def req_config_handler(self): req = urlparse.urlparse(self.path).query reqs = urlparse.parse_qs(req, keep_blank_values=True) data = '' appid_updated = False try: if reqs['cmd'] == ['get_config']: data = json.dumps(user_config.user_special, default=lambda o: o.__dict__) elif reqs['cmd'] == ['set_config']: appids = self.postvars['appid'][0] if appids != user_config.user_special.appid: if appids and (google_ip.good_ipv4_num + google_ip.good_ipv6_num): fail_appid_list = test_appid.test_appids(appids) if len(fail_appid_list): fail_appid = "|".join(fail_appid_list) return self.send_response_nc('text/html', '{"res":"fail", "reason":"appid fail:%s"}' % fail_appid) appid_updated = True user_config.user_special.appid = appids user_config.user_special.proxy_enable = self.postvars['proxy_enable'][0] user_config.user_special.proxy_type = self.postvars['proxy_type'][0] user_config.user_special.proxy_host = self.postvars['proxy_host'][0] user_config.user_special.proxy_port = self.postvars['proxy_port'][0] try: user_config.user_special.proxy_port = int(user_config.user_special.proxy_port) except: user_config.user_special.proxy_port = 0 user_config.user_special.proxy_user = self.postvars['proxy_user'][0] user_config.user_special.proxy_passwd = self.postvars['proxy_passwd'][0] user_config.user_special.host_appengine_mode = self.postvars['host_appengine_mode'][0] user_config.save() config.load() appid_manager.reset_appid() import connect_manager connect_manager.https_manager.load_config() if appid_updated: http_dispatch.close_all_worker() google_ip.reset() check_ip.load_proxy_config() data = '{"res":"success"}' self.send_response_nc('text/html', data) #http_request("http://127.0.0.1:8085/init_module?module=gae_proxy&cmd=restart") return except Exception as e: xlog.exception("req_config_handler except:%s", e) data = '{"res":"fail", "except":"%s"}' % e self.send_response_nc('text/html', data)
def req_config_handler(self): req = urlparse.urlparse(self.path).query reqs = urlparse.parse_qs(req, keep_blank_values=True) data = '' appid_updated = False try: if reqs['cmd'] == ['get_config']: data = json.dumps(user_config.user_special, default=lambda o: o.__dict__) elif reqs['cmd'] == ['set_config']: appids = self.postvars['appid'][0] if appids != user_config.user_special.appid: if appids and (google_ip.good_ipv4_num + google_ip.good_ipv6_num): fail_appid_list = test_appid.test_appids(appids) if len(fail_appid_list): fail_appid = "|".join(fail_appid_list) return self.send_response_nc( 'text/html', '{"res":"fail", "reason":"appid fail:%s"}' % fail_appid) appid_updated = True user_config.user_special.appid = appids user_config.save() config.load() appid_manager.reset_appid() import connect_manager connect_manager.https_manager.load_config() if appid_updated: http_dispatch.close_all_worker() google_ip.reset() data = '{"res":"success"}' self.send_response_nc('text/html', data) #http_request("http://127.0.0.1:8085/init_module?module=gae_proxy&cmd=restart") return except Exception as e: xlog.exception("req_config_handler except:%s", e) data = '{"res":"fail", "except":"%s"}' % e self.send_response_nc('text/html', data)
def req_config_handler(self): req = urlparse.urlparse(self.path).query reqs = urlparse.parse_qs(req, keep_blank_values=True) data = '' appid_updated = False try: if reqs['cmd'] == ['get_config']: data = json.dumps(user_config.user_special, default=lambda o: o.__dict__) elif reqs['cmd'] == ['set_config']: appids = self.postvars['appid'][0] if appids != user_config.user_special.appid: if appids and google_ip.good_ip_num: fail_appid_list = test_appid.test_appids(appids) if len(fail_appid_list): fail_appid = "|".join(fail_appid_list) return self.send_response_nc( 'text/html', '{"res":"fail", "reason":"appid fail:%s"}' % fail_appid) appid_updated = True user_config.user_special.appid = appids user_config.user_special.proxy_enable = self.postvars[ 'proxy_enable'][0] user_config.user_special.proxy_type = self.postvars[ 'proxy_type'][0] user_config.user_special.proxy_host = self.postvars[ 'proxy_host'][0] user_config.user_special.proxy_port = self.postvars[ 'proxy_port'][0] try: user_config.user_special.proxy_port = int( user_config.user_special.proxy_port) except: user_config.user_special.proxy_port = 0 user_config.user_special.proxy_user = self.postvars[ 'proxy_user'][0] user_config.user_special.proxy_passwd = self.postvars[ 'proxy_passwd'][0] user_config.user_special.host_appengine_mode = self.postvars[ 'host_appengine_mode'][0] use_ipv6 = int(self.postvars['use_ipv6'][0]) if user_config.user_special.use_ipv6 != use_ipv6: if use_ipv6: if not check_local_network.check_ipv6(): xlog.warn("IPv6 was enabled, but check failed.") return self.send_response_nc( 'text/html', '{"res":"fail", "reason":"IPv6 fail"}') user_config.user_special.use_ipv6 = use_ipv6 user_config.save() config.load() appid_manager.reset_appid() import connect_manager connect_manager.load_proxy_config() connect_manager.https_manager.load_config() if appid_updated: http_dispatch.close_all_worker() google_ip.reset() check_ip.load_proxy_config() data = '{"res":"success"}' self.send_response_nc('text/html', data) #http_request("http://127.0.0.1:8085/init_module?module=gae_proxy&cmd=restart") return except Exception as e: xlog.exception("req_config_handler except:%s", e) data = '{"res":"fail", "except":"%s"}' % e self.send_response_nc('text/html', data)