Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

buengese
Copy link
Member

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

  • I have read the contribution guidelines.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate.
  • All commit messages are in house style.
  • I'm done, this Pull Request is ready for review :-)

@buengese buengese requested a review from ncw June 13, 2022 16:13
Copy link
Member

@ncw ncw left a 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 {
Copy link
Member

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"?

Copy link
Member Author

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.

fs/config/configflags/configflags.go Show resolved Hide resolved
fs/config/configflags/configflags.go Show resolved Hide resolved
@buengese
Copy link
Member Author

buengese commented Jun 13, 2022

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.

@ncw
Copy link
Member

ncw commented Jun 13, 2022

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 rand.Intn(2) == 0)

ncw added a commit that referenced this pull request Aug 30, 2023
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/
@ncw ncw closed this in cffe85e Sep 1, 2023
@ncw
Copy link
Member

ncw commented Sep 1, 2023

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 --bind 0.0.0.0 to force rclone to use IPv4 addresses and --bind ::0 to force rclone to use IPv6 addresses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants