diff --git a/bridge_master.py b/bridge_master.py index 9602c67..c3c8fac 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -979,22 +979,21 @@ def _saveRecording(): _recording_state['rf_src'] = None def _sendFilteredByTG(_sys_obj, pkt, _tg, _ts, _label, _pkt_idx): - _tg_bytes = bytes_3(_tg) if isinstance(_tg, int) else _tg - if hasattr(_sys_obj, '_peer_tg') and hasattr(_sys_obj, '_peers'): - _sent_count = 0 - for _peer in list(_sys_obj._peers.keys()): - _send = False - if _peer in _sys_obj._peer_tg: - if _ts in _sys_obj._peer_tg[_peer]: - if _sys_obj._peer_tg[_peer][_ts]['tgid'] == _tg_bytes: - _send = True - if _send: - _sys_obj.send_peer(_peer, pkt) - _sent_count += 1 - return _sent_count - else: + _sys_name = _sys_obj._system + _tg_str = str(_tg) if isinstance(_tg, int) else str(int_id(_tg)) + + _has_active_bridge = False + if _tg_str in BRIDGES: + for _be in BRIDGES[_tg_str]: + if _be['SYSTEM'] == _sys_name and _be['TS'] == _ts and _be['ACTIVE']: + _has_active_bridge = True + break + + if _has_active_bridge: _sys_obj.send_system(pkt) return -1 + else: + return 0 def _announcementSendBroadcast(_targets, _pkts, _pkt_idx, _source_id, _dst_id, _tg, _ts, _ann_num=1, _next_time=None): global _announcement_running @@ -1034,8 +1033,8 @@ def _announcementSendBroadcast(_targets, _pkts, _pkt_idx, _source_id, _dst_id, _ _sys_obj.STATUS[_stream_id]['LAST'] = _now _slot['TX_TIME'] = _now _fc = _sendFilteredByTG(_sys_obj, pkt, _tg, _ts, _label, _pkt_idx) - if _pkt_idx == 0 and _fc >= 0: - logger.info('(%s) TG filter: %s/%s peers match TG %s TS%s on %s', _label, _fc, len(_sys_obj._peers), _tg, _ts, _t['name']) + if _pkt_idx == 0 and _fc == 0: + logger.debug('(%s) TG %s TS%s not active on %s, skipping', _label, _tg, _ts, _t['name']) except Exception as e: logger.error('(%s) Error sending packet %s to %s: %s', _label, _pkt_idx, _t['name'], e) @@ -1371,8 +1370,8 @@ def _ttsSendBroadcast(_targets, _pkts, _pkt_idx, _source_id, _dst_id, _tg, _ts, _sys_obj.STATUS[_stream_id]['LAST'] = _now _slot['TX_TIME'] = _now _fc = _sendFilteredByTG(_sys_obj, pkt, _tg, _ts, _label, _pkt_idx) - if _pkt_idx == 0 and _fc >= 0: - logger.info('(%s) TG filter: %s/%s peers match TG %s TS%s on %s', _label, _fc, len(_sys_obj._peers), _tg, _ts, _t['name']) + if _pkt_idx == 0 and _fc == 0: + logger.debug('(%s) TG %s TS%s not active on %s, skipping', _label, _tg, _ts, _t['name']) except Exception as e: logger.error('(%s) Error sending packet %s to %s: %s', _label, _pkt_idx, _t['name'], e) @@ -2322,7 +2321,6 @@ class routerHBP(HBSYSTEM): } } self.CALL_DATA = [] - self._peer_tg = {} def to_target(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data, pkt_time, dmrpkt, _bits,_bridge,_system,_noOBP,sysIgnore,_source_server, _ber, _rssi, _source_rptr): _sysIgnore = sysIgnore @@ -3022,10 +3020,6 @@ class routerHBP(HBSYSTEM): if CONFIG['REPORTS']['REPORT']: self._report.send_bridgeEvent('GROUP VOICE,START,RX,{},{},{},{},{},{}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id)).encode(encoding='utf-8', errors='ignore')) - if _peer_id not in self._peer_tg: - self._peer_tg[_peer_id] = {} - self._peer_tg[_peer_id][_slot] = {'tgid': _dst_id, 'time': pkt_time} - else: logger.info('(%s) *VCSBK* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s _dtype_vseq: %s', self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot, _dtype_vseq)