Class: Ftpd::CmdPort

Inherits:
CommandHandler show all
Defined in:
lib/ftpd/cmd_port.rb

Overview

The Data Port (PORT) command.

Constant Summary

Constants inherited from CommandHandler

Ftpd::CommandHandler::COMMAND_FILENAME_PREFIX, Ftpd::CommandHandler::COMMAND_KLASS_PREFIX, Ftpd::CommandHandler::COMMAND_METHOD_PREFIX

Instance Method Summary collapse

Methods inherited from CommandHandler

commands, #initialize

Methods included from FileSystemHelper

#ensure_accessible, #ensure_directory, #ensure_does_not_exist, #ensure_exists, #ensure_file_system_supports, #path_list, #unique_path

Methods included from Error

#error, #sequence_error, #syntax_error, #unimplemented_error

Methods included from DataConnectionHelper

#close_data_server_socket_when_done, #data_connection_description, #encrypt_data?, #handle_data_disconnect, #make_tls_connection, #open_active_data_connection, #open_active_tls_data_connection, #open_data_connection, #open_passive_data_connection, #open_passive_tls_data_connection, #receive_file, #send_start_of_data_connection_reply, #transmit_file

Constructor Details

This class inherits a constructor from Ftpd::CommandHandler

Instance Method Details

#cmd_port(argument) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ftpd/cmd_port.rb', line 9

def cmd_port(argument)
  ensure_logged_in
  ensure_not_epsv_all
  pieces = argument.split(/,/)
  syntax_error unless pieces.size == 6
  pieces.collect! do |s|
    syntax_error unless s =~ /^\d{1,3}$/
    i = s.to_i
    syntax_error unless (0..255) === i
    i
  end
  hostname = pieces[0..3].join('.')
  port = pieces[4] << 8 | pieces[5]
  set_active_mode_address hostname, port
  reply "200 PORT command successful"
end