-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix: don't prefer local ports from other addresses when dialing #1673
Conversation
@@ -177,20 +176,13 @@ func testPrefer(t *testing.T, listen, prefer, avoid ma.Multiaddr) { | |||
} | |||
defer listenerB1.Close() | |||
|
|||
dialOne(t, &trB, listenerA, listenerB1.Addr().(*net.TCPAddr).Port) |
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.
We now only prefer source ports if the dialing addresses match.
type dialer interface { | ||
Dial(network, addr string) (net.Conn, error) | ||
DialContext(ctx context.Context, network, addr string) (net.Conn, error) | ||
} |
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.
We now have one dialer, so there's no need to abstract over them.
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 remember having spent quite some time digging through this code a while back (and forgotten most about it), so I'm mainly asking for more documentation here.
p2p/net/reuseport/dialer.go
Outdated
|
||
// DialContext dials a target addr. | ||
// Dialing preference is | ||
// * If there is a listener on the local interface the OS expects to use to route towards addr, use that. |
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 have problems parsing this sentence.
p2p/net/reuseport/dialer.go
Outdated
// DialContext dials a target addr. | ||
// Dialing preference is | ||
// * If there is a listener on the local interface the OS expects to use to route towards addr, use that. | ||
// * If there is a listener on a loopback address, addr is loopback, use that. |
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.
This one as well, do you mean?
// * If there is a listener on a loopback address, addr is loopback, use that. | |
// * If there is a listener on a loopback address and addr is loopback, use that. |
This address may already be in-use (on that other address) somewhere else. Thanks to @schomatis for figuring this out. fixes #1611
@marten-seemann done. |
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.
Thank you for the excellent documentation, @Stebalien!
…ng (libp2p#1673)" This reverts commit bbd2836.
This address may already be in-use (on that other address) somewhere else.
Thanks to @schomatis for figuring this out.
fixes #1611