I'm trying to get FTPFXP to work on Ruby 2.0 (so I can FTP over TLS)
I'm having problems with this line, which sets up the SSL Socket. OpenSSL checks whether @sock
is a T_FILE
In Ruby 1.9.3, it worked well, because it was just a TCPSocket
but in Ruby 2.0, @sock
becomes a Net::FTP::BufferedSocket
.
It's easy enough to change the code in https://github.com/codeodor/ftpfxp/blob/06f2d56e65e73d3818b6c7aef4dfe461bad98849/lib/ftpfxp/ftpfxptls.rb#L87 to send @sock.io
to make it a TCPSocket
again, but when Net::FTP
tries to close the socket, it expects the socket to have a read timeout, which I'm guessing BufferedSocket
has, but a TCPSocket
does not.
So, a few questions:
- Should a
Net::FTP::BufferedSocket
be aFile
? - Should Net::FTP be assuming it has a
BufferedSocket
at all times? - Should TCPSocket implement
read_timeout
?
I guess the broader question is: what is the appropriate fix? Obviously I'll need to work around it in my code, but is this something that should be fixed in Ruby, and if so, where?
Thanks for your help!
If we just monkeypatch null implementations of those 2 methods onto
OpenSSL::SSL::SSLSocket
it runs,but it only gets the first block, the 2nd call toread
on the connection returnsnil
: https://github.com/ruby/ruby/blob/v2_0_0_247/lib/net/ftp.rb#L490Updated: Ok, I was wrong about it only reading the first block. It's just the file I was testing on was much smaller than I expected. So the monkeypatching seems to work.
Now how do we fix this in Ruby, or is there anything wrong with Ruby?