def process_incoming_control(self, msg): cosby_log('control sequence:', hex_to_ascii(msg)) ctrl_io = { IAC + DO + '\x18' : IAC + WILL + '\x18' + IAC + SB + '\x18\x00' + 'xterm-color' + IAC + SE, IAC + DO + '\x20' : IAC + WONT + '\x20', IAC + DO + '\x23' : IAC + WONT + '\x23', IAC + DO + '\x27' : IAC + WONT + '\x27', IAC + WILL + '\x03' : IAC + DO + '\x03', IAC + DO + '\x01' : IAC + WILL + '\x01', IAC + DO + '\x1f' : IAC + WILL + '\x1f' + IAC + SB + '\x1f\x00\xa0\x00\x30' + IAC + SE, IAC + WILL + '\x05' : IAC + DONT + '\x05', IAC + DO + '\x21' : IAC + WONT + '\x21', IAC + WILL + '\x01' : IAC + DONT + '\x01', IAC + DONT + '\x01' : IAC + WONT + '\x01' } if msg == IAC + WONT + '\x63': assert self.network_state == STATE_WAITING_FOR_DATA_AND_PONG self.npongs += 1 self.transition(STATE_WANT_TO_SEND_DATA) if self.inbuffer_ansi: sys.stdout.write(self.inbuffer_ansi) sys.stdout.flush() for listener in self.listeners: listener.process_incoming(self.inbuffer_ansi) else: cosby_log('ERROR: received a pong but no ansi buffer') self.inbuffer_ansi = '' elif msg in ctrl_io: response = ctrl_io[msg] self.outbuffer += response if self.network_state == STATE_WAITING_FOR_DATA: self.transition(STATE_WANT_TO_SEND_PING) else: cosby_log('I do not know how to respond to the telnet sequence.')
def process_incoming_control_subcommand(self, msg): cosby_log('subcommand:', hex_to_ascii(msg))
def process_incoming_control_subcommand(self, msg): print >> self.log, 'subcommand:', hex_to_ascii(msg)