(self)
Find out which local address communicates with the Sat-IP server
Find out which local address communicates with the Sat-IP server
Find out which local address communicates with the Sat - IP server
def set_local_addr(self):
        """Find out which local address communicates with the Sat-IP server"""
        try:
            res = subprocess.check_output(['ip', 'route', 'get', self.host])
        except subprocess.CalledProcessError as e:
            logger.warning("Failed to read the local Sat-IP client address")
            logger.warning(e)
            return

        out_line = res.decode().splitlines()[0].split()
        if (out_line[1] == "via" and len(out_line) > 6):
            local_addr = out_line[6]
        elif (len(out_line) > 4):
            local_addr = out_line[4]
        else:
            logger.warning("Failed to read the local Sat-IP client address")
            return

        try:
            ip_address(local_addr)
        except ValueError as e:
            logger.warning("Failed to parse the local Sat-IP client address")
            logger.warning(e)
            return
        logger.debug("Local Sat-IP client address: {}".format(local_addr))
        self.local_addr = local_addr
def set_local_addr ( self ) : try : res = subprocess . check_output ( [ 'ip' , 'route' , 'get' , self . host ] ) except subprocess . CalledProcessError as e : logger . warning ( "Failed to read the local Sat-IP client address" ) logger . warning ( e ) return out_line = res . decode ( ) . splitlines ( ) [ 0 ] . split ( ) if ( out_line [ 1 ] == "via" and len ( out_line ) > 6 ) : local_addr = out_line [ 6 ] elif ( len ( out_line ) > 4 ) : local_addr = out_line [ 4 ] else : logger . warning ( "Failed to read the local Sat-IP client address" ) return try : ip_address ( local_addr ) except ValueError as e : logger . warning ( "Failed to parse the local Sat-IP client address" ) logger . warning ( e ) return logger . debug ( "Local Sat-IP client address: {}" . format ( local_addr ) ) self . local_addr = local_addr