-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
p2p/net/conn: reuse listen tcp port to dial #602
Conversation
https://build.protocol-dev.com/job/ipfs_test_all_commits_on_branch/185/console <-- tells me tests_all_commits fails, but i cant tell which commit. |
RFCR |
this PR shouldnt be against ipfs, you should file it against Go. |
return -1, err | ||
} | ||
|
||
// set non-blocking until after connect, because we cant poll using runtime :( |
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.
whats this?
Is much of this code directly copied from go's |
Right!?
Yeah, the stuff copied straight out is marked with the copyright notice. The |
This amount of copy pasting is horrible. This PR is an exercise in why internal packages / forcibly unaccessible symbols are a bad idea. There's a significant difference between "not exporting something to my interface" and "making it absolutely impossible for you to use this code". It should be possible to import things if you really mean it. Maybe as a different package altogether with a dependency like ibaz "foo/bar/baz/internal". |
https://build.protocol-dev.com/job/build%20docker%20image/923/console
Maybe the chore should happen before the docker image tries to build and fails? or this may be unrelated. cc @briantigerchow |
Looks pretty good to me, let's hope it solves our issues! |
@whyrusleeping is that a LGTM on the PR? |
This commit finally makes use of the sent observed addrs. If the connection's local address is from one of our listen addrs, then the remote's observed addr is its natted mapping, which is useful to us. For now, we add it directly to our address book. (a future commit should make addressbook addresses expire)
This commit cleans up the reuse port setup, and fixes a problem: make sure to filter addrs out that we simply cannot dial with (e.g. loopback -> non-loopback, or linklocal -> nonlinklocal)
Yeah, merge it! (before i change my mind! :P ) |
p2p/net/conn: reuse listen tcp port to dial
This PR finally makes it possible to dial out from our TCP listen addr. I had to sink low into net to make this possible. The result is the go-reuseport package. Sadly
golang/net
doesnt let us add tcp socket options, so we have to do it this way (setting up the sockets manually, which is truly painful). can see the same approach used in various modules:Anyway, this PR:
[1] wow i just discovered this one... after rolling my own. fffff! it looks good-- we might want to switch to this one if my go-reuseport gives us problems