Add maximum peer limit for master instances
This commit is contained in:
parent
8a6225bd8e
commit
83692f037c
@ -202,6 +202,7 @@ def build_config(_config_file):
|
|||||||
'MODE': config.get(section, 'MODE'),
|
'MODE': config.get(section, 'MODE'),
|
||||||
'ENABLED': config.getboolean(section, 'ENABLED'),
|
'ENABLED': config.getboolean(section, 'ENABLED'),
|
||||||
'REPEAT': config.getboolean(section, 'REPEAT'),
|
'REPEAT': config.getboolean(section, 'REPEAT'),
|
||||||
|
'MAX_PEERS': config.getint(section, 'MAX_PEERS'),
|
||||||
'EXPORT_AMBE': config.getboolean(section, 'EXPORT_AMBE'),
|
'EXPORT_AMBE': config.getboolean(section, 'EXPORT_AMBE'),
|
||||||
'IP': gethostbyname(config.get(section, 'IP')),
|
'IP': gethostbyname(config.get(section, 'IP')),
|
||||||
'PORT': config.getint(section, 'PORT'),
|
'PORT': config.getint(section, 'PORT'),
|
||||||
|
@ -142,12 +142,17 @@ TGID_ACL: PERMIT:ALL
|
|||||||
# and unused by anything else.
|
# and unused by anything else.
|
||||||
# Repeat - if True, the master repeats traffic to peers, False, it does nothing.
|
# 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:
|
# ACLs:
|
||||||
# See comments in the GLOBAL stanza
|
# See comments in the GLOBAL stanza
|
||||||
[MASTER-1]
|
[MASTER-1]
|
||||||
MODE: MASTER
|
MODE: MASTER
|
||||||
ENABLED: True
|
ENABLED: True
|
||||||
REPEAT: True
|
REPEAT: True
|
||||||
|
MAX_PEERS: 10
|
||||||
EXPORT_AMBE: False
|
EXPORT_AMBE: False
|
||||||
IP:
|
IP:
|
||||||
PORT: 54000
|
PORT: 54000
|
||||||
|
71
hblink.py
71
hblink.py
@ -370,41 +370,46 @@ class HBSYSTEM(DatagramProtocol):
|
|||||||
|
|
||||||
elif _command == 'RPTL': # RPTLogin -- a repeater wants to login
|
elif _command == 'RPTL': # RPTLogin -- a repeater wants to login
|
||||||
_peer_id = _data[4:8]
|
_peer_id = _data[4:8]
|
||||||
# Check for valid Radio ID
|
# Check to see if we've reached the maximum number of allowed peers
|
||||||
if acl_check(_peer_id, self._CONFIG['GLOBAL']['REG_ACL']) and acl_check(_peer_id, self._config['REG_ACL']):
|
if len(self._peers < self._config['MAX_PEERS']):
|
||||||
# Build the configuration data strcuture for the peer
|
# Check for valid Radio ID
|
||||||
self._peers.update({_peer_id: {
|
if acl_check(_peer_id, self._CONFIG['GLOBAL']['REG_ACL']) and acl_check(_peer_id, self._config['REG_ACL']):
|
||||||
'CONNECTION': 'RPTL-RECEIVED',
|
# Build the configuration data strcuture for the peer
|
||||||
'PINGS_RECEIVED': 0,
|
self._peers.update({_peer_id: {
|
||||||
'LAST_PING': time(),
|
'CONNECTION': 'RPTL-RECEIVED',
|
||||||
'SOCKADDR': _sockaddr,
|
'PINGS_RECEIVED': 0,
|
||||||
'IP': _sockaddr[0],
|
'LAST_PING': time(),
|
||||||
'PORT': _sockaddr[1],
|
'SOCKADDR': _sockaddr,
|
||||||
'SALT': randint(0,0xFFFFFFFF),
|
'IP': _sockaddr[0],
|
||||||
'RADIO_ID': str(int(ahex(_peer_id), 16)),
|
'PORT': _sockaddr[1],
|
||||||
'CALLSIGN': '',
|
'SALT': randint(0,0xFFFFFFFF),
|
||||||
'RX_FREQ': '',
|
'RADIO_ID': str(int(ahex(_peer_id), 16)),
|
||||||
'TX_FREQ': '',
|
'CALLSIGN': '',
|
||||||
'TX_POWER': '',
|
'RX_FREQ': '',
|
||||||
'COLORCODE': '',
|
'TX_FREQ': '',
|
||||||
'LATITUDE': '',
|
'TX_POWER': '',
|
||||||
'LONGITUDE': '',
|
'COLORCODE': '',
|
||||||
'HEIGHT': '',
|
'LATITUDE': '',
|
||||||
'LOCATION': '',
|
'LONGITUDE': '',
|
||||||
'DESCRIPTION': '',
|
'HEIGHT': '',
|
||||||
'SLOTS': '',
|
'LOCATION': '',
|
||||||
'URL': '',
|
'DESCRIPTION': '',
|
||||||
'SOFTWARE_ID': '',
|
'SLOTS': '',
|
||||||
'PACKAGE_ID': '',
|
'URL': '',
|
||||||
}})
|
'SOFTWARE_ID': '',
|
||||||
logger.info('(%s) Repeater Logging in with Radio ID: %s, %s:%s', self._system, int_id(_peer_id), _sockaddr[0], _sockaddr[1])
|
'PACKAGE_ID': '',
|
||||||
_salt_str = hex_str_4(self._peers[_peer_id]['SALT'])
|
}})
|
||||||
self.send_peer(_peer_id, 'RPTACK'+_salt_str)
|
logger.info('(%s) Repeater Logging in with Radio ID: %s, %s:%s', self._system, int_id(_peer_id), _sockaddr[0], _sockaddr[1])
|
||||||
self._peers[_peer_id]['CONNECTION'] = 'CHALLENGE_SENT'
|
_salt_str = hex_str_4(self._peers[_peer_id]['SALT'])
|
||||||
logger.info('(%s) Sent Challenge Response to %s for login: %s', self._system, int_id(_peer_id), self._peers[_peer_id]['SALT'])
|
self.send_peer(_peer_id, 'RPTACK'+_salt_str)
|
||||||
|
self._peers[_peer_id]['CONNECTION'] = 'CHALLENGE_SENT'
|
||||||
|
logger.info('(%s) Sent Challenge Response to %s for login: %s', self._system, int_id(_peer_id), self._peers[_peer_id]['SALT'])
|
||||||
|
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:
|
else:
|
||||||
self.transport.write('MSTNAK'+_peer_id, _sockaddr)
|
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))
|
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
|
elif _command == 'RPTK': # Repeater has answered our login challenge
|
||||||
_peer_id = _data[4:8]
|
_peer_id = _data[4:8]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user