(self, active_frontends)
Find the Sat-IP frontend serving this client

        Args:
            active_frontends (list): List of active frontends.
Find the Sat-IP frontend serving this client
Find the Sat - IP frontend serving this client
def _find_serving_frontend(self, active_frontends):
        """Find the Sat-IP frontend serving this client

        Args:
            active_frontends (list): List of active frontends.

        """

        # First, select the active frontends with matching DVB-S2 parameters.
        candidate_frontends = []
        for fe in active_frontends:
            try:
                fe_freq = float(fe['fq'])
                fe_pol = fe['pol']
            except ValueError:
                continue

            if fe_freq == self.params['freq'] and fe_pol == self.params['pol']:
                candidate_frontends.append(fe)

        # If there is only one matching frontend, it's got to be ours.
        if len(candidate_frontends) == 1:
            self.serving_fe = candidate_frontends[0]['name']
            return

        # If there isn't any candidate frontend at this point, warn the user.
        # There should be at least one matching frontend.
        if len(candidate_frontends) == 0:
            logger.warning(
                "Could not find a frontend with matching parameters")
            return

        # If there are multiple matching frontends (due to multiple clients),
        # try to select those serving the local IP address. However, note this
        # filtering may fail if the local address lies behind a NAT (e.g., a VM
        # behind a host NAT). In this case, the frontend client IP will be set
        # to the NAT address, not the local (translated) address.
        #
        # If none of the candidate frontends are serving the local address,
        # warn the user and skip this step, assuming it's the NAT case.
        if len(candidate_frontends) > 1:
            any_fe_serving_local_addr = any(
                [fe['ip'] == self.local_addr for fe in candidate_frontends])
            if any_fe_serving_local_addr:
                for fe in candidate_frontends.copy():
                    if fe['ip'] != self.local_addr:
                        candidate_frontends.remove(fe)
            else:
                logger.warning(
                    "Could not find a frontend serving the local {} address - "
                    "logging the status of {}".format(
                        self.local_addr, candidate_frontends[-1]['name']))

        # In the end, despite the filtering, multiple candidate frontends could
        # remain. For example, in the NAT case mentioned above, where the IP
        # filtering is skipped. Alternatively, in case the same host is running
        # multiple clients. There is no protocol-level solution to detect which
        # client is which. The only workaround is to guess the frontend number
        # by inspecting the pre-existing active frontends before launching the
        # client. However, this is still a TODO. For now, pick the last
        # frontend from the list (possibly the most recent), and warn the user.
        self.serving_fe = candidate_frontends[-1]['name']
        n_candidate = len(candidate_frontends)
        if n_candidate > 1:
            logger.warning(
                "The status logs can be unreliable when streaming from "
                "multiple frontends concurrently (found {} frontends, "
                "listening to {})".format(n_candidate, self.serving_fe))
def _find_serving_frontend ( self , active_frontends ) : # First, select the active frontends with matching DVB-S2 parameters. candidate_frontends = [ ] for fe in active_frontends : try : fe_freq = float ( fe [ 'fq' ] ) fe_pol = fe [ 'pol' ] except ValueError : continue if fe_freq == self . params [ 'freq' ] and fe_pol == self . params [ 'pol' ] : candidate_frontends . append ( fe ) # If there is only one matching frontend, it's got to be ours. if len ( candidate_frontends ) == 1 : self . serving_fe = candidate_frontends [ 0 ] [ 'name' ] return # If there isn't any candidate frontend at this point, warn the user. # There should be at least one matching frontend. if len ( candidate_frontends ) == 0 : logger . warning ( "Could not find a frontend with matching parameters" ) return # If there are multiple matching frontends (due to multiple clients), # try to select those serving the local IP address. However, note this # filtering may fail if the local address lies behind a NAT (e.g., a VM # behind a host NAT). In this case, the frontend client IP will be set # to the NAT address, not the local (translated) address. # # If none of the candidate frontends are serving the local address, # warn the user and skip this step, assuming it's the NAT case. if len ( candidate_frontends ) > 1 : any_fe_serving_local_addr = any ( [ fe [ 'ip' ] == self . local_addr for fe in candidate_frontends ] ) if any_fe_serving_local_addr : for fe in candidate_frontends . copy ( ) : if fe [ 'ip' ] != self . local_addr : candidate_frontends . remove ( fe ) else : logger . warning ( "Could not find a frontend serving the local {} address - " "logging the status of {}" . format ( self . local_addr , candidate_frontends [ - 1 ] [ 'name' ] ) ) # In the end, despite the filtering, multiple candidate frontends could # remain. For example, in the NAT case mentioned above, where the IP # filtering is skipped. Alternatively, in case the same host is running # multiple clients. There is no protocol-level solution to detect which # client is which. The only workaround is to guess the frontend number # by inspecting the pre-existing active frontends before launching the # client. However, this is still a TODO. For now, pick the last # frontend from the list (possibly the most recent), and warn the user. self . serving_fe = candidate_frontends [ - 1 ] [ 'name' ] n_candidate = len ( candidate_frontends ) if n_candidate > 1 : logger . warning ( "The status logs can be unreliable when streaming from " "multiple frontends concurrently (found {} frontends, " "listening to {})" . format ( n_candidate , self . serving_fe ) )