-
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
swarm: use happy eyeballs ranking for TCP dials #2573
Conversation
9db6917
to
62b878b
Compare
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.
Do we also need to use this for WebTransport? WebTransport also has a two-step handshake: The QUIC handshake finishes first, then we do the WebTransport session setup.
0bea85f
to
a92d4e7
Compare
@marten-seemann Addressed review comments. I'll take webtransport up in a later PR. |
p2p/net/swarm/dial_ranker.go
Outdated
copy(addrs[2:], addrs[1:i]) | ||
for j := 1; j < len(addrs); j++ { | ||
if isQUICAddr(addrs[j]) && isProtocolAddr(addrs[j], ma.P_IP4) { | ||
// The first IPv4 address is at position i |
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.
Isn't i
always 0 here?
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.
my bad. This should be j.
// If the first address is (QUIC, IPv6), make the second address (QUIC, IPv4). | ||
happyEyeballs := false | ||
if len(addrs) > 0 { | ||
// addrs is now sorted by (Transport, IPVersion). Reorder addrs for happy eyeballs dialing. |
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.
Should this sorting logic be part of score
?
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'm not sure if that'd be more readable. For this ranking we need to look at other addresses, so an IPv4 address gets higher score than other IPv6 addresses only if there are some IPv6 addresses present. I think the present implementation makes the logic explicit.
1c0aee3
to
58979d1
Compare
The required change is much simpler than my previous tries. Closing other open PRs in favour of this.