Пример #1
0
    def _request_queue(self):
        return_ready = self.REQ_TRACKER.return_ready

        while True:

            # this blocks until request tracker returns (at least 1 client query has been inspected)
            requests = return_ready()

            for client_query, decision in requests:
                if decision is DNS.ALLOWED and not self._cached_response(
                        client_query):
                    self._handle_query(client_query)

                Log.informational(
                    f'{self.protocol.name} Relay ALLOWED | {client_query}')  # pylint: disable=no-member
Пример #2
0
    def _wait_for_proxy_decision(self, client_query):
        # waiting for proxy decision. if iteration completes normally, it will be marked as a timeout.
        # NOTE: TESTING | after each check a msec will get added to the interval.
        for interval in [x / 1000
                         for x in range(DNS.WAIT_COUNT)]:  # converting to msec
            decision = self._req_results_pop(client_query.address,
                                             DNS.NO_NOTICE)
            if (decision is DNS.FLAGGED): return
            if (decision is DNS.ALLOWED): break

            sleep(interval)
        else:
            return

        Log.informational(
            f'{self.protocol.name} Relay ALLOWED | {client_query}')  # pylint: disable=no-member
        if not self._cached_response(client_query):
            self._handle_query(client_query)