From 830c9e171fa0ec70d2cd8882f8c129b08d506390 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 22 Jul 2022 17:17:35 -0400 Subject: [PATCH] Add IP detection on local segment from remote registration If an ip address is missing, but linklocal is set, try to search the local nics for a viable connection to use. --- .../confluent/discovery/handlers/xcc.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/confluent_server/confluent/discovery/handlers/xcc.py b/confluent_server/confluent/discovery/handlers/xcc.py index ded39b21..7850f63b 100644 --- a/confluent_server/confluent/discovery/handlers/xcc.py +++ b/confluent_server/confluent/discovery/handlers/xcc.py @@ -59,6 +59,24 @@ class NodeHandler(immhandler.NodeHandler): @property def ipaddr(self): + if not self._ipaddr: + lla = self.info.get('linklocal', '') + tmplla = None + if lla: + for idx in util.list_interface_indexes(): + tmplla = '{0}%{1}'.format(lla, idx) + addr = socket.getaddrinfo(tmplla, 443, 0, socket.SOCK_STREAM)[0][4] + try: + tsock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) + tsock.settimeout(1) + tsock.connect(addr) + tsock.close() + break + except Exception: + continue + else: + return '' + return tmplla return self._ipaddr if self._ipaddr else '' @classmethod