Class: Ftpd::Session
Instance Method Summary collapse
-
#initialize(opts) ⇒ Session
constructor
A new instance of Session.
- #run ⇒ Object
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.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ftpd/session.rb', line 8 def initialize(opts) @driver = opts[:driver] @auth_level = opts[:auth_level] @socket = opts[:socket] @tls = opts[:tls] if @tls == :implicit @socket.encrypt end @name_prefix = '/' @debug_path = opts[:debug_path] @debug = opts[:debug] @list_formatter = opts[:list_formatter] @data_type = 'A' @mode = 'S' @structure = 'F' @response_delay = opts[:response_delay] @data_channel_protection_level = :clear @command_sequence_checker = init_command_sequence_checker @logged_in = false end |
Instance Method Details
#run ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ftpd/session.rb', line 29 def run reply "220 ftpd" catch :done do loop do begin s = get_command 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. rescue Errno::ECONNRESET, Errno::EPIPE end end end end |