示例#1
0
 def _process_backend(self):
     inst = self.backend.accept()
     if not inst:
         return
     record_conn = RecordConnection(self.key, inst)
     tunnel = TunnelConnection(record_conn)
     tunnel.address = inst.address
     self.tunnels[tunnel] = {}
     info("connected", 'backend', inst.address)
示例#2
0
 def __init__(self, config):
     self.local_conn = Connection(socket.socket(), -1)
     # read config
     if 'address' in config:
         self.address = config['address']
     if 'port' in config:
         self.port = config['port']
     # initialize local port
     self.local_conn.conn.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,
                                     1)
     self.local_conn.bind((self.address, self.port))
     self.local_conn.listen(10)
     # initialize backend & record layer
     Backend = import_backend(config).ClientBackend
     self.backend = Backend(**config['backend'])
     self.record_conn = RecordConnection(config['key'], self.backend)
     self.tunnel = TunnelConnection(self.record_conn)
     # initialize connection dict
     self.conns = {}