switch(self.ConnectionType) {
case CON_TELNET:
Telnet.send(self, self.SendBuffer);
break;
case CON_SSH;
SSH.send(self, self.SendBuffer);
break;
default:
fprintf(stderr, "ERROR: Invalid Connection Type! Tried to send '%s'\n", self.SendBuffer);
break;
}
from netboa.coroutine import coroutine
_CR = '\r' # Carriage Return or ASCII 10
_LF = '\n' # Line Feed (Python newline) or ASCII 13
_NULL = '\x00' # Null Character
@coroutine
def t2p_eol_proto(client, target):
"""
Protocol to convert inward Telnet line terminators to Python-style
newlines.
Normally, Telnet lines are terminated with a CR-LF pair, however
some application may use CR-NULL or just a LF so we need to cope
with all three.
"""
while True:
byte = (yield)
if byte == _CR:
next_byte = (yield)
if next_byte == _LF or next_byte == _NULL:
target.send(_LF)
else:
## weirdness, but not our place to argue
target.send(_CR)
target.send(next_byte)
else:
target.send(byte)