diff --git a/backend/ftp/ftp.go b/backend/ftp/ftp.go index 2c0617911..d2b3c5fa3 100644 --- a/backend/ftp/ftp.go +++ b/backend/ftp/ftp.go @@ -456,9 +456,7 @@ func (f *Fs) ftpConnection(ctx context.Context) (c *ftp.ServerConn, err error) { } }() baseDialer := fshttp.NewDialer(ctx) - if f.opt.SocksProxy != "" { - conn, err = proxy.SOCKS5Dial(network, address, f.opt.SocksProxy, baseDialer) - } else if f.proxyURL != nil { + if f.opt.SocksProxy != "" || f.proxyURL != nil { // We need to make the onward connection to f.opt.Host. However the FTP // library sets the host to the proxy IP after using EPSV or PASV so we need // to correct that here. @@ -468,7 +466,11 @@ func (f *Fs) ftpConnection(ctx context.Context) (c *ftp.ServerConn, err error) { return nil, err } dialAddress := net.JoinHostPort(f.opt.Host, dialPort) - conn, err = proxy.HTTPConnectDial(network, dialAddress, f.proxyURL, baseDialer) + if f.opt.SocksProxy != "" { + conn, err = proxy.SOCKS5Dial(network, dialAddress, f.opt.SocksProxy, baseDialer) + } else { + conn, err = proxy.HTTPConnectDial(network, dialAddress, f.proxyURL, baseDialer) + } } else { conn, err = baseDialer.Dial(network, address) }