def __init__(self, config, passphrase=None): Connection.__init__(self) if not isinstance(config, Config): raise ValueError('Config must be an instance of Config()') public_key = private_key = None if config.public_key: with open(config.public_key, 'rb') as file: public_key = file.read() if config.private_key: with open(config.private_key, 'rb') as file: private_key = file.read() self.aes_dir = config.aes_dir self.rsa = lib_rsa.Rsa(private_key=private_key, public_key=public_key, passphrase=passphrase) self.aes, self.aes_filename = self.__get_aes_info()
class Tcpconnection(Connection): def __init__(self, module, (dst, dport), (src, sport)): Connection.__init__(self, module, (dst, dport), (src, sport)) self.outqueue = PriorityQueue() self.inqueue = PriorityQueue() self.outseq = 0 # last ACKed sequence number self.outseq_max = 0 # for detection of out of order packets # minimum sequence number that is allowed to get appended # i.e. packets that got inserted, ack'd AND retransmitted must not # be appended to the {incoming,outgoing} buffer again self.outseq_min = 0 self.inseq_min = 0 self.inseq = 0 # last ACKed sequence number self.inseq_max = 0 # for detection of out of order packets
def __init__(self): Connection.__init__(self)