jlaffaye / ftp

FTP client package for Go
ISC License
1.31k stars 359 forks source link

EOF when parsing response from Explicit TLS connection #323

Open michal239 opened 1 year ago

michal239 commented 1 year ago

Describe the bug

getting io.EOF error after running list/stor/retr method the example describes running the mlsd command, but the same issue happens when i try to upload or download a file To Reproduce

    cl, err := ftp.Dial(
        host,
        ftp.DialWithExplicitTLS(&tls.Config{InsecureSkipVerify: true}),
        ftp.DialWithDebugOutput(os.Stdout),
    )
    if err != nil {
        log.Error(err)
    }

    err = cl.Login(user, password)
    if err != nil {
        log.Error(err)
    }
    _, err = cl.List(".")
    if err != nil {
        log.Error(err) // EOF ERROR HERE
    }

    cl.Quit()

Expected behavior no error

FTP server pure ftpd, latest version

Debug output library debug log:

220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 5 allowed.
220-Local time is now 14:32. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
AUTH TLS
234 AUTH TLS OK.
USER michal
331 User michal OK. Password required
PASS 1234
230 OK. Current directory is /
FEAT
211-Extensions supported:
 EPRT
 IDLE
 MDTM
 SIZE
 MFMT
 REST STREAM
 MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
 MLSD
 AUTH TLS
 PBSZ
 PROT
 UTF8
 TVFS
 ESTA
 PASV
 EPSV
 SPSV
211 End.
TYPE I
200 TYPE is now 8-bit binary
OPTS UTF8 ON
200 OK, UTF-8 enabled
PBSZ 0
200 PBSZ=0
PROT P
200 Data protection level set to "private"
EPSV
229 Extended Passive mode OK (|||30000|)
MLSD .
150 Accepted data connection
ERRO[1859] can't list files: 1 error occurred:
    * EOF

QUIT

server debug log:

ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (?@172.22.0.1) [INFO] New connection from 172.22.0.1
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (?@172.22.0.1) [DEBUG] 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (?@172.22.0.1) [DEBUG] 220-You are user number 1 of 5 allowed.
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (?@172.22.0.1) [DEBUG] 220-Local time is now 14:32. Server port: 21.
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (?@172.22.0.1) [DEBUG] 220-This is a private system - No anonymous login
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (?@172.22.0.1) [DEBUG] 220-IPv6 connections are also welcome on this server.
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (?@172.22.0.1) [DEBUG] 220 You will be disconnected after 15 minutes of inactivity.
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (?@172.22.0.1) [DEBUG] Command [auth] [TLS]
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (?@172.22.0.1) [DEBUG] 234 AUTH TLS OK.
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (?@172.22.0.1) [INFO] TLS: Enabled TLSv1.3 with TLS_AES_256_GCM_SHA384, 256 secret bits cipher
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (?@172.22.0.1) [DEBUG] Command [user] [michal]
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (?@172.22.0.1) [DEBUG] 331 User michal OK. Password required
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (?@172.22.0.1) [DEBUG] Command [pass] [<*>]
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (?@172.22.0.1) [INFO] michal is now logged in
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (michal@172.22.0.1) [DEBUG] 230 OK. Current directory is /
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (michal@172.22.0.1) [DEBUG] Command [feat] []
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (michal@172.22.0.1) [DEBUG] 211-Extensions supported:#015#012 EPRT#015#012 IDLE#015#012 MDTM#015#012 SIZE#015#012 MFMT#015#012 REST STREAM#015#012 MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;#015#012 MLSD#015#012 AUTH TLS#015#012 PBSZ#015#012 PROT#015#012 UTF8#015#012 TVFS#015#012 ESTA#015#012 PASV#015#012 EPSV#015#012 SPSV#015
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (michal@172.22.0.1) [DEBUG] 211 End.
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (michal@172.22.0.1) [DEBUG] Command [type] [I]
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (michal@172.22.0.1) [DEBUG] 200 TYPE is now 8-bit binary
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (michal@172.22.0.1) [DEBUG] Command [opts] [UTF8 ON]
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (michal@172.22.0.1) [DEBUG] 200 OK, UTF-8 enabled
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (michal@172.22.0.1) [DEBUG] Command [pbsz] [0]
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (michal@172.22.0.1) [DEBUG] 200 PBSZ=0
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (michal@172.22.0.1) [DEBUG] Command [prot] [P]
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (michal@172.22.0.1) [DEBUG] 200 Data protection level set to "private"
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (michal@172.22.0.1) [DEBUG] Command [epsv] []
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (michal@172.22.0.1) [DEBUG] 229 Extended Passive mode OK (|||30000|)
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (michal@172.22.0.1) [DEBUG] Command [mlsd] [.]
ftps  | Mar 29 14:32:07 e8497fae7061 pure-ftpd: (michal@172.22.0.1) [DEBUG] 150 Accepted data connection
michal239 commented 1 year ago

offtop: PASS 1234 shouldn't that be masked?