def __init__(self): self.running = True self.logger = logger self.config = config self.host_manager = host_manager.HostManager(self.config, logger) ca_certs = os.path.join(current_path, "cacert.pem") self.openssl_context = SSLContext( logger, ca_certs=ca_certs, support_http2=config.support_http2, cipher_suites=[ 'ALL', "!RC4-SHA", "!ECDHE-RSA-RC4-SHA", "!ECDHE-RSA-AES128-GCM-SHA256", "!AES128-GCM-SHA256", "!ECDHE-RSA-AES128-SHA", "!AES128-SHA" ]) self.connect_creator = ConnectCreator(logger, self.config, self.openssl_context, self.host_manager) self.appid_manager = AppidManager(self.config, logger) self.host_manager.appid_manager = self.appid_manager self.ip_checker = CheckIp(xlog.null, self.config, self.connect_creator) self.ipv4_source = Ipv4RangeSource( logger, self.config, os.path.join(current_path, "ip_range.txt"), os.path.join(module_data_path, "ip_range.txt")) self.ipv6_source = Ipv6PoolSource( logger, self.config, os.path.join(current_path, "ipv6_list.txt")) self.ip_source = IpCombineSource(logger, self.config, self.ipv4_source, self.ipv6_source) self.ip_manager = IpManager(logger, self.config, self.ip_source, check_local_network, self.check_ip, None, os.path.join(module_data_path, "good_ip.txt"), scan_ip_log=None) self.appid_manager.check_api = self.ip_checker.check_ip self.appid_manager.ip_manager = self.ip_manager self.connect_manager = ConnectManager(logger, self.config, self.connect_creator, self.ip_manager, check_local_network) self.http_dispatcher = HttpsDispatcher(logger, self.config, self.ip_manager, self.connect_manager)
def start(self): self.running = True ca_certs = os.path.join(current_path, "cacert.pem") self.openssl_context = SSLContext( logger, ca_certs=ca_certs, support_http2=config.support_http2, cipher_suites=['ALL', "!RC4-SHA","!ECDHE-RSA-RC4-SHA", "!ECDHE-RSA-AES128-GCM-SHA256", "!AES128-GCM-SHA256", "!ECDHE-RSA-AES128-SHA", "!AES128-SHA"] ) self.appid_manager = AppidManager(self.config, logger) self.host_manager = host_manager.HostManager(self.config, logger) self.host_manager.appid_manager = self.appid_manager self.connect_creator = ConnectCreator( logger, self.config, self.openssl_context, self.host_manager) self.ip_checker = CheckIp(xlog.null, self.config, self.connect_creator) self.ipv4_source = Ipv4RangeSource( logger, self.config, os.path.join(current_path, "ip_range.txt"), os.path.join(module_data_path, "ip_range.txt") ) self.ipv6_source = Ipv6PoolSource( logger, self.config, os.path.join(current_path, "ipv6_list.txt") ) self.ip_source = IpCombineSource( logger, self.config, self.ipv4_source, self.ipv6_source ) self.ip_manager = IpManager( logger, self.config, self.ip_source, check_local_network, self.check_ip, None, os.path.join(module_data_path, "good_ip.txt"), scan_ip_log=None) self.appid_manager.check_api = self.ip_checker.check_ip self.appid_manager.ip_manager = self.ip_manager self.connect_manager = ConnectManager( logger, self.config, self.connect_creator, self.ip_manager, check_local_network) self.http_dispatcher = HttpsDispatcher( logger, self.config, self.ip_manager, self.connect_manager )
class Front(object): name = "gae_front" def __init__(self): self.logger = logger self.config = config def start(self): self.running = True ca_certs = os.path.join(current_path, "cacert.pem") self.openssl_context = SSLContext( logger, ca_certs=ca_certs, support_http2=config.support_http2, cipher_suites=[ 'ALL', "!RC4-SHA", "!ECDHE-RSA-RC4-SHA", "!ECDHE-RSA-AES128-GCM-SHA256", "!AES128-GCM-SHA256", "!ECDHE-RSA-AES128-SHA", "!AES128-SHA" ]) self.appid_manager = AppidManager(self.config, logger) self.host_manager = host_manager.HostManager(self.config, logger) self.host_manager.appid_manager = self.appid_manager self.connect_creator = ConnectCreator(logger, self.config, self.openssl_context, self.host_manager) self.ip_checker = CheckIp(xlog.null, self.config, self.connect_creator) self.ipv4_source = Ipv4RangeSource( logger, self.config, os.path.join(current_path, "ip_range.txt"), os.path.join(module_data_path, "ip_range.txt")) self.ipv6_source = Ipv6PoolSource( logger, self.config, os.path.join(current_path, "ipv6_list.txt")) self.ip_source = IpCombineSource(logger, self.config, self.ipv4_source, self.ipv6_source) self.ip_manager = IpManager(logger, self.config, self.ip_source, check_local_network, self.check_ip, None, os.path.join(module_data_path, "good_ip.txt"), scan_ip_log=None) self.appid_manager.check_api = self.ip_checker.check_ip self.appid_manager.ip_manager = self.ip_manager self.connect_manager = ConnectManager(logger, self.config, self.connect_creator, self.ip_manager, check_local_network) self.http_dispatcher = HttpsDispatcher(logger, self.config, self.ip_manager, self.connect_manager) def check_ip(self, ip): sni = self.host_manager.sni_manager.get() host = "xxnet-1.appspot.com" return self.ip_checker.check_ip(ip, sni=sni, host=host) def get_dispatcher(self): return self.http_dispatcher def request(self, method, host, path="/", headers={}, data="", timeout=120): response = self.http_dispatcher.request(method, host, path, dict(headers), data, timeout=timeout) return response def stop(self): logger.info("terminate") self.connect_manager.set_ssl_created_cb(None) self.http_dispatcher.stop() self.connect_manager.stop() self.ip_manager.stop() self.running = False def set_proxy(self, args): logger.info("set_proxy:%s", args) self.config.PROXY_ENABLE = args["enable"] self.config.PROXY_TYPE = args["type"] self.config.PROXY_HOST = args["host"] self.config.PROXY_PORT = args["port"] self.config.PROXY_USER = args["user"] self.config.PROXY_PASSWD = args["passwd"] self.config.save() self.connect_creator.update_config()
class Front(object): name = "gae_front" def __init__(self): self.logger = logger self.config = config def start(self): self.running = True ca_certs = os.path.join(current_path, "cacert.pem") self.openssl_context = SSLContext( logger, ca_certs=ca_certs, support_http2=config.support_http2, cipher_suites=['ALL', "!RC4-SHA","!ECDHE-RSA-RC4-SHA", "!ECDHE-RSA-AES128-GCM-SHA256", "!AES128-GCM-SHA256", "!ECDHE-RSA-AES128-SHA", "!AES128-SHA"] ) self.appid_manager = AppidManager(self.config, logger) self.host_manager = host_manager.HostManager(self.config, logger) self.host_manager.appid_manager = self.appid_manager self.connect_creator = ConnectCreator( logger, self.config, self.openssl_context, self.host_manager) self.ip_checker = CheckIp(xlog.null, self.config, self.connect_creator) self.ipv4_source = Ipv4RangeSource( logger, self.config, os.path.join(current_path, "ip_range.txt"), os.path.join(module_data_path, "ip_range.txt") ) self.ipv6_source = Ipv6PoolSource( logger, self.config, os.path.join(current_path, "ipv6_list.txt") ) self.ip_source = IpCombineSource( logger, self.config, self.ipv4_source, self.ipv6_source ) self.ip_manager = IpManager( logger, self.config, self.ip_source, check_local_network, self.check_ip, None, os.path.join(module_data_path, "good_ip.txt"), scan_ip_log=None) self.appid_manager.check_api = self.ip_checker.check_ip self.appid_manager.ip_manager = self.ip_manager self.connect_manager = ConnectManager( logger, self.config, self.connect_creator, self.ip_manager, check_local_network) self.http_dispatcher = HttpsDispatcher( logger, self.config, self.ip_manager, self.connect_manager ) def check_ip(self, ip): sni = self.host_manager.sni_manager.get() host = "xxnet-1.appspot.com" return self.ip_checker.check_ip(ip, sni=sni, host=host) def get_dispatcher(self): return self.http_dispatcher def request(self, method, host, path="/", headers={}, data="", timeout=120): response = self.http_dispatcher.request(method, host, path, dict(headers), data, timeout=timeout) return response def stop(self): logger.info("terminate") self.connect_manager.set_ssl_created_cb(None) self.http_dispatcher.stop() self.connect_manager.stop() self.ip_manager.stop() self.running = False def set_proxy(self, args): logger.info("set_proxy:%s", args) self.config.PROXY_ENABLE = args["enable"] self.config.PROXY_TYPE = args["type"] self.config.PROXY_HOST = args["host"] self.config.PROXY_PORT = args["port"] self.config.PROXY_USER = args["user"] self.config.PROXY_PASSWD = args["passwd"] self.config.save() self.connect_creator.update_config()