You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The workaround I'm currently using for this is as follows (it stores the address used for the initial connection and then just reuses that for any further connections). This is quite a common problem where FTP servers are behind NAT.
var d net.Dialer
var firstHost string
dialFunc = func(network, address string) (net.Conn, error) {
host, port, err := net.SplitHostPort(address)
if err != nil {
return nil, fmt.Errorf("ftp.Open: Failed to split address %s: %w", address, err)
}
if len(firstHost) == 0 {
firstHost = host
}
return d.DialContext(ctx, "tcp", net.JoinHostPort(firstHost, port))
}
c, err := ftp.Dial(ftpUrl.Host, ftp.DialWithContext(ctx), ftp.DialWithDialFunc(dialFunc))
@tgulacsi that should fix some uses; in my case all of the addresses are private so the isBogusDataIP() would return false (and the fix would not be applied).
@MattBrittan sorry, I've missed that the server has private IP address.
Then your solution is the most straightforward.
Maybe documenting it would be enough.
Hi!
Faced this error while working with bad-configured third-party FTP server...
Logs from connection to the same server in FileZilla:
It would be better to have the similar behavior.
May be implemented as a new
DialOption
.The text was updated successfully, but these errors were encountered: