"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: Add cookie support with cmdline switch --use-cookies
qipf471a7e3f5c4
diff --git a/fs/config.go b/fs/config.goindex aaa392ae4..3499a9fec 100644--- a/fs/config.go+++ b/fs/config.go@@ -85,6 +85,7 @@ type ConfigInfo struct {MaxBacklog intStatsOneLine boolProgress bool+ Cookie bool}// NewConfig creates a new config with everything set to the defaultdiff --git a/fs/config/configflags/configflags.go b/fs/config/configflags/configflags.goindex 9e9ca06a3..f9201bcda 100644--- a/fs/config/configflags/configflags.go+++ b/fs/config/configflags/configflags.go@@ -87,6 +87,7 @@ func AddFlags(flagSet *pflag.FlagSet) {flags.IntVarP(flagSet, &fs.Config.MaxBacklog, "max-backlog", "", fs.Config.MaxBacklog, "Maximum number of objects in sync or check backlog.")flags.BoolVarP(flagSet, &fs.Config.StatsOneLine, "stats-one-line", "", fs.Config.StatsOneLine, "Make the stats fit on one line.")flags.BoolVarP(flagSet, &fs.Config.Progress, "progress", "P", fs.Config.Progress, "Show progress during transfer.")+ flags.BoolVarP(flagSet, &fs.Config.Cookie, "use-cookies", "", fs.Config.Cookie, "Enable session cookiejar.")}// SetFlags converts any flags into config which weren't straight fowarddiff --git a/fs/fshttp/http.go b/fs/fshttp/http.goindex e8240c9a5..a11dcc0fc 100644--- a/fs/fshttp/http.go+++ b/fs/fshttp/http.go@@ -7,12 +7,14 @@ import ("crypto/tls""net""net/http"+ "net/http/cookiejar""net/http/httputil""reflect""sync""time""github.com/ncw/rclone/fs"+ "golang.org/x/net/publicsuffix""golang.org/x/time/rate")@@ -22,9 +24,10 @@ const ()var (- transport http.RoundTripper- noTransport sync.Once- tpsBucket *rate.Limiter // for limiting number of http transactions per second+ transport http.RoundTripper+ noTransport sync.Once+ tpsBucket *rate.Limiter // for limiting number of http transactions per second+ cookieJar, _ = cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List}))// StartHTTPTokenBucket starts the token bucket if necessary@@ -142,9 +145,13 @@ func NewTransport(ci *fs.ConfigInfo) http.RoundTripper {// NewClient returns an http.Client with the correct timeoutsfunc NewClient(ci *fs.ConfigInfo) *http.Client {- return &http.Client{+ transport := &http.Client{Transport: NewTransport(ci),}+ if ci.Cookie {+ transport.Jar = cookieJar+ }+ return transport}// Transport is a our http Transport which wraps an http.Transport