def main(args): global ready, proxy_server check_create_data_path() log_info() CertUtil.init_ca() allow_remote = args.get("allow_remote", 0) listen_ips = front.config.listen_ip if isinstance(listen_ips, basestring): listen_ips = [listen_ips] else: listen_ips = list(listen_ips) if allow_remote and ("0.0.0.0" not in listen_ips or "::" not in listen_ips): listen_ips.append("0.0.0.0") addresses = [(listen_ip, front.config.listen_port) for listen_ip in listen_ips] front.start() direct_front.start() proxy_server = simple_http_server.HTTPServer(addresses, proxy_handler.GAEProxyHandler, logger=xlog) ready = True # checked by launcher.module_init proxy_server.serve_forever()
def main(): global ready connect_control.keep_running = True config.load() connect_manager.https_manager.load_config() xlog.debug("## GAEProxy set keep_running: %s", connect_control.keep_running) # to profile gae_proxy, run proxy.py, visit some web by proxy, then visit http://127.0.0.1:8084/quit to quit and print result. do_profile = False if do_profile: import cProfile, pstats pr = cProfile.Profile() pr.enable() global __file__ __file__ = os.path.abspath(__file__) if os.path.islink(__file__): __file__ = getattr(os, 'readlink', lambda x: x)(__file__) os.chdir(os.path.dirname(os.path.abspath(__file__))) #xlog.basicConfig(level=xlog.DEBUG if config.LISTEN_DEBUGINFO else xlog.INFO, format='%(levelname)s - %(asctime)s %(message)s', datefmt='[%b %d %H:%M:%S]') pre_start() log_info() CertUtil.init_ca() proxy_daemon = simple_http_server.HTTPServer( (config.LISTEN_IP, config.LISTEN_PORT), proxy_handler.GAEProxyHandler) proxy_thread = threading.Thread(target=proxy_daemon.serve_forever) proxy_thread.setDaemon(True) proxy_thread.start() if config.PAC_ENABLE: pac_daemon = simple_http_server.HTTPServer( (config.PAC_IP, config.PAC_PORT), pac_server.PACServerHandler) pac_thread = threading.Thread(target=pac_daemon.serve_forever) pac_thread.setDaemon(True) pac_thread.start() ready = True # checked by launcher.module_init while connect_control.keep_running: time.sleep(1) xlog.info("Exiting gae_proxy module...") proxy_daemon.shutdown() proxy_daemon.server_close() proxy_thread.join() if config.PAC_ENABLE: pac_daemon.shutdown() pac_daemon.server_close() pac_thread.join() ready = False # checked by launcher.module_init xlog.debug("## GAEProxy set keep_running: %s", connect_control.keep_running) if do_profile: pr.disable() pr.print_stats()
def main(args): global ready, proxy_server check_create_data_path() log_info() CertUtil.init_ca() allow_remote = args.get("allow_remote", 0) if allow_remote: listen_ip = "0.0.0.0" else: listen_ip = front.config.listen_ip front.start() direct_front.start() proxy_server = simple_http_server.HTTPServer( (listen_ip, front.config.listen_port), proxy_handler.GAEProxyHandler, logger=xlog) ready = True # checked by launcher.module_init proxy_server.serve_forever()
def main(args): global ready, proxy_server check_create_data_path() log_info() CertUtil.init_ca() allow_remote = args.get("allow_remote", 0) listen_ips = front.config.listen_ip if isinstance(listen_ips, basestring): listen_ips = [listen_ips] else: listen_ips = list(listen_ips) if allow_remote and ("0.0.0.0" not in listen_ips or "::" not in listen_ips): listen_ips.append("0.0.0.0") addresses = [(listen_ip, front.config.listen_port) for listen_ip in listen_ips] front.start() direct_front.start() proxy_server = simple_http_server.HTTPServer( addresses, proxy_handler.GAEProxyHandler, logger=xlog) ready = True # checked by launcher.module_init proxy_server.serve_forever()
def main(): pre_start() connect_control.keep_running = True connect_manager.https_manager.load_config() xlog.debug("## GAEProxy set keep_running: %s", connect_control.keep_running) CertUtil.init_ca() proxy_daemon = simple_http_server.HTTPServer((config.LISTEN_IP, config.LISTEN_PORT), proxy_handler.GAEProxyHandler) proxy_thread = threading.Thread(target=proxy_daemon.serve_forever) proxy_thread.setDaemon(True) proxy_thread.start() if config.PAC_ENABLE: pac_daemon = simple_http_server.HTTPServer((config.PAC_IP, config.PAC_PORT), PACServerHandler) pac_thread = threading.Thread(target=pac_daemon.serve_forever) pac_thread.setDaemon(True) pac_thread.start() try: urllib2.urlopen('http://127.0.0.1:%d/%s' % (config.PAC_PORT, config.PAC_FILE)) except: pass while connect_control.keep_running: time.sleep(1) proxy_daemon.shutdown() proxy_daemon.server_close() proxy_thread.join() if config.PAC_ENABLE: pac_daemon.shutdown() pac_daemon.server_close() pac_thread.join()
def main(): pre_start() connect_control.keep_running = True connect_manager.https_manager.load_config() xlog.debug("## GAEProxy set keep_running: %s", connect_control.keep_running) CertUtil.init_ca() if config.LISTEN_USERNAME: proxy_handler.GAEProxyHandler.handler_filters.insert(0, simple_http_server.AuthFilter(config.LISTEN_USERNAME, config.LISTEN_PASSWORD)) proxy_daemon = simple_http_server.HTTPServer((config.LISTEN_IP, config.LISTEN_PORT), proxy_handler.GAEProxyHandler) proxy_thread = threading.Thread(target=proxy_daemon.serve_forever) proxy_thread.setDaemon(True) proxy_thread.start() if config.PAC_ENABLE: pac_daemon = simple_http_server.HTTPServer((config.PAC_IP, config.PAC_PORT), PACServerHandler) pac_thread = threading.Thread(target=pac_daemon.serve_forever) pac_thread.setDaemon(True) pac_thread.start() urllib2.urlopen('http://127.0.0.1:%d/%s' % (config.PAC_PORT, config.PAC_FILE)) while connect_control.keep_running: time.sleep(1) proxy_daemon.shutdown() proxy_daemon.server_close() proxy_thread.join() if config.PAC_ENABLE: pac_daemon.shutdown() pac_daemon.server_close() pac_thread.join()
def main(): pre_start() connect_control.keep_running = True connect_manager.https_manager.load_config() xlog.debug("## GAEProxy set keep_running: %s", connect_control.keep_running) CertUtil.init_ca() proxy_daemon = simple_http_server.HTTPServer( (config.LISTEN_IP, config.LISTEN_PORT), proxy_handler.GAEProxyHandler) proxy_thread = threading.Thread(target=proxy_daemon.serve_forever) proxy_thread.setDaemon(True) proxy_thread.start() if config.PAC_ENABLE: pac_daemon = simple_http_server.HTTPServer( (config.PAC_IP, config.PAC_PORT), PACServerHandler) pac_thread = threading.Thread(target=pac_daemon.serve_forever) pac_thread.setDaemon(True) pac_thread.start() try: urllib2.urlopen('http://127.0.0.1:%d/%s' % (config.PAC_PORT, config.PAC_FILE)) except: pass while connect_control.keep_running: time.sleep(1)
def main(): global ready connect_control.keep_running = True config.load() connect_manager.https_manager.load_config() xlog.debug("## GAEProxy set keep_running: %s", connect_control.keep_running) # to profile gae_proxy, run proxy.py, visit some web by proxy, then visit http://127.0.0.1:8084/quit to quit and print result. do_profile = config.do_profile if do_profile: import cProfile, pstats pr = cProfile.Profile() pr.enable() global __file__ __file__ = os.path.abspath(__file__) if os.path.islink(__file__): __file__ = getattr(os, 'readlink', lambda x: x)(__file__) os.chdir(os.path.dirname(os.path.abspath(__file__))) #xlog.basicConfig(level=xlog.DEBUG if config.LISTEN_DEBUGINFO else xlog.INFO, format='%(levelname)s - %(asctime)s %(message)s', datefmt='[%b %d %H:%M:%S]') pre_start() log_info() CertUtil.init_ca() proxy_daemon = simple_http_server.HTTPServer((config.LISTEN_IP, config.LISTEN_PORT), proxy_handler.GAEProxyHandler) proxy_thread = threading.Thread(target=proxy_daemon.serve_forever) proxy_thread.setDaemon(True) proxy_thread.start() if config.PAC_ENABLE: pac_daemon = simple_http_server.HTTPServer((config.PAC_IP, config.PAC_PORT), pac_server.PACServerHandler) pac_thread = threading.Thread(target=pac_daemon.serve_forever) pac_thread.setDaemon(True) pac_thread.start() ready = True # checked by launcher.module_init while connect_control.keep_running: time.sleep(1) xlog.info("Exiting gae_proxy module...") proxy_daemon.shutdown() proxy_daemon.server_close() proxy_thread.join() if config.PAC_ENABLE: pac_daemon.shutdown() pac_daemon.server_close() pac_thread.join() ready = False # checked by launcher.module_init xlog.debug("## GAEProxy set keep_running: %s", connect_control.keep_running) if do_profile: pr.disable() pr.print_stats()
def main(): global ready for i in range(50): check_network = simple_check_worker() if check_network: break else: time.sleep(3) if (i + 1) % 5 == 0: xlog.error('Failed to connect to network, please check!') if i + 1 == 50: return pre_start() ip_range.load() google_ip.check() connect_control.keep_running = True connect_manager.https_manager.load_config() xlog.debug("## GAEProxy set keep_running: %s", connect_control.keep_running) CertUtil.init_ca() proxy_daemon = simple_http_server.HTTPServer( (config.LISTEN_IP, config.LISTEN_PORT), proxy_handler.GAEProxyHandler) proxy_thread = threading.Thread(target=proxy_daemon.serve_forever) proxy_thread.setDaemon(True) proxy_thread.start() if config.PAC_ENABLE: pac_daemon = simple_http_server.HTTPServer( (config.PAC_IP, config.PAC_PORT), PACServerHandler) pac_thread = threading.Thread(target=pac_daemon.serve_forever) pac_thread.setDaemon(True) pac_thread.start() urllib2.urlopen('http://127.0.0.1:%d/%s' % (config.PAC_PORT, config.PAC_FILE)) #PACServerHandler.do_GET() ready = True # checked by launcher.module_init while connect_control.keep_running: time.sleep(1) xlog.info("Exiting gae_proxy module...") proxy_daemon.shutdown() proxy_daemon.server_close() proxy_thread.join() if config.PAC_ENABLE: pac_daemon.shutdown() pac_daemon.server_close() pac_thread.join() ready = False # checked by launcher.module_init xlog.debug("## GAEProxy set keep_running: %s", connect_control.keep_running)
def main(): # to profile goagent, run proxy.py, visit some web by proxy, then visit http://127.0.0.1:8084/quit to quit and print result. do_profile = False if do_profile: import cProfile, pstats pr = cProfile.Profile() pr.enable() global __file__ __file__ = os.path.abspath(__file__) if os.path.islink(__file__): __file__ = getattr(os, 'readlink', lambda x: x)(__file__) os.chdir(os.path.dirname(os.path.abspath(__file__))) logging.basicConfig( level=logging.DEBUG if config.LISTEN_DEBUGINFO else logging.INFO, format='%(levelname)s - %(asctime)s %(message)s', datefmt='[%b %d %H:%M:%S]') pre_start() logging.info(config.info()) if config.PAC_ENABLE: server = LocalProxyServer((config.PAC_IP, config.PAC_PORT), pac_server.PACServerHandler) p = threading.Thread(target=server.serve_forever) p.setDaemon(True) p.start() if config.CONTROL_ENABLE: control_server = LocalProxyServer( (config.CONTROL_IP, config.CONTROL_PORT), web_control.RemoteContralServerHandler) p = threading.Thread(target=control_server.serve_forever) p.setDaemon(True) p.start() server = LocalProxyServer((config.LISTEN_IP, config.LISTEN_PORT), proxy_handler.GAEProxyHandler) p = threading.Thread(target=server.serve_forever) p.setDaemon(True) p.start() CertUtil.init_ca() while config.keep_run: time.sleep(1) if do_profile: pr.disable() pr.print_stats()
def import_certfile(): CertUtil.init_ca()