Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

sftp: fix proxy initialisation

Nick Craig-Wood933bbf3ac835
diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.go
index f7eb2a1c3..97678c4c2 100644
--- a/backend/sftp/sftp.go
+++ b/backend/sftp/sftp.go
@@ -925,15 +925,8 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
opt.Port = "22"
}
- // get proxy URL if set
- if opt.HTTPProxy != "" {
- proxyURL, err := url.Parse(opt.HTTPProxy)
- if err != nil {
- return nil, fmt.Errorf("failed to parse HTTP Proxy URL: %w", err)
- }
- f.proxyURL = proxyURL
- }
-
+ // Set up sshConfig here from opt
+ // **NB** everything else should be setup in NewFsWithConnection
sshConfig := &ssh.ClientConfig{
User: opt.User,
Auth: []ssh.AuthMethod{},
@@ -1181,11 +1174,21 @@ func NewFsWithConnection(ctx context.Context, f *Fs, name string, root string, m
f.mkdirLock = newStringLock()
f.pacer = fs.NewPacer(ctx, pacer.NewDefault(pacer.MinSleep(minSleep), pacer.MaxSleep(maxSleep), pacer.DecayConstant(decayConstant)))
f.savedpswd = ""
+
// set the pool drainer timer going
if f.opt.IdleTimeout > 0 {
f.drain = time.AfterFunc(time.Duration(f.opt.IdleTimeout), func() { _ = f.drainPool(ctx) })
}
+ // get proxy URL if set
+ if opt.HTTPProxy != "" {
+ proxyURL, err := url.Parse(opt.HTTPProxy)
+ if err != nil {
+ return nil, fmt.Errorf("failed to parse HTTP Proxy URL: %w", err)
+ }
+ f.proxyURL = proxyURL
+ }
+
f.features = (&fs.Features{
CanHaveEmptyDirectories: true,
SlowHash: true,