Ejemplo n.º 1
0
def queue_normal(db):
    """ Прогоняем все домены резолвером """
    qdns_configured = False
    current_time = CURRENT_UNIXTIME()
    logging.info('queue outdated domains')
    db.queued_count = 0
    for domain, entry in db.data.items():
        if domain not in DOMAINS:
            continue
        if not is_out_date(entry, current_time):
            continue
        if not qdns_configured:
            logging.info('qdns.configure')
            cpu_count = int(os.environ.get('QDNS_THREADS', 4))
            qdns.configure(new_thread_count=cpu_count,
                           carbon=True,
                           __ipv6_support=CONFIG['IPV6_SUPPORT'])
            qdns_configured = True
        db.queued_count += 1
        logging.info("queued: %s", domain.encode('utf-8'))
        qdns.gethostsbyname(domain, db.receive)
        DOMAINS_QUEUED.append(domain)
        # отрицательный RESOLVER_LIMIT == резолвить всё
        if CONFIG['RESOLVER_LIMIT'] < 0:
            continue
        # не резолвим всё, только в пределах лимита, чтобы резолвер не висел долго
        if CONFIG['RESOLVER_LIMIT'] <= db.queued_count:
            logging.info('check only first %d domains',
                         CONFIG['RESOLVER_LIMIT'])
            break
    db.queued_count_total = int(db.queued_count)
    logging.info("total queued: %d", db.queued_count_total)
    if qdns_configured:
        qdns.stop(True)
        logging.info('qdns stopped')
Ejemplo n.º 2
0
 def test_gethostbyname_v6(self):
     qdns.configure()
     qdns.gethostbyname('::1', self._receive)
     qdns.stop(True)
     self.assertEquals('::1', self.received[0])
Ejemplo n.º 3
0
 def test_getaddrinfo_v6(self):
     qdns.configure()
     qdns.getaddrinfo('::1', self._receive)
     qdns.stop(True)
     self.assertEquals('::1', self.received[0][0][4][0])
Ejemplo n.º 4
0
 def test_gethostbyname_host(self):
     qdns.configure()
     qdns.gethostbyname('python.org', self._receive)
     qdns.stop(True)
     self.assertEquals('82.94.164.162', self.received[0])
Ejemplo n.º 5
0
 def test_gethostbyname_ex_v4(self):
     qdns.configure()
     qdns.gethostbyname_ex('1.2.3.4', self._receive)
     qdns.stop(True)
     self.assertEquals('1.2.3.4', self.received[0][2][0])
Ejemplo n.º 6
0
 def test_getaddrinfo_host(self):
     qdns.configure()
     qdns.getaddrinfo('python.org', self._receive)
     qdns.stop(True)
     self.assertEquals('82.94.164.162', self.received[0][0][4][0])
Ejemplo n.º 7
0
 def test_gethostbyname_ex_host(self):
     qdns.configure()
     qdns.gethostbyname_ex('python.org', self._receive)
     qdns.stop(True)
     self.assertEquals('82.94.164.162', self.received[0][2][0])
Ejemplo n.º 8
0
 def test_gethostbyname_v6(self):
     qdns.configure()
     qdns.gethostbyname('::1', self._receive)
     qdns.stop(True)
     self.assertEquals('::1', self.received[0])
Ejemplo n.º 9
0
 def test_getaddrinfo_v6(self):
     qdns.configure()
     qdns.getaddrinfo('::1', self._receive)
     qdns.stop(True)
     self.assertEquals('::1', self.received[0][0][4][0])
Ejemplo n.º 10
0
 def test_getaddrinfo_host(self):
     qdns.configure()
     qdns.getaddrinfo('python.org', self._receive)
     qdns.stop(True)
     self.assertEquals('82.94.164.162', self.received[0][0][4][0])
Ejemplo n.º 11
0
 def test_gethostbyname_ex_v4(self):
     qdns.configure()
     qdns.gethostbyname_ex('1.2.3.4', self._receive)
     qdns.stop(True)
     self.assertEquals('1.2.3.4', self.received[0][2][0])