Call Router Work (untested)
# Conflicts: # hblink.py
This commit is contained in:
parent
8faeb39095
commit
e90da9f02e
22
hb_router.py
22
hb_router.py
@ -88,20 +88,17 @@ class routerMASTER(HBMASTER):
|
|||||||
_target = rule['DST_NET']
|
_target = rule['DST_NET']
|
||||||
if _target in RULES['MASTERS']:
|
if _target in RULES['MASTERS']:
|
||||||
_tmp_data = _data
|
_tmp_data = _data
|
||||||
_tmp_data = _tmp_data.replace(_radio_id, CONFIG['MASTERS'][_target]['RADIO_ID'])
|
masters[_target].send_clients(_client, _tmp_data)
|
||||||
for _client in CONFIG['MASTERS'][_target]._clients:
|
logger.debug('(%s) Packet routed to master instance: %s', self._master, _target)
|
||||||
if _client != _radio_id:
|
|
||||||
masters[_target].send_packet(_client, _tmp_data)
|
|
||||||
logger.debug('(%s) Packet bridged to client: %s', self._master, _target)
|
|
||||||
|
|
||||||
elif _target in RULES['CLIENTS']:
|
elif _target in RULES['CLIENTS']:
|
||||||
_tmp_data = _data
|
_tmp_data = _data
|
||||||
_tmp_data = _tmp_data.replace(_radio_id, CONFIG['CLIENTS'][_target]['RADIO_ID'])
|
_tmp_data = _tmp_data.replace(_radio_id, CONFIG['CLIENTS'][_target]['RADIO_ID'])
|
||||||
clients[_target].send_packet(_tmp_data)
|
clients[_target].send_packet(_tmp_data)
|
||||||
logger.debug('(%s) Packet bridged to master: %s', self._master, _target)
|
logger.debug('(%s) Packet routed to client instance: %s', self._master, _target)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print('no luck')
|
logger.debug('(%s) Packet router found no target for packet. Destination was: %s on target network %s', self._master, _dst_id, _target)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
@ -112,20 +109,17 @@ class routerCLIENT(HBCLIENT):
|
|||||||
_target = rule['DST_NET']
|
_target = rule['DST_NET']
|
||||||
if _target in RULES['MASTERS']:
|
if _target in RULES['MASTERS']:
|
||||||
_tmp_data = _data
|
_tmp_data = _data
|
||||||
#_tmp_data = _tmp_data.replace(_radio_id, CONFIG['MASTERS'][_target]['RADIO_ID'])
|
masters[_target].send_packet(_client, _tmp_data)
|
||||||
for _client in CONFIG['MASTERS'][_target]['CLIENTS']:
|
logger.debug('(%s) Packet routed to master instance: %s', self._client, _target)
|
||||||
if _client != _radio_id:
|
|
||||||
masters[_target].send_packet(_client, _tmp_data)
|
|
||||||
logger.debug('(%s) Packet bridged to client: %s', self._client, _target)
|
|
||||||
|
|
||||||
elif _target in RULES['CLIENTS']:
|
elif _target in RULES['CLIENTS']:
|
||||||
_tmp_data = _data
|
_tmp_data = _data
|
||||||
_tmp_data = _tmp_data.replace(_radio_id, CONFIG['CLIENTS'][_target]['RADIO_ID'])
|
_tmp_data = _tmp_data.replace(_radio_id, CONFIG['CLIENTS'][_target]['RADIO_ID'])
|
||||||
clients[_target].send_packet(_tmp_data)
|
clients[_target].send_packet(_tmp_data)
|
||||||
logger.debug('(%s) Packet bridged to master: %s', self._client, _target)
|
logger.debug('(%s) Packet routed to client instance: %s', self._client, _target)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print('no luck')
|
logger.debug('(%s) Packet router found no target for packet. Destination was: %s on target network %s', self._client, _dst_id, _target)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
#************************************************
|
#************************************************
|
||||||
|
@ -188,6 +188,13 @@ class HBMASTER(DatagramProtocol):
|
|||||||
# Remove any timed out clients from the configuration
|
# Remove any timed out clients from the configuration
|
||||||
del CONFIG['MASTERS'][self._master]['CLIENTS'][client]
|
del CONFIG['MASTERS'][self._master]['CLIENTS'][client]
|
||||||
|
|
||||||
|
def send_clients(self, _packet):
|
||||||
|
for _client in self._clients:
|
||||||
|
#add destiantion re-writer here split _data and insert target client radio_id at: _data[11:15]
|
||||||
|
_tmp_data = _data[:11] + _client + _data[15:]
|
||||||
|
self.send_packet(_client, _data)
|
||||||
|
logger.debug('(%s) Packet sent to all connected clients', self._master)
|
||||||
|
|
||||||
def send_packet(self, _client, _packet):
|
def send_packet(self, _client, _packet):
|
||||||
_ip = self._clients[_client]['IP']
|
_ip = self._clients[_client]['IP']
|
||||||
_port = self._clients[_client]['PORT']
|
_port = self._clients[_client]['PORT']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user