OP防火墙部分优化

This commit is contained in:
midoks
2023-08-11 12:56:07 +08:00
parent 2b2fc08120
commit 6eadad5db4
5 changed files with 126 additions and 112 deletions
+11 -11
View File
@@ -19,7 +19,7 @@
<div class="main">
<div class="title">OP网站防火墙|安全校验</div>
<div class="content">
<p id="change">5</p>
<p id="change">3</p>
</div>
<div id="status" style="display: none;">false</div>
</div>
@@ -125,22 +125,22 @@ function ajax(type,bool){
return xhr;
}
ajax('JSON',true).post('{uri}',{'pass':"ok"}, function(data){
if (data['status'] == 0){
document.getElementById('status').innerHTML = 'ok';
location.reload();
}
});
var ok = setInterval(function(){
var id = document.getElementById('change').innerHTML;
id = id - 1;
if (id == 0){
document.getElementById('change').innerHTML = '稍等';
clearInterval(ok);
if (document.getElementById('status').innerHTML == 'ok'){
location.reload();
}
ajax('JSON',true).post('{uri}',{'pass':"ok"}, function(data){
if (data['status'] == 0 && data['msg'] == 'ok'){
document.getElementById('status').innerHTML = 'ok';
setTimeout(function(){
location.reload();
},500);
} else{
document.getElementById('change').innerHTML = '?';
}
});
} else {
document.getElementById('change').innerHTML = id;
}
+7 -11
View File
@@ -35,10 +35,8 @@ local cookie_rules = require "rule_cookie"
local url_rules = require "rule_url"
local url_white_rules = require "rule_url_white"
-- local server_name = string.gsub(C:get_sn(config_domains),'_','.')
local server_name = C:get_sn(config_domains)
local function initParams()
local data = {}
data['server_name'] = server_name
@@ -53,10 +51,12 @@ local function initParams()
data['user_agent'] = data['request_header']['user-agent']
data['cookie'] = ngx.var.http_cookie
data['time'] = ngx.time()
return data
end
local params = initParams()
-- C:D(C:to_json(params))
C:setParams(params)
local cpu_percent = ngx.shared.waf_limit:get("cpu_usage")
@@ -343,6 +343,7 @@ local function waf_cc_increase()
local make_uri_str = "?token="..make_token
local make_uri = "/"..make_uri_str
-- C:D("token:"..tostring(params['uri_request_args']['token']))
if params['uri_request_args']['token'] then
ngx.header.content_type = "application/json"
local args_token = params['uri_request_args']['token']
@@ -352,14 +353,9 @@ local function waf_cc_increase()
ngx.say(json.encode(data))
ngx.exit(200)
end
-- C:D("debug[args]:"..tostring(params['uri_request_args']['debug']))
-- if params['uri_request_args']['debug'] == 'ok' then
-- ngx.header.content_type = "application/json"
-- local data = get_return_state(0, "ok")
-- ngx.say(json.encode(data))
-- ngx.exit(200)
-- end
local data = get_return_state(0, "unset")
ngx.say(json.encode(data))
ngx.exit(200)
end
local cc_html = ngx.re.gsub(cc_safe_js_html, "{uri}", make_uri_str)
@@ -531,7 +527,7 @@ end
function waf()
if server_name == "unset" then ngx.exit(403) end
-- if server_name == "unset" then ngx.exit(403) end
min_route()
-- C:D("min_route")
+1 -1
View File
@@ -207,7 +207,7 @@ function _M.D(self, msg)
local _msg = ''
if type(msg) == 'table' then
for key, val in pairs(msg) do
_msg = tostring( key)..':'.."\n"
_msg = tostring(key)..':'.."\n"
end
elseif type(msg) == 'string' then
_msg = msg