def check_ip_process(self): while connect_control.keep_running: try: ip, test_time = self.to_check_ip_queue.get() except: continue time_wait = test_time - time.time() if time_wait > 0: time.sleep(time_wait) if check_local_network.network_stat == "Fail": try: if self.ip_dict[ip]['fail_times']: self.ip_dict[ip]['fail_times'] = 0 self.good_ip_num += 1 except: pass continue result = check_ip.test_gae_ip(ip) if result: self.add_ip(ip, result.handshake_time, result.domain, "gws") xlog.debug("restore ip:%s", ip) continue xlog.debug("ip:%s real fail", ip)
def scan_ip_worker(self): while self.scan_thread_count <= self.scan_ip_thread_num and connect_control.keep_running: if not connect_control.allow_scan(): time.sleep(10) continue try: time.sleep(1) ip = self.ip_range.get_ip() if ip in self.ip_dict: continue connect_control.start_connect_register() result = check_ip.test_gae_ip(ip) connect_control.end_connect_register() if not result: continue if self.add_ip(ip, result.handshake_time, result.domain, "gws"): #xlog.info("add %s CN:%s type:%s time:%d gws:%d ", ip, # result.domain, result.server_type, result.handshake_time, len(self.gws_ip_list)) xlog.info("scan_ip add ip:%s time:%d", ip, result.handshake_time) scan_ip_log.info("Add %s time:%d CN:%s ", ip, result.handshake_time, result.domain) self.remove_slowest_ip() self.save_ip_list() except Exception as e: xlog.exception("google_ip.runJob fail:%r", e) self.scan_thread_lock.acquire() self.scan_thread_count -= 1 self.scan_thread_lock.release() xlog.info("scan_ip_worker exit")
def process_appid_not_exist(self, appid, ip): if check_ip.test_gae_ip(ip, "xxnet-1"): self.set_appid_not_exist(appid) else: xlog.warn("process_appid_not_exist, remove ip:%s", ip) from google_ip import google_ip google_ip.report_connect_fail(ip, force_remove=True)
def scan_exist_ip_worker(self): while connect_control.keep_running: try: ip_str = self.scan_exist_ip_queue.get_nowait() except: break connect_control.start_connect_register() result = check_ip.test_gae_ip(ip_str) connect_control.end_connect_register() if not result: self.ip_lock.acquire() try: if ip_str not in self.ip_dict: continue if self.ip_dict[ip_str]['fail_times'] == 0: self.good_ip_num -= 1 self.ip_dict[ip_str]['fail_times'] += 1 self.ip_dict[ip_str]["fail_time"] = time.time() finally: self.ip_lock.release() continue self.add_ip(ip_str, result.handshake_time, result.domain, "gws")
def check_ip_process(self): while connect_control.keep_running: try: ip, test_time = self.to_check_ip_queue.get() except: continue time_wait = test_time - time.time() if time_wait > 0: time.sleep(time_wait) if check_local_network.network_stat == "Fail": try: if self.ip_dict[ip]['fail_times']: self.ip_dict[ip]['fail_times'] = 0 self.good_ip_num += 1 self.bad_ip_num -= 1 except: pass continue result = check_ip.test_gae_ip(ip) if result: self.add_ip(ip, result.handshake_time, result.domain, "gws") xlog.debug("restore ip:%s", ip) continue xlog.debug("ip:%s real fail", ip)
def scan_ip_worker(self): while self.scan_thread_count <= self.scan_ip_thread_num and connect_control.keep_running: if not connect_control.allow_scan(): time.sleep(10) continue try: time.sleep(1) ip = self.ip_range.get_ip() if ip in self.ip_dict: continue connect_control.start_connect_register() result = check_ip.test_gae_ip(ip) connect_control.end_connect_register() if not result: continue if self.add_ip(ip, result.handshake_time, result.domain, "gws"): #logging.info("add %s CN:%s type:%s time:%d gws:%d ", ip, # result.domain, result.server_type, result.handshake_time, len(self.gws_ip_list)) xlog.info("scan_ip add ip:%s time:%d", ip, result.handshake_time) scan_ip_log.info("Add %s time:%d CN:%s ", ip, result.handshake_time, result.domain) self.remove_slowest_ip() self.save_ip_list() except Exception as e: xlog.exception("google_ip.runJob fail:%r", e) self.scan_thread_lock.acquire() self.scan_thread_count -= 1 self.scan_thread_lock.release() xlog.info("scan_ip_worker exit")
def scan_ip_worker(self): while self.scan_thread_count <= self.scan_ip_thread_num and connect_control.keep_running: if not connect_control.allow_scan(): time.sleep(10) continue try: time.sleep(1) ip = self.ip_range.get_ip() if ip in self.ip_dict: continue result = check_ip.test_gae_ip(ip) if not result: continue if self.add_ip(ip, result.handshake_time, result.domain, "gws"): #logging.info("add %s CN:%s type:%s time:%d gws:%d ", ip, # result.domain, result.server_type, result.handshake_time, len(self.gws_ip_list)) xlog.info("scan_ip add ip:%s time:%d", ip, result.handshake_time) import re log = scan_ip_log.get_log_content() log_ip = re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}',re.S).findall(log) if ip not in log_ip: scan_ip_log.info("Add %s time:%d CN:%s ", ip, result.handshake_time, result.domain) self.remove_slowest_ip() self.save_ip_list() except Exception as e: xlog.exception("google_ip.runJob fail:%r", e) self.scan_thread_lock.acquire() self.scan_thread_count -= 1 self.scan_thread_lock.release() xlog.info("scan_ip_worker exit")
def req_test_ip_handler(self): req = urlparse.urlparse(self.path).query reqs = urlparse.parse_qs(req, keep_blank_values=True) ip = reqs['ip'][0] result = check_ip.test_gae_ip(ip) if not result: data = "{'res':'fail'}" else: data = json.dumps("{'ip':'%s', 'handshake':'%s', 'server':'%s', 'domain':'%s'}" % (ip, result.handshake_time, result.server_type, result.domain)) self.send_response('text/html', data)
def scan_ip_worker(self): while self.scan_thread_count <= self.scan_ip_thread_num and connect_control.keep_running: if not connect_control.allow_scan(): time.sleep(10) continue try: time.sleep(1) ip = self.ip_range.get_ip() if ip in self.ip_dict: continue result = check_ip.test_gae_ip(ip) if not result: continue if self.add_ip(ip, result.handshake_time, result.domain, "gws"): #logging.info("add %s CN:%s type:%s time:%d gws:%d ", ip, # result.domain, result.server_type, result.handshake_time, len(self.gws_ip_list)) xlog.info("scan_ip add ip:%s time:%d", ip, result.handshake_time) if config.log_scan: import re log = scan_ip_log.get_log_content() log_ip = re.compile( r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', re.S).findall(log) if ip not in log_ip: scan_ip_log.info("Add %s time:%d CN:%s ", ip, result.handshake_time, result.domain) self.remove_slowest_ip() self.save_ip_list() except Exception as e: xlog.exception("google_ip.runJob fail:%r", e) self.scan_thread_lock.acquire() self.scan_thread_count -= 1 self.scan_thread_lock.release() xlog.info("scan_ip_worker exit")
def scan_exist_ip_worker(self): while connect_control.keep_running and self.keep_scan_all_exist_ip: try: ip = self.scan_exist_ip_queue.get_nowait() except: break result = check_ip.test_gae_ip(ip) if not result: self.ip_lock.acquire() try: if ip not in self.ip_dict: continue if self.ip_dict[ip]['fail_times'] == 0: self.good_ip_num -= 1 self.ip_dict[ip]['fail_times'] += 1 self.ip_dict[ip]["fail_time"] = time.time() finally: self.ip_lock.release() else: self.add_ip(ip, result.handshake_time, result.domain, "gws")