Add maximum peer limit for master instances

This commit is contained in:
Cort Buffington 2018-11-25 15:07:55 -06:00
parent 8a6225bd8e
commit 83692f037c
3 changed files with 44 additions and 33 deletions

View File

@ -202,6 +202,7 @@ def build_config(_config_file):
'MODE': config.get(section, 'MODE'),
'ENABLED': config.getboolean(section, 'ENABLED'),
'REPEAT': config.getboolean(section, 'REPEAT'),
'MAX_PEERS': config.getint(section, 'MAX_PEERS'),
'EXPORT_AMBE': config.getboolean(section, 'EXPORT_AMBE'),
'IP': gethostbyname(config.get(section, 'IP')),
'PORT': config.getint(section, 'PORT'),

View File

@ -142,12 +142,17 @@ TGID_ACL: PERMIT:ALL
# and unused by anything else.
# Repeat - if True, the master repeats traffic to peers, False, it does nothing.
#
# MAX_PEERS -- maximun number of peers that may be connect to this master
# at any given time. This is very handy if you're allowing hotspots to
# connect, or using a limited computer like a Raspberry Pi.
#
# ACLs:
# See comments in the GLOBAL stanza
[MASTER-1]
MODE: MASTER
ENABLED: True
REPEAT: True
MAX_PEERS: 10
EXPORT_AMBE: False
IP:
PORT: 54000

View File

@ -370,6 +370,8 @@ class HBSYSTEM(DatagramProtocol):
elif _command == 'RPTL': # RPTLogin -- a repeater wants to login
_peer_id = _data[4:8]
# Check to see if we've reached the maximum number of allowed peers
if len(self._peers < self._config['MAX_PEERS']):
# Check for valid Radio ID
if acl_check(_peer_id, self._CONFIG['GLOBAL']['REG_ACL']) and acl_check(_peer_id, self._config['REG_ACL']):
# Build the configuration data strcuture for the peer
@ -405,6 +407,9 @@ class HBSYSTEM(DatagramProtocol):
else:
self.transport.write('MSTNAK'+_peer_id, _sockaddr)
logger.warning('(%s) Invalid Login from Radio ID: %s Denied by Registation ACL', self._system, int_id(_peer_id))
else:
self.transport.write('MSTNAK'+_peer_id, _sockaddr)
logger.warning('(%s) Registration denied from Radio ID: %s Maximum number of peers exceeded', self._system, int_id(_peer_id))
elif _command == 'RPTK': # Repeater has answered our login challenge
_peer_id = _data[4:8]