From 05b72a0c7e3a31521d27f720738eeb08e3ed701d Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 4 Apr 2026 00:29:52 +0800 Subject: [PATCH] update --- web/admin/site/proxy.py | 3 ++- web/utils/site.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/web/admin/site/proxy.py b/web/admin/site/proxy.py index 2574a681e..367c5c903 100644 --- a/web/admin/site/proxy.py +++ b/web/admin/site/proxy.py @@ -43,10 +43,11 @@ def set_proxy(): name = request.form.get('name', '') open_proxy = request.form.get('open_proxy', '') open_cors = request.form.get('open_cors','') + open_http3 = request.form.get('open_http3','') open_cache = request.form.get('open_cache', '') cache_time = request.form.get('cache_time', '') proxy_id = request.form.get('id', '') - return MwSites.instance().setProxy(site_name,site_from,to,host,name,open_proxy,open_cors,open_cache,cache_time, proxy_id) + return MwSites.instance().setProxy(site_name,site_from,to,host,name,open_proxy,open_cors,open_http3,open_cache,cache_time, proxy_id) # 设置代理状态 @blueprint.route('/set_proxy_status', endpoint='set_proxy_status', methods=['POST']) diff --git a/web/utils/site.py b/web/utils/site.py index 2d6154361..7f75d7cdb 100644 --- a/web/utils/site.py +++ b/web/utils/site.py @@ -1489,7 +1489,7 @@ class sites(object): mw.writeFile(vhost_file, content) # 设置 网站 反向代理列表 - def setProxy(self, site_name, site_from, to, host, name, open_proxy, open_cors, open_cache, cache_time, proxy_id): + def setProxy(self, site_name, site_from, to, host, name, open_proxy, open_cors, open_http3,open_cache, cache_time, proxy_id): from urllib.parse import urlparse if site_name == "" or site_from == "" or to == "" or host == "" or name == "": return mw.returnData(False, "必填项不能为空") @@ -1582,6 +1582,10 @@ location ^~ {from} {\n\ }\n\ " + tpl_proxy_http3 = "\n\ + add_header Alt-Svc 'h3=\":443\";ma=86400' always;\n\ +" + # replace if site_from[0] != '/': site_from = '/' + site_from @@ -1601,6 +1605,11 @@ location ^~ {from} {\n\ else: tpl = tpl.replace("{cors}", '', 999) + if open_http3 == 'on': + tpl = tpl.replace("{http3}", tpl_proxy_http3, 999) + else: + tpl = tpl.replace("{http3}", '', 999) + conf_proxy = "{}/{}.conf".format(self.getProxyPath(site_name), proxy_id) conf_bk = "{}/{}.conf.txt".format(self.getProxyPath(site_name), proxy_id) @@ -1628,6 +1637,7 @@ location ^~ {from} {\n\ "cache_time": cache_time, "open_proxy": open_proxy, "open_cors": open_cors, + "open_http3": open_http3, "id": proxy_id, }) else: @@ -1646,6 +1656,7 @@ location ^~ {from} {\n\ data[dindex]['cache_time'] = cache_time data[dindex]['open_proxy'] = open_proxy data[dindex]['open_cors'] = open_cors + data[dindex]['open_http3'] = open_http3 if open_proxy != 'on': os.rename(conf_proxy, conf_bk)