Dynamic IP update:

Using BCKA (Extended OBP KeepAlives):

When an authenticated keepalive is received from a different IP but
on the same port, we update the IP for the OpenBridge. This means, we can
handle dynamic IP seamlessly!
This commit is contained in:
Simon 2021-04-04 18:39:16 +01:00
parent dda0470ff2
commit 53c1958aec
2 changed files with 12 additions and 4 deletions

View File

@ -302,7 +302,7 @@ def build_config(_config_file):
'SUB_ACL': config.get(section, 'SUB_ACL'),
'TG1_ACL': config.get(section, 'TGID_ACL'),
'TG2_ACL': 'PERMIT:ALL',
'RELAX_CHECKS': config.getboolean(section, 'RELAX_CHECKS')
'RELAX_CHECKS': config.getboolean(section, 'RELAX_CHECKS'),
'ENHANCED_OBP': config.getboolean(section, 'ENHANCED_OBP')
}})

View File

@ -213,12 +213,20 @@ class OPENBRIDGE(DatagramProtocol):
_hash = _packet[4:]
_ckhs = hmac_new(self._config['PASSPHRASE'],_packet[:4],sha1).digest()
if compare_digest(_hash, _ckhs):
logger.debug('(%s) Bridge Control Keep Alive received',self._system)
logger.debug('(%s) *BridgeControl* Keep Alive received',self._system)
self._config['_bcka'] = time()
if _sockaddr != self._config['TARGET_SOCK']:
h,p = _sockaddr
if p == self._config['TARGET_PORT']:
self._config['TARGET_SOCK'] = _sockaddr
self.config['TARGET_IP'] = h
logger.info('(%s) *BridgeControl* Source IP has changed for OBP, updating',self._system)
else:
logger.info('(%s) *BridgeControl* Source IP has changed for OBP but port has also changed, *NOT* updating',self._system)
else:
h,p = _sockaddr
logger.info('(%s) OpenBridge BCKA invalid KeepAlive, packet discarded - OPCODE: %s DATA: %s HMAC LENGTH: %s HMAC: %s SRC IP: %s SRC PORT: %s', self._system, _packet[:4], repr(_packet[:53]), len(_packet[53:]), repr(_packet[53:]),h,p)
logger.info('(%s) *BridgeControl* BCKA invalid KeepAlive, packet discarded - OPCODE: %s DATA: %s HMAC LENGTH: %s HMAC: %s SRC IP: %s SRC PORT: %s', self._system, _packet[:4], repr(_packet[:53]), len(_packet[53:]), repr(_packet[53:]),h,p)
#************************************************