def dig_ip_worker(self): try: for ip in self.dig_ips: if ip in self.dig_ipdict or ip in self.dig_finishedip: continue self.dig_ipdict.append(ip) if not check_ip_valid(ip): print('ip: %s is invalid, reset to default ip: %s' % (ip, default_ip)) ip = default_ip print('\ndig ip: %s' % ip) cmd = ['1', '+subnet=%s/32' % ip, '@ns1.google.com', 'www.google.com'] code = pydig(cmd) self.dig_lock.acquire() if code == 502: open(dig_error, "a").write(ip + "\n") else: open(dig_finished, "a").write(ip + "\n") self.dig_lock.release() except: pass finally: self.dig_lock.acquire() print 'dig_ip_worker exit' self.dig_thread_num -= 1 self.dig_lock.release()
def dig_ip(ip): if not check_ip_valid(ip): print('ip: %s is invalid, reset to default ip: %s' % (ip, default_ip)) ip = default_ip print('\ndig ip: %s' % ip) cmd = ['1', '+subnet=%s/32' % ip, '@ns1.google.com', 'www.google.com'] code = pydig(cmd) if code == 502: open(dig_error, "a").write(ip + "\n") else: open(dig_finished, "a").write(ip + "\n")