"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
fshttp: fix --bind 0.0.0.0 allowing IPv6 and --bind ::0 allowing IPv4
Nick Craig-Woodcffe85e6c50a
diff --git a/docs/content/docs.md b/docs/content/docs.mdindex c229bef19..a520424e0 100644--- a/docs/content/docs.md+++ b/docs/content/docs.md@@ -641,6 +641,9 @@ IPv4 address (1.2.3.4), an IPv6 address (1234::789A) or host name. Ifthe host name doesn't resolve or resolves to more than one IP addressit will give an error.+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.+### --bwlimit=BANDWIDTH_SPEC ###This option controls the bandwidth limit. For examplediff --git a/fs/fshttp/dialer.go b/fs/fshttp/dialer.goindex adeece185..a41b478b8 100644--- a/fs/fshttp/dialer.go+++ b/fs/fshttp/dialer.go@@ -52,6 +52,17 @@ var warnDSCPFail, warnDSCPWindows sync.Once// DialContext connects to the network address using the provided context.func (d *Dialer) DialContext(ctx context.Context, network, address string) (net.Conn, error) {+ // If local address is 0.0.0.0 or ::0 force IPv4 or IPv6+ // This works around https://github.com/golang/go/issues/48723+ // Which means 0.0.0.0 and ::0 both bind to both IPv4 and IPv6+ if ip, ok := d.Dialer.LocalAddr.(*net.TCPAddr); ok && ip.IP.IsUnspecified() && (network == "tcp" || network == "udp") {+ if ip.IP.To4() != nil {+ network += "4" // IPv4 address+ } else {+ network += "6" // IPv6 address+ }+ }+c, err := d.Dialer.DialContext(ctx, network, address)if err != nil {return c, err