From b63794757a39ac5409790e2920b6a29d4b6bc2d0 Mon Sep 17 00:00:00 2001 From: wulabing Date: Thu, 2 Jun 2022 17:35:48 +0800 Subject: [PATCH] Xray-0.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [update] 添加配置自动应用,重复IP判断 --- ss_whitelist/config/nginx.conf | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ss_whitelist/config/nginx.conf b/ss_whitelist/config/nginx.conf index 83bb092..5fdfa43 100644 --- a/ss_whitelist/config/nginx.conf +++ b/ss_whitelist/config/nginx.conf @@ -97,11 +97,19 @@ http { file = io.open("/etc/openresty/allow.list","a+") io.input(file) io.output(file) - io.write("allow "..clientIP..";\n") - ngx.print("当前IP:"..clientIP.."已添加至白名单") + for line in file:lines() do + if string.find(line,clientIP) then + m = string.find(line,clientIP) + ngx.print("当前IP:"..clientIP.."已存在,无需添加") + end + end + if m == nil then + io.write("allow "..clientIP..";\n") + ngx.print("当前IP:"..clientIP.."已添加至白名单") + end io.close(file) + os.execute("/usr/local/openresty/nginx/sbin/nginx -s reload") } - } } }