Module: RTunnel::CommandProcessor

Included in:
RTunnel::Client::ServerConnection, Server, Server::ControlConnection
Defined in:
lib/rtunnel/command_processor.rb

Overview

The plumbing for processing RTunnel commands.

Instance Method Summary collapse

Instance Method Details

#process_close_connection(connection_id) ⇒ Object

Override to process CloseConnectionCommand. Do NOT call super.



24
25
26
# File 'lib/rtunnel/command_processor.rb', line 24

def process_close_connection(connection_id)
  unexpected_command @last_command
end

#process_create_connection(connection_id) ⇒ Object

Override to process CreateConnectionCommand. Do NOT call super.



29
30
31
# File 'lib/rtunnel/command_processor.rb', line 29

def process_create_connection(connection_id)
  unexpected_command @last_command
end

#process_generate_session_key(public_key_fp) ⇒ Object

Override to process GenerateSessionKeyCommand. Do NOT call super.



34
35
36
# File 'lib/rtunnel/command_processor.rb', line 34

def process_generate_session_key(public_key_fp)
  unexpected_command @last_command
end

#process_keep_aliveObject

Override to process KeepAliveCommand. Do NOT call super.



39
40
41
# File 'lib/rtunnel/command_processor.rb', line 39

def process_keep_alive
  unexpected_command @last_command
end

#process_remote_listen(address) ⇒ Object

Override to process RemoteListenCommand. Do NOT call super.



44
45
46
# File 'lib/rtunnel/command_processor.rb', line 44

def process_remote_listen(address)
  unexpected_command @last_command
end

#process_send_data(connection_id, data) ⇒ Object

Override to process SendDataCommand. Do NOT call super.



49
50
51
# File 'lib/rtunnel/command_processor.rb', line 49

def process_send_data(connection_id, data)
  unexpected_command @last_command
end

#process_set_session_key(encrypted_keys) ⇒ Object

Override to process SetSessionKeyCommand. Do NOT call super.



54
55
56
# File 'lib/rtunnel/command_processor.rb', line 54

def process_set_session_key(encrypted_keys)
  unexpected_command @last_command
end

#receive_command(command) ⇒ Object

Called by CommandProtocol to process a command.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rtunnel/command_processor.rb', line 4

def receive_command(command)
  case @last_command = command
  when RTunnel::CloseConnectionCommand
    process_close_connection command.connection_id
  when RTunnel::CreateConnectionCommand
    process_create_connection command.connection_id
  when RTunnel::GenerateSessionKeyCommand
    process_generate_session_key command.public_key_fp
  when RTunnel::KeepAliveCommand
    process_keep_alive
  when RTunnel::RemoteListenCommand
    process_remote_listen command.address
  when RTunnel::SendDataCommand
    process_send_data command.connection_id, command.data
  when RTunnel::SetSessionKeyCommand
    process_set_session_key command.encrypted_keys
  end
end

#unexpected_command(command) ⇒ Object

Override to handle commands that haven’t been overridden.



59
60
61
# File 'lib/rtunnel/command_processor.rb', line 59

def unexpected_command(command)
    W "Unexpected command: #{command.inspect}"    
end