Python telnetlib.IAC Examples
The following are 11
code examples of telnetlib.IAC().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
telnetlib
, or try the search function
.
Example #1
Source File: telnet.py From flashre with GNU Lesser General Public License v3.0 | 6 votes |
def __init__(self, host): self.tlnt = telnetlib.Telnet(host, 23) # Announce that we will send strings character per character self.write_raw(telnetlib.IAC + telnetlib.WONT + telnetlib.LINEMODE)
Example #2
Source File: telnet.py From flashre with GNU Lesser General Public License v3.0 | 5 votes |
def write_raw(self, data): """ Write raw data to the socket, as the regular write() doubles IAC characters. From http://stackoverflow.com/questions/12421799/how-to-disable-telnet-echo-in-python-telnetlib # noqa: E501 """ t_sck = self.tlnt.get_socket() t_sck.send(data)
Example #3
Source File: telnet.py From netman with Apache License 2.0 | 5 votes |
def _accept_all(sock, cmd, opt): if cmd == WILL: sock.sendall(IAC + DO + opt) elif cmd == WONT: sock.sendall(IAC + DONT + opt)
Example #4
Source File: microlparallax.py From pyLIMA with GNU General Public License v3.0 | 5 votes |
def optcallback(socket, command, option): """Write by Tim Lister, thanks :) """ cnum = ord(command) onum = ord(option) if cnum == telnetlib.WILL: # and onum == ECHO: socket.write(telnetlib.IAC + telnetlib.DONT + onum) if cnum == telnetlib.DO and onum == telnetlib.TTYPE: socket.write(telnetlib.IAC + telnetlib.WONT + telnetlib.TTYPE) ### Uncomment the following if the spacecraft dataset is huge! and also the global variables # at the begining of the module # width = struct.pack('H', MAX_WINDOW_WIDTH) # height = struct.pack('H', MAX_WINDOW_HEIGHT) # socket.send(telnetlib.IAC + telnetlib.SB + telnetlib.NAWS + width + height + telnetlib.IAC + telnetlib.SE)
Example #5
Source File: telnet.py From logparser with GNU General Public License v3.0 | 5 votes |
def telnet_callback(tn, command, option): if command == DO and option == TTYPE: tn.sendall(IAC + WILL + TTYPE) tn.sendall(IAC + SB + TTYPE + '\0' + 'LogParser' + IAC + SE) elif command in (DO, DONT): tn.sendall(IAC + WILL + option) elif command in (WILL, WONT): tn.sendall(IAC + DO + option)
Example #6
Source File: epdb_client.py From conary with Apache License 2.0 | 5 votes |
def ctrl_c(self, int, tb): self.sock.sendall(IAC + IP) self.sock.sendall('close\n') raise KeyboardInterrupt
Example #7
Source File: epdb_client.py From conary with Apache License 2.0 | 5 votes |
def updateTerminalSize(self): rows, cols = getTerminalSize() out = struct.pack('>HH', cols, rows) out.replace('\xFF', '\xFF\xFF') # escape IAC self.sock.sendall(IAC + SB + NAWS + out + IAC + SE)
Example #8
Source File: epdb_server.py From conary with Apache License 2.0 | 5 votes |
def process_IAC(self, sock, cmd, option): """ Read in and parse IAC commands as passed by telnetlib. SB/SE commands are stored in sbdataq, and passed in w/ a command of SE. """ if cmd == DO: if option == TM: # timing mark - send WILL into outgoing stream os.write(self.remote, IAC + WILL + TM) else: pass elif cmd == IP: # interrupt process os.write(self.local, chr(ord('C') & 0x1F)) elif cmd == SB: pass elif cmd == SE: option = self.sbdataq[0] if option == NAWS: # negotiate window size. cols = ord(self.sbdataq[1]) rows = ord(self.sbdataq[2]) s = struct.pack('HHHH', rows, cols, 0, 0) fcntl.ioctl(self.local, termios.TIOCSWINSZ, s) elif cmd == DONT: pass else: pass
Example #9
Source File: epdb_client.py From epdb with MIT License | 5 votes |
def ctrl_c(self, int, tb): self.sock.sendall(IAC + IP) self.sock.sendall(b'close\n') raise KeyboardInterrupt
Example #10
Source File: epdb_client.py From epdb with MIT License | 5 votes |
def updateTerminalSize(self): rows, cols = getTerminalSize() out = struct.pack(b'>HH', cols, rows) if IAC in out: out.replace(IAC, IAC + IAC) # escape IAC self.sock.sendall(IAC + SB + NAWS + out + IAC + SE)
Example #11
Source File: epdb_server.py From epdb with MIT License | 5 votes |
def process_IAC(self, sock, cmd, option): """ Read in and parse IAC commands as passed by telnetlib. SB/SE commands are stored in sbdataq, and passed in w/ a command of SE. """ if cmd == DO: if option == TM: # timing mark - send WILL into outgoing stream os.write(self.remote, IAC + WILL + TM) else: pass elif cmd == IP: # interrupt process os.write(self.local, IPRESP) elif cmd == SB: pass elif cmd == SE: option = self.sbdataq[0] if option == NAWS[0]: # negotiate window size. cols = six.indexbytes(self.sbdataq, 1) rows = six.indexbytes(self.sbdataq, 2) s = struct.pack('HHHH', rows, cols, 0, 0) fcntl.ioctl(self.local, termios.TIOCSWINSZ, s) elif cmd == DONT: pass else: pass