fix(ftp): refresh deadline after TCP connect instead of sharing one

Revert the pre-computed deadline approach. A successful TCP connect is
forward movement: the server is responsive. Giving banner+login a fresh
timeout window after connect avoids false verification failures on
slow-but-working servers. Worst case is 2*timeout total, which is still
bounded (not indefinite) and a safe trade-off vs. the risk of starving
the FTP handshake with leftover time from a slow connect.

Co-authored-by: Dylan Ayrey <[email protected]>
This commit is contained in:
Cursor Agent
2026-02-23 07:27:11 +00:00
co-authored by Dylan Ayrey
parent 064ce88cef
commit a4dcac7e27
+2 -3
View File
@@ -129,13 +129,12 @@ func verifyFTP(timeout time.Duration, u *url.URL) error {
host = host + ":21"
}
deadline := time.Now().Add(timeout)
c, err := ftp.Dial(host, ftp.DialWithDialFunc(func(network, address string) (net.Conn, error) {
conn, err := net.DialTimeout(network, address, time.Until(deadline))
conn, err := net.DialTimeout(network, address, timeout)
if err != nil {
return nil, err
}
if err := conn.SetDeadline(deadline); err != nil {
if err := conn.SetDeadline(time.Now().Add(timeout)); err != nil {
conn.Close()
return nil, err
}