Class: Ftpd::Session
- Inherits:
-
Object
- Object
- Ftpd::Session
- Defined in:
- lib/ftpd/session.rb
Instance Method Summary collapse
-
#initialize(opts) ⇒ Session
constructor
A new instance of Session.
- #run ⇒ Object
Methods included from ListPath
Methods included from Error
#error, #permanent_error, #sequence_error, #transient_error, #unimplemented_error, #unrecognized_error
Constructor Details
#initialize(opts) ⇒ Session
Returns a new instance of Session.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ftpd/session.rb', line 9 def initialize(opts) @failed_login_delay = opts[:failed_login_delay] @connection_tracker = opts[:connection_tracker] @max_failed_logins = opts[:max_failed_logins] @log = opts[:log] || NullLogger.new @allow_low_data_ports = opts[:allow_low_data_ports] @server_name = opts[:server_name] @server_version = opts[:server_version] @driver = opts[:driver] @auth_level = opts[:auth_level] @socket = opts[:socket] @tls = opts[:tls] @list_formatter = opts[:list_formatter] @response_delay = opts[:response_delay] @session_timeout = opts[:session_timeout] if @tls == :implicit @socket.encrypt end @command_sequence_checker = init_command_sequence_checker @protocols = Protocols.new(@socket) initialize_session end |
Instance Method Details
#run ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ftpd/session.rb', line 33 def run catch :done do begin reply "220 #{server_name_and_version}" loop do begin s = get_command s = process_telnet_sequences(s) syntax_error unless s =~ /^(\w+)(?: (.*))?$/ command, argument = $1.downcase, $2 method = 'cmd_' + command unless respond_to?(method, true) unrecognized_error s end @command_sequence_checker.check command send(method, argument) rescue CommandError => e reply e. end end rescue Errno::ECONNRESET, Errno::EPIPE end end end |