Add switch for server ID validation:

You should add this to [GLOBAL]:

VALIDATE_SERVER_IDS: True

Please set to True if you are part of FreeDMR network.
If you are standalone or private network, You can set it to False if you want.
identtg v1.3.5
Simon 4 years ago
parent 09630c6850
commit 2baabdbd79
No known key found for this signature in database
GPG Key ID: 6ACF11630B5D8F82

@ -147,7 +147,8 @@ def build_config(_config_file):
'ALLOW_NULL_PASSPHRASE': config.getboolean(section, 'ALLOW_NULL_PASSPHRASE'), 'ALLOW_NULL_PASSPHRASE': config.getboolean(section, 'ALLOW_NULL_PASSPHRASE'),
'ANNOUNCEMENT_LANGUAGES': config.get(section, 'ANNOUNCEMENT_LANGUAGES'), 'ANNOUNCEMENT_LANGUAGES': config.get(section, 'ANNOUNCEMENT_LANGUAGES'),
'SERVER_ID': config.getint(section, 'SERVER_ID').to_bytes(4, 'big'), 'SERVER_ID': config.getint(section, 'SERVER_ID').to_bytes(4, 'big'),
'DATA_GATEWAY': config.getboolean(section, 'DATA_GATEWAY') 'DATA_GATEWAY': config.getboolean(section, 'DATA_GATEWAY'),
'VALIDATE_SERVER_IDS': config.getboolean(section, 'VALIDATE_SERVER_IDS')
}) })
if not CONFIG['GLOBAL']['ANNOUNCEMENT_LANGUAGES']: if not CONFIG['GLOBAL']['ANNOUNCEMENT_LANGUAGES']:

@ -450,25 +450,26 @@ class OPENBRIDGE(DatagramProtocol):
logger.warning('(%s) Packet more than 5s old!, discarding', self._system) logger.warning('(%s) Packet more than 5s old!, discarding', self._system)
return return
#Discard bad source server if self._CONFIG['GLOBAL']['VALIDATE_SERVER_IDS']:
if ((len(str(int.from_bytes(_source_server,'big'))) < 4) or (len(str(int.from_bytes(_source_server,'big'))) > 7)): #Discard bad source server
if _stream_id not in self._laststrid: if ((len(str(int.from_bytes(_source_server,'big'))) < 4) or (len(str(int.from_bytes(_source_server,'big'))) > 7)):
logger.warning('(%s) Source Server should be between 4 and 7 digits, discarding Src: %s', self._system, int.from_bytes(_source_server,'big')) if _stream_id not in self._laststrid:
self.send_bcsq(_dst_id,_stream_id) logger.warning('(%s) Source Server should be between 4 and 7 digits, discarding Src: %s', self._system, int.from_bytes(_source_server,'big'))
self._laststrid.append(_stream_id) self.send_bcsq(_dst_id,_stream_id)
return self._laststrid.append(_stream_id)
elif (len(str(int.from_bytes(_source_server,'big'))) == 4 or (len(str(int.from_bytes(_source_server,'big'))) == 5)) and ((str(int.from_bytes(_source_server,'big'))[:4]) not in self._CONFIG['_SERVER_IDS'] ): return
if _stream_id not in self._laststrid: elif (len(str(int.from_bytes(_source_server,'big'))) == 4 or (len(str(int.from_bytes(_source_server,'big'))) == 5)) and ((str(int.from_bytes(_source_server,'big'))[:4]) not in self._CONFIG['_SERVER_IDS'] ):
logger.warning('(%s) Source Server ID is 4 or 5 digits but not in list: %s', self._system, int.from_bytes(_source_server,'big')) if _stream_id not in self._laststrid:
self.send_bcsq(_dst_id,_stream_id) logger.warning('(%s) Source Server ID is 4 or 5 digits but not in list: %s', self._system, int.from_bytes(_source_server,'big'))
self._laststrid.append(_stream_id) self.send_bcsq(_dst_id,_stream_id)
return self._laststrid.append(_stream_id)
elif len(str(int.from_bytes(_source_server,'big'))) > 5 and not self.validate_id(_source_server): return
if _stream_id not in self._laststrid: elif len(str(int.from_bytes(_source_server,'big'))) > 5 and not self.validate_id(_source_server):
logger.warning('(%s) Source Server 6 or 7 digits but not a valid DMR ID, discarding Src: %s', self._system, int.from_bytes(_source_server,'big')) if _stream_id not in self._laststrid:
self.send_bcsq(_dst_id,_stream_id) logger.warning('(%s) Source Server 6 or 7 digits but not a valid DMR ID, discarding Src: %s', self._system, int.from_bytes(_source_server,'big'))
self._laststrid.append(_stream_id) self.send_bcsq(_dst_id,_stream_id)
return self._laststrid.append(_stream_id)
return
#Increment max hops #Increment max hops
_inthops = _hops +1 _inthops = _hops +1

Loading…
Cancel
Save

Powered by TurnKey Linux.