이것은 내 문제입니다. 보일러 플레이트 :
# Connects to ftp through a socks proxy
#
# TODO: testing, use ssl, capture debugging output, recovery on network failure...
#
# @param ftpHost [String ] Domain name or ip address of the ftp server
# @param proxyHost [String ] Host name or ip address of the socks proxy
# @param proxyPort [FixNum ] Port number of the socks proxy
# @param proxyUser [String ] User name for connecting to the proxy if needed
# @param proxyPass [String ] Password for connecting to the proxy if needed
# @param ftpPort [FixNum ] Ftp port, defaults to 21
# @param ftpUser [String ] Ftp username
# @param ftpPass [String ] Ftp password
# @param debug [Boolean] Whether to turn on debug output of both socksify and Net::FTP, will be sent to STDOUT
# @param passive [Boolean] Whether to use passive FTP mode
#
def ftp(
ftpHost: ,
proxyHost: ,
proxyPort: ,
proxyUser: nil ,
proxyPass: nil ,
ftpPort: Net::FTP::FTP_PORT ,
ftpUser: 'anonymous' ,
ftpPass: '[email protected]' ,
debug: false ,
passive: true
)
Socksify::debug = debug
TCPSocket::socks_username = proxyUser
TCPSocket::socks_password = proxyPass
Socksify::proxy(proxyHost, proxyPort) do |_|
begin
# Check whether we got an ip address or a domain name.
# If needed we'll do dns through the socket to avoid dns leaks.
#
Regexp.new(URI::RFC2396_Parser.new.pattern[ :IPV4ADDR ]) =~ ftpHost or
ftpHost = Socksify::resolve(ftpHost)
ftp = Net::FTP.new
ftp.debug_mode = debug
ftp.passive = passive
ftp.connect ftpHost, ftpPort
ftp.login ftpUser, ftpPass
yield ftp
ensure
ftp.close
end
end
end
지금 실제 응용 프로그램에서 당신은 다만 할 수 있습니다
tvgriek에
def listRemoteFiles
connect do |ftp|
puts ftp.list.inspect # or other cool functions from Net::FTP
end
end
def connect &block
ftp({
debug: true ,
proxyHost: your.proxy.host ,
proxyPort: your.proxy.port ,
ftpHost: your.ftpHost
}, &block)
end
감사를 올바른 방향으로 가리키는 위해.
출처
2017-02-05 20:04:36
nus
혹시 이것을 알아 냈습니까? –
@JohnWright 불행히도 : ( –