示例#1
0
 def __init__(self, addr, port, data, local_hander):
     super().__init__()
     self.data = data
     self.local = local_hander
     self.peername = None
     self._transport = None
     self.cipher = CipherMan(access_user=self.local.cipher.access_user)
示例#2
0
 def __init__(self, addr, port, data, local_hander):
     super().__init__()
     self.data = data
     self.local = local_hander
     self.peername = None
     self._transport = None
     self.cipher = CipherMan(access_user=self.local.cipher.access_user,
                             ts_protocol=flag.TRANSPORT_UDP)
     self._is_closing = False
示例#3
0
 def connection_made(self, transport: asyncio.Transport):
     self._transport = transport
     self.peername = self._transport.get_extra_info("peername")
     self.cipher = CipherMan(access_user=self.local.cipher.access_user,
                             peername=self.peername)
     transport.write(self.local._connect_buffer)
     self.ready = True
     CONNECTION_MADE_COUNT.inc()
     ACTIVE_CONNECTION_COUNT.inc()
示例#4
0
    def __init__(self, local_handler):
        super().__init__()

        self.local = local_handler
        self.peername = None
        self._transport = None
        self.cipher = CipherMan(access_user=local_handler.cipher.access_user)
        self.ready = False

        self._is_closing = False
示例#5
0
    def __init__(self, addr, port, data, local_handler):
        super().__init__()

        self.data = data
        self.local = local_handler
        self.cipher = CipherMan(access_user=local_handler.cipher.access_user)

        self.peername = None
        self._transport = None
        self.loop = asyncio.get_running_loop()
示例#6
0
    def datagram_received(self, data, peer, *args):
        if not self.cipher_man:
            self.cipher_man = CipherMan(access_user=self.local.cipher_man.access_user, ts_protocol=flag.TRANSPORT_UDP)

        assert self.peer == peer
        # 源地址和端口
        bind_addr = peer[0]
        bind_port = peer[1]
        if "." in bind_addr:
            addr = socket.inet_pton(socket.AF_INET, bind_addr)
        elif ":" in bind_addr:
            addr = socket.inet_pton(socket.AF_INET6, bind_addr)
        else:
            raise Exception("add not valid")
        port = struct.pack("!H", bind_port)
        # 构造返回的报文结构
        data = b"\x01" + addr + port + data
        data = self.cipher_man.encrypt(data)
        self.local.write(data)
示例#7
0
 def connection_made(self, transport: asyncio.Transport):
     self._transport = transport
     self.peer = self._transport.get_extra_info("peername")
     self.cipher_man = CipherMan(access_user=self.local.cipher_man.access_user, peer=self.peer)
     transport.write(self.local.connect_buffer)
     self.ready = True