Class: Ftpd::CommandLoop
- Inherits:
-
Object
- Object
- Ftpd::CommandLoop
- Extended by:
- Forwardable
- Includes:
- Error
- Defined in:
- lib/ftpd/command_loop.rb
Instance Method Summary collapse
-
#initialize(session) ⇒ CommandLoop
constructor
A new instance of CommandLoop.
- #read_and_execute_commands ⇒ Object
Methods included from Error
#error, #sequence_error, #syntax_error, #unimplemented_error
Constructor Details
#initialize(session) ⇒ CommandLoop
Returns a new instance of CommandLoop.
11 12 13 |
# File 'lib/ftpd/command_loop.rb', line 11 def initialize(session) @session = session end |
Instance Method Details
#read_and_execute_commands ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ftpd/command_loop.rb', line 15 def read_and_execute_commands 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 unless valid_command?(command) error "Syntax error, command unrecognized: #{s.chomp}", 500 end command_sequence_checker.check command execute_command command, argument rescue FtpServerError => e reply e. rescue => e reply "451 Requested action aborted. Local error in processing." config.exception_handler.call(e) unless config.exception_handler.nil? end end rescue Errno::ECONNRESET, Errno::EPIPE end end end |