ftp
ftp copied to clipboard
Fix hang when using ExplicitTLS to certain servers.
In #282 it was discovered that doing the tls Handshake immediately on connection causes some FTP servers (proftpd and pureftpd) to hang.
The exact cause of this is unknown, but this patch works around the problem by not doing the Handsake initially, and only doing it at the end if we were attempting to upload a zero length file.
Doing the Handshake at the end was originally added in a4e9650823896675 however it got reverted in 212daf295f0e6ae4 which used tls.DialWithDialer to do the handshake. Unfortunately tls.DialWithDialer seems to trigger the hanging bug.
See: https://forum.rclone.org/t/rclone-ftps-explicit-rclone-touch-empty-files-proftpd-unable-to-build-data-connection-operation-not-permitted/22522 See: https://github.com/rclone/rclone/issues/6426#issuecomment-1243993039 Fixes #282
Coverage decreased (-2.0%) to 72.521% when pulling 5da37698fc590b6252507d769934a3e1e202956f on ncw:fix-282-tls-handshake-hang into 6512c2a4ae1a4090fd6e9a10f98bb11aebe3c44f on jlaffaye:master.
Can you please add a comment in the code to explain why we setup the connection with tls.Client and not tls.Dial ? So we dont forget about this in the future.
I've put a comment in explaining the reasoning.
Encountered this bug today with pure-ftpd server - the proposed fix worked for me.
Tackled this as well - any chance we can merge the PR ?
I have updated the code with a bit more documentation.
Unfortunately I'm going to have to hard fork flaffaye for the rclone v1.60 release with this patch in - I'll move the rclone back as soon as this gets merged and released.
facing the same issue, @ncw When are you planning to merge this one?
@mohsek not my call! I have merged a fix for this in rclone 1.60 github.com/rclone/[email protected]
I had the same error with the hanging connection
So i tried to use this one No i get an EOF error... Filezilla has no problems uploading files with Explicit TLS. But i am not sure if this is the server or the lib....
Server is pureftp
` 220-You are user number 2 of 5 allowed.
220-Local time is now 17:46. 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 xxxx
331 User admin OK. Password required
PASS xxxx
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 (|||30005|)
STOR myfile
150 Accepted data connection
1 error occurred: * EOF `
@jlaffaye any chance we could get this merged?
Oops totally forgot about this PR