Exemple #1
0
    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.get_ip_to_scan()

                if ip in self.ip_dict:
                    continue

                connect_control.start_connect_register()
                result = check_ip.test_gae_ip2(ip)
                connect_control.end_connect_register()
                if not result or not result.support_gae:
                    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()
Exemple #2
0
    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

            connect_control.start_connect_register()
            result = check_ip.test_gae_ip2(ip)
            connect_control.end_connect_register()
            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()
            elif result.support_gae:
                self.add_ip(ip, result.handshake_time, result.domain, "gws")
            else:
                self.report_connect_fail(ip, force_remove=True)
Exemple #3
0
    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_ip2(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.bad_ip_num += 1
                    self.ip_dict[ip]['fail_times'] += 1
                    self.ip_dict[ip]["fail_time"] = time.time()
                finally:
                    self.ip_lock.release()
            elif result.support_gae:
                self.add_ip(ip, result.handshake_time, result.domain, "gws")
            else:
                self.report_connect_fail(ip, force_remove=True)
Exemple #4
0
    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 not check_local_network.is_ok():
                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_ip2(ip)
            if result and result.support_gae:
                self.add_ip(ip, result.handshake_time, result.domain, "gws")
                xlog.debug("restore ip:%s", ip)
                continue

            xlog.debug("ip:%s real fail", ip)
Exemple #5
0
    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 not check_local_network.is_ok():
                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_ip2(ip)
            if result and result.support_gae:
                self.add_ip(ip, result.handshake_time, result.domain, "gws")
                xlog.debug("restore ip:%s", ip)
                continue

            xlog.debug("ip:%s real fail", ip)
Exemple #6
0
    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_ip2(ip)
                if not result or not result.support_gae:
                    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)
                    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()
Exemple #7
0
    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_ip2(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")
Exemple #8
0
 def process_appid_not_exist(self, appid, ip):
     if check_ip.test_gae_ip2(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)
Exemple #9
0
 def process_appid_not_exist(self, appid, ip):
     if check_ip.test_gae_ip2(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)
Exemple #10
0
    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 = google_ip_range.ip_range.get_ip()

                if ip in self.ip_dict:
                    continue

                result = check_ip.test_gae_ip2(ip)
                if not result or not result.support_gae:
                    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)
                    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()
Exemple #11
0
    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_ip2(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)
Exemple #12
0
    def recheck_ip(self, ip):
        # recheck ip if not work.
        # can block.
        if not check_local_network.is_ok():
            xlog.debug("recheck_ip:%s network is fail", ip)
            return

        self.report_connect_fail(ip)

        connect_control.start_connect_register()
        result = check_ip.test_gae_ip2(ip)
        connect_control.end_connect_register()
        if not result:
            self.report_connect_fail(ip, force_remove=True)
            xlog.debug("recheck_ip:%s real fail, removed.", ip)
        else:
            self.add_ip(ip, result.handshake_time, result.domain, "gws")
            xlog.debug("recheck_ip:%s restore okl", ip)
Exemple #13
0
    def recheck_ip(self, ip):
        # recheck ip if not work.
        # can block.
        if not check_local_network.is_ok():
            xlog.debug("recheck_ip:%s network is fail", ip)
            return

        self.report_connect_fail(ip)

        result = check_ip.test_gae_ip2(ip)
        if not result:
            # connect fail.
            # do nothing
            return

        if not result.support_gae:
            self.report_connect_fail(ip, force_remove=True)
            xlog.debug("recheck_ip:%s real fail, removed.", ip)
        else:
            self.add_ip(ip, result.handshake_time, result.domain, "gws")
            xlog.debug("recheck_ip:%s restore okl", ip)