-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
core: add NatPortMap and default it to true #3775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@whyrusleeping defaulting Other than that I followed your outline. This still needs tests that the actual NAT discovery is turned off, but I am not sure how to do that. Hints welcome. |
License: MIT Signed-off-by: Kevin Atkinson <[email protected]>
4af66e5
to
5082f83
Compare
core/core.go
Outdated
@@ -728,7 +732,12 @@ func constructPeerHost(ctx context.Context, id peer.ID, ps pstore.Peerstore, bwr | |||
network.Swarm().Filters.AddDialFilter(f) | |||
} | |||
|
|||
host := p2pbhost.New(network, p2pbhost.NATPortMap, bwr) | |||
newOpts := []interface{}{bwr} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably call this hostOpts
repo/config/config.go
Outdated
@@ -34,6 +34,20 @@ type Config struct { | |||
Experimental Experiments | |||
} | |||
|
|||
// NewConfig creates any new Config with all the values set the | |||
// default | |||
func NewConfig() *Config { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call this NewDefaultConfig
repo/fsrepo/serialize/serialize.go
Outdated
var cfg config.Config | ||
err := ReadConfigFile(filename, &cfg) | ||
cfg := config.NewConfig() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldnt add a space here
' | ||
|
||
test_expect_success "Swarm.NatPortMap has line in config file" ' | ||
grep -q NatPortMap .ipfs/config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redirect output to devnull
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is what the -q
is for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, gotcha
' | ||
|
||
test_expect_success "remove Swarm.NatPortMap from config file" ' | ||
sed -i "s/NatPortMap/XxxYyyyZzz/" .ipfs/config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use $IPFS_PATH
' | ||
|
||
test_expect_success "load config file by replacing a unrelated key" ' | ||
ipfs config --json Swarm.DisableBandwidthMetrics false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a note here:
Note: this is relying on an implementation detail where setting a config field loads the json blob into the config struct, causing defaults to be properly set. Simply 'reading' the config would read the json directly and not cause defaults to be reset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments
License: MIT Signed-off-by: Kevin Atkinson <[email protected]>
License: MIT Signed-off-by: Kevin Atkinson <[email protected]>
Addressed CR feedback. I am not going to be comfortable with the PR until we figure out how to test for NAT discovery. I caught a rather serious bug that should of caused tests to fail in |
@kevina NAT traversal is not tested, yes. I've looked into testing this (spending a significant amount of time in doing so) and came up empty. It seems that even nat traversal libraries don't have proper tests. |
Okay than I am going to do some hackish manual testing to make sure that the setting is at least being honored. I will remove the WIP from the title when that is done. |
All right, I tested it manually and the settings are being honored. I not sure I like how the default to true is being handled but if @whyrusleeping and @Kubuxu are okay with it than so am I. |
@Kubuxu What do you think? |
This just highlights defectiveness of config system to me. What do you think about shifting to default + overrides config? If we decide for it, I would love to see some other project that did something similar in past and it worked out well. |
Or we could change the option to |
@whyrusleeping your call |
Alright, we can use Lets also make sure to add this field to the config options document in |
Because removing the default to true was the majority of this pull request I decided to redo the P.R. as #3798. Closing. Please don't delete the branch. |
@whyrusleeping is there a reason you deleted this branch when I asked "Please don't delete the branch." We (or at least me) might want to refer back to it. I thought the idea was for old branched to be moved to go-ipfs-archived. For some reason GitHub isn't allowing me to restore this branch so I re-pushed my code from my local repo. |
@kevina whoops. I just compulsively click the delete branch button |
Closes #2964
License: MIT
Signed-off-by: Kevin Atkinson [email protected]