diff --git a/code/default/launcher/web_control.py b/code/default/launcher/web_control.py index a1c0be119f..531488e827 100644 --- a/code/default/launcher/web_control.py +++ b/code/default/launcher/web_control.py @@ -71,11 +71,11 @@ def handle_one_request(self): "Allow": "GET,POST,OPTIONS", "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "GET,POST,OPTIONS", - "Access-Control-Allow-Headers": "Authorization,Content-Type", + "Access-Control-Allow-Headers": "Authorization,Content-Type,Sec-Fetch-Site,Sec-Fetch-Mode,Sec-Fetch-Dest", "Connection": "close", - "Content-Type": "text/html", } + class Http_Handler(simple_http_server.HttpServerHandler): deploy_proc = None @@ -103,25 +103,19 @@ def load_module_menus(self): # xlog.debug("m:%s id:%d", k, v['menu_sort_id']) def do_OPTIONS(self): + # xlog.debug('%s "%s headers:%s from:%s', self.command, self.path, self.headers, self.address_string()) try: - # origin = utils.to_str(self.headers.get(b'Origin')) + origin = utils.to_str(self.headers.get(b'Origin')) # if origin not in self.config.allow_web_origins: # return - self.headers = utils.to_str(self.headers) - self.path = utils.to_str(self.path) - - refer = self.headers.get('Referer') - if refer: - refer_loc = urlparse(refer).netloc - host = self.headers.get('Host') - if refer_loc != host and refer_loc not in config.allowed_refers: - xlog.warn("web control ref:%s host:%s", refer_loc, host) - return - - self.set_CORS(CORS_header) - - return self.send_response() + header = { + "Allow": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS", + "Access-Control-Allow-Origin": origin, + "Access-Control-Allow-Methods": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS", + "Access-Control-Allow-Headers": "Authorization,Content-Type", + } + return self.send_response(headers=header) except Exception as e: xlog.exception("options fail:%r", e) return self.send_not_found() diff --git a/code/default/lib/noarch/xlog.py b/code/default/lib/noarch/xlog.py index 202d51cc35..07672c6728 100644 --- a/code/default/lib/noarch/xlog.py +++ b/code/default/lib/noarch/xlog.py @@ -367,7 +367,7 @@ def keep_log(temp=False): full_log = True else: for name, log in loggerDict.items(): - log.keep_logs(temp) + log.keep_logs() default_log = getLogger() diff --git a/code/default/version.txt b/code/default/version.txt index a16dcb354a..b54822f0da 100644 --- a/code/default/version.txt +++ b/code/default/version.txt @@ -1 +1 @@ -5.10.5 \ No newline at end of file +5.10.7 \ No newline at end of file diff --git a/code/default/x_tunnel/local/proxy_session.py b/code/default/x_tunnel/local/proxy_session.py index c718e650bc..a657416fd9 100644 --- a/code/default/x_tunnel/local/proxy_session.py +++ b/code/default/x_tunnel/local/proxy_session.py @@ -34,6 +34,7 @@ def decrypt_data(data): else: return data + def traffic_readable(num, units=('B', 'KB', 'MB', 'GB')): for unit in units: if num >= 1024: diff --git a/code/default/x_tunnel/local/upload_logs.py b/code/default/x_tunnel/local/upload_logs.py index 2cb88bd9e3..31ef647b24 100644 --- a/code/default/x_tunnel/local/upload_logs.py +++ b/code/default/x_tunnel/local/upload_logs.py @@ -40,23 +40,36 @@ def mask_x_tunnel_password(fp): return dat_str +def get_launcher_port(): + launcher_config_fn = os.path.join(data_path, "launcher", "config.json") + try: + with open(launcher_config_fn, "r") as fd: + info = json.load(fd) + return info.get("control_port", 8085) + except Exception as e: + xlog.exception("get_launcher_port except:%r", e) + return 8085 + + def collect_debug_and_log(): + port = get_launcher_port() + # collect debug info and save to folders debug_infos = { - "system_info": "http://127.0.0.1:8085/debug", - "gae_info": "http://127.0.0.1:8085/module/gae_proxy/control/debug", - "gae_log": "http://127.0.0.1:8085/module/gae_proxy/control/log?cmd=get_new&last_no=1", - "xtunnel_info": "http://127.0.0.1:8085/module/x_tunnel/control/debug", - "xtunnel_status": "http://127.0.0.1:8085/module/x_tunnel/control/status", - "cloudflare_info": "http://127.0.0.1:8085/module/x_tunnel/control/cloudflare_front/debug", - "tls_info": "http://127.0.0.1:8085/module/x_tunnel/control/tls_relay_front/debug", - "seley_info": "http://127.0.0.1:8085/module/x_tunnel/control/seley_front/debug", - "cloudflare_log": "http://127.0.0.1:8085/module/x_tunnel/control/cloudflare_front/log?cmd=get_new&last_no=1", - "tls_log": "http://127.0.0.1:8085/module/x_tunnel/control/tls_relay_front/log?cmd=get_new&last_no=1", - "seley_log": "http://127.0.0.1:8085/module/x_tunnel/control/seley_front/log?cmd=get_new&last_no=1", - "xtunnel_log": "http://127.0.0.1:8085/module/x_tunnel/control/log?cmd=get_new&last_no=1", - "smartroute_log": "http://127.0.0.1:8085/module/smart_router/control/log?cmd=get_new&last_no=1", - "launcher_log": "http://127.0.0.1:8085/log?cmd=get_new&last_no=1" + "system_info": f"http://127.0.0.1:{port}/debug", + "gae_info": f"http://127.0.0.1:{port}/module/gae_proxy/control/debug", + "gae_log": f"http://127.0.0.1:{port}/module/gae_proxy/control/log?cmd=get_new&last_no=1", + "xtunnel_info": f"http://127.0.0.1:{port}/module/x_tunnel/control/debug", + "xtunnel_status": f"http://127.0.0.1:{port}/module/x_tunnel/control/status", + "cloudflare_info": f"http://127.0.0.1:{port}/module/x_tunnel/control/cloudflare_front/debug", + "tls_info": f"http://127.0.0.1:{port}/module/x_tunnel/control/tls_relay_front/debug", + "seley_info": f"http://127.0.0.1:{port}/module/x_tunnel/control/seley_front/debug", + "cloudflare_log": f"http://127.0.0.1:{port}/module/x_tunnel/control/cloudflare_front/log?cmd=get_new&last_no=1", + "tls_log": f"http://127.0.0.1:{port}/module/x_tunnel/control/tls_relay_front/log?cmd=get_new&last_no=1", + "seley_log": f"http://127.0.0.1:{port}/module/x_tunnel/control/seley_front/log?cmd=get_new&last_no=1", + "xtunnel_log": f"http://127.0.0.1:{port}/module/x_tunnel/control/log?cmd=get_new&last_no=1", + "smartroute_log": f"http://127.0.0.1:{port}/module/smart_router/control/log?cmd=get_new&last_no=1", + "launcher_log": f"http://127.0.0.1:{port}/log?cmd=get_new&last_no=1" } download_path = os.path.join(env_info.data_path, "downloads") @@ -110,7 +123,7 @@ def list_files(): return other_files + log_files_list -def pack_logs(max_size=4 * 1024 * 1024): +def pack_logs(max_size=10 * 1024 * 1024): content_size = 0 collect_debug_and_log()