module Ronin::Support::Network::FTP::Mixin
Provides helper methods for communicating with FTP
servers.
Constants
Public Instance Methods
Source
# File lib/ronin/support/network/ftp/mixin.rb, line 83 def ftp_connect(host, port: DEFAULT_PORT, user: DEFAULT_USER, password: nil, account: nil, passive: true) host = DNS::IDN.to_ascii(host) ftp = Net::FTP.new ftp.connect(host,port) ftp.login(user,password,account) ftp.passive = passive if block_given? yield ftp ftp.close else return ftp end end
Creates a connection to the FTP
server.
@param [String] host
The host to connect to.
@param [Integer] port
The port to connect to.
@param [String] user
The user to authenticate with.
@param [String] password
The password to authenticate with.
@param [String] account
The FTP account information to send via the `ACCT` command.
@param [Boolean] passive
Specifies whether the FTP session should use passive mode.
@yield [ftp]
If a block is given, it will be passed an FTP session object. Once the block returns, the FTP session will be closed.
@yieldparam [Net::FTP] ftp
The FTP session.
@return [Net::FTP, nil]
The FTP session. If a block is given, then `nil` will be returned.
@example
ftp_connect('www.example.com', user: 'joe', password: 'secret')
@example
ftp_connect('www.example.com', user: 'joe', password: 'secret') do |ftp| # ... end
@api public