Package ssh :: Module packet :: Class Packetizer
[frames] | no frames]

Class Packetizer

source code

object --+
         |
        Packetizer

Implementation of the base SSH packet protocol.

Instance Methods
 
__init__(self, socket)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
set_log(self, log)
Set the python log object to use for logging.
source code
 
set_outbound_cipher(self, block_engine, block_size, mac_engine, mac_size, mac_key)
Switch outbound data cipher.
source code
 
set_inbound_cipher(self, block_engine, block_size, mac_engine, mac_size, mac_key)
Switch inbound data cipher.
source code
 
set_outbound_compressor(self, compressor) source code
 
set_inbound_compressor(self, compressor) source code
 
close(self) source code
 
set_hexdump(self, hexdump) source code
 
get_hexdump(self) source code
 
get_mac_size_in(self) source code
 
get_mac_size_out(self) source code
 
need_rekey(self)
Returns True if a new set of keys needs to be negotiated.
source code
 
set_keepalive(self, interval, callback)
Turn on/off the callback keepalive.
source code
str
read_all(self, n, check_rekey=False)
Read as close to N bytes as possible, blocking as long as necessary.
source code
 
write_all(self, out) source code
 
readline(self, timeout)
Read a line from the socket.
source code
 
send_message(self, data)
Write a block of data using the current cipher, as an SSH block.
source code
 
read_message(self)
Only one thread should ever be in this function (no other locking is done).
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variables
  REKEY_PACKETS = pow(2, 30)
  REKEY_BYTES = pow(2, 30)
Properties

Inherited from object: __class__

Method Details

__init__(self, socket)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

need_rekey(self)

source code 

Returns True if a new set of keys needs to be negotiated. This will be triggered during a packet read or write, so it should be checked after every read or write, or at least after every few.

Returns:
True if a new set of keys needs to be negotiated

set_keepalive(self, interval, callback)

source code 

Turn on/off the callback keepalive. If interval seconds pass with no data read from or written to the socket, the callback will be executed and the timer will be reset.

read_all(self, n, check_rekey=False)

source code 

Read as close to N bytes as possible, blocking as long as necessary.

Parameters:
  • n (int) - number of bytes to read
Returns: str
the data read
Raises:
  • EOFError - if the socket was closed before all the bytes could be read

readline(self, timeout)

source code 

Read a line from the socket. We assume no data is pending after the line, so it's okay to attempt large reads.

read_message(self)

source code 

Only one thread should ever be in this function (no other locking is done).

Raises: