From 077b5b6d405f01f06e0663db155ca443c46f4c04 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 5 Mar 2022 16:54:35 +0000 Subject: [PATCH] init --- const.py | 3 +++ hblink.py | 3 +++ hotspot_proxy_v2.py | 3 +++ 3 files changed, 9 insertions(+) diff --git a/const.py b/const.py index efa30e9..53279da 100755 --- a/const.py +++ b/const.py @@ -73,6 +73,9 @@ RPTA = b'RPTA' RPTO = b'RPTO' DMRA = b'DMRA' +#Prox commands +PRIN = b'PRIN' + #Bridge Control commands BC = b'BC' BCKA = b'BCKA' diff --git a/hblink.py b/hblink.py index e265099..ec82f16 100755 --- a/hblink.py +++ b/hblink.py @@ -1067,6 +1067,9 @@ class HBSYSTEM(DatagramProtocol): elif _command == DMRA: _peer_id = _data[4:8] logger.debug('(%s) Peer has sent Talker Alias packet %s', self._system, _data) + + elif _command == PRIN: + logger.info('(%s) *ProxyInfo* Source IP/Port: %s', self._system, _data.decode('utf8')) else: logger.error('(%s) Unrecognized command. Raw HBP PDU: %s', self._system, _data) diff --git a/hotspot_proxy_v2.py b/hotspot_proxy_v2.py index a3643ee..2e7cd6a 100644 --- a/hotspot_proxy_v2.py +++ b/hotspot_proxy_v2.py @@ -183,6 +183,9 @@ class Proxy(DatagramProtocol): self.peerTrack[_peer_id]['shost'] = host self.peerTrack[_peer_id]['timer'] = reactor.callLater(self.timeout,self.reaper,_peer_id) self.transport.write(data, (self.master,_dport)) + pripacket = b''.join([b'PRIN',host.encode('UTF-8'),b':',port.encode('UTF-8')]) + #Send IP and Port info to server + self.transport.write(pripacket, (self.master,_dport)) if self.clientinfo and _peer_id != b'\xff\xff\xff\xff': print(f'{datetime.now().replace(microsecond=0)} New client: ID:{str(int_id(_peer_id)).rjust(9)} IP:{host.rjust(15)} Port:{port}, assigned to port:{_dport}.')