-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Implement a way to force rclone to use ipv4/ipv6 #6244
Conversation
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 is a useful feature, but it doesn't actually implement what the user wanted in #6124 which was to use both IPv4 and IPv6, so (maybe) alternate betwen them or choose one at random.
Either way that should be on a different flag in a different commit!
var c net.Conn | ||
var err error | ||
ci := fs.GetConfig(ctx) | ||
if ci.PreferIPv4 { |
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.
What are the possible values of network
here? Maybe these if statements should be wrapped in an if network == "tcp"
?
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.
The http transport will only use tcp
which lets the dialer decide between IPv4 and IPv6. Other possible values would be udp, udp4, udp6, ip, ip4, ip6
.
Hm true automatically switching between them could probably be implemented in the same place if something like round robin is enough. Everything more fancy would be rather complicated. Connection reuse might interfere tough. I kinda need this feature too, so I'll think about it. |
If you want to do it, I'd start with round robin and see if that is good enough. (or even |
Due to a bug/misfeature in the go standard library as described here: golang/go#48723 the go standard library binds to both IPv4 and IPv6 when passed 0.0.0.0 or ::0. This patch detects the bind address and forces the correct IP protocol. Fixes #6124 Fixes #6244 See: https://forum.rclone.org/t/issues-with-bind-0-0-0-0-and-onedrive-getting-etag-mismatch-when-using-ipv6/41379/
I've merged a variant of this to master now which means it will be in the latest beta in 15-30 minutes and released in v1.64 You can use |
What is the purpose of this change?
Implement a way force rclone to use IPv4/IPv6 on a dual-stack network as requested in #6124 . This was the simplest way I could think of that should have desired effect.
Limitations include this forcing the dialer to make tcp connections only. This shouldn't be problem for
net/http
since HTTP/1.1 and HTTP/2 are tcp only .I might have also missed other problems with this approach.
Alternative ways of achieving this is modifying address resolution probably by providing a custom resolver to the dialer.
Checklist