Class: FakeFtp::ServerCommands::Port

Inherits:
Object
  • Object
show all
Defined in:
lib/fake_ftp/server_commands/port.rb

Instance Method Summary collapse

Instance Method Details

#run(ctx, remote = '') ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fake_ftp/server_commands/port.rb', line 6

def run(ctx, remote = '', *)
  remote = remote.split(',')
  remote_port = remote[4].to_i * 256 + remote[5].to_i
  unless ctx.command_state[:active_connection].nil?
    ctx.command_state[:active_connection].close
    ctx.command_state[:active_connection] = nil
  end
  ctx.mode = :active
  ctx.debug('_port active connection ->')
  ctx.command_state[:active_connection] = ::TCPSocket.new(
    '127.0.0.1', remote_port
  )
  ctx.debug('_port active connection <-')
  '200 Okay'
end