def _create_ssl_connection(self, ip_port): if not connect_control.allow_connect(): time.sleep(10) return False ip = ip_port[0] port = ip_port[1] connect_control.start_connect_register(high_prior=True) time_begin = time.time() try: ssl_sock = check_ip.connect_ssl(ip, port=port, timeout=self.connect_timeout, on_close=ip_manager.ssl_closed) xlog.debug("create_ssl update ip:%s time:%d h2:%d sni:%s top:%s", ip, ssl_sock.handshake_time, ssl_sock.h2, ssl_sock.sni, ssl_sock.top_domain) ssl_sock.last_use_time = ssl_sock.create_time ssl_sock.received_size = 0 ssl_sock.load = 0 ssl_sock.host = self.sub + "." + ssl_sock.top_domain connect_control.report_connect_success() return ssl_sock except Exception as e: time_cost = time.time() - time_begin if time_cost < self.connect_timeout - 1: xlog.debug("connect %s fail:%s cost:%d ", ip, e, time_cost * 1000) else: xlog.debug("%s fail:%r", ip, e) ip_manager.report_connect_fail(ip) connect_control.report_connect_fail() return False finally: connect_control.end_connect_register(high_prior=True)
def test_appid(self, appid): for ip in self.ip_dict: try: ssl_sock = check_ip.connect_ssl(ip) except: continue try: check_ip.check_appid(ssl_sock, appid) return True except: return False return False
def test_appid(self, appid): for ip in self.ip_dict: try: ssl_sock = check_ip.connect_ssl(ip) except: continue try: return check_ip.check_appid(ssl_sock, appid) except Exception as e: xlog.exception("check_appid %s %r", appid, e) continue return False
def _create_ssl_connection(self, ip_port): if not connect_control.allow_connect(): time.sleep(10) return False sock = None ssl_sock = None ip = ip_port[0] connect_control.start_connect_register(high_prior=True) try: ssl_sock = check_ip.connect_ssl(ip, port=443, timeout=self.timeout, check_cert=True, close_cb=google_ip.ssl_closed) google_ip.update_ip(ip, ssl_sock.handshake_time) xlog.debug("create_ssl update ip:%s time:%d h2:%d", ip, ssl_sock.handshake_time, ssl_sock.h2) connect_control.report_connect_success() return ssl_sock except check_ip.Cert_Exception as e: xlog.debug("connect %s fail:%s ", ip, e) google_ip.report_connect_fail(ip, force_remove=True) if ssl_sock: ssl_sock.close() if sock: sock.close() except Exception as e: xlog.debug("connect %s fail:%r", ip, e) google_ip.report_connect_fail(ip) connect_control.report_connect_fail() if not check_local_network.IPv4.is_ok(): time.sleep(10) else: time.sleep(1) if ssl_sock: ssl_sock.close() if sock: sock.close() finally: connect_control.end_connect_register(high_prior=True)