From 16cc3eab404c92e18d0427b262bb34b5be587b5b Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Sat, 11 May 2024 13:52:39 +0800 Subject: [PATCH 1/2] Update site_api.py --- class/core/site_api.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/class/core/site_api.py b/class/core/site_api.py index ddd857211..bbaf2a71c 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -1960,6 +1960,19 @@ class site_api: proxy_site_path) if os.path.exists(proxy_site_path) else "" data = json.loads(data_content) if data_content != "" else [] + proxy_action = 'add' + if _id == "": + _id = mw.md5("{}".format(_name)) + else: + proxy_action = 'edit' + + if proxy_action == "add": + for item in data: + if item["name"] == _name: + return mw.returnJson(False, "名称重复!!") + if item["from"] == _from: + return mw.returnJson(False, "代理目录已存在!!") + tpl = "#PROXY-START\n\ location ^~ {from} {\n\ proxy_pass {to};\n\ @@ -2016,15 +2029,11 @@ location ^~ {from} {\n\ else: tpl = tpl.replace("{proxy_cache}", tpl_proxy_nocache, 999) - proxy_action = 'add' - if _id == "": - _id = mw.md5("{}".format(_name)) - else: - proxy_action = 'edit' conf_proxy = "{}/{}.conf".format(self.getProxyPath(_siteName), _id) conf_bk = "{}/{}.conf.txt".format(self.getProxyPath(_siteName), _id) + print(tpl) mw.writeFile(conf_proxy, tpl) rule_test = mw.checkWebConfig() From e92151c9c533bf8a99987b88f2544f23bbe1e646 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Sat, 11 May 2024 13:52:52 +0800 Subject: [PATCH 2/2] Update site_api.py --- class/core/site_api.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/class/core/site_api.py b/class/core/site_api.py index bbaf2a71c..ca3983da2 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -2032,8 +2032,6 @@ location ^~ {from} {\n\ conf_proxy = "{}/{}.conf".format(self.getProxyPath(_siteName), _id) conf_bk = "{}/{}.conf.txt".format(self.getProxyPath(_siteName), _id) - - print(tpl) mw.writeFile(conf_proxy, tpl) rule_test = mw.checkWebConfig()