diff --git a/plugins/op_waf/t/index.py b/plugins/op_waf/t/index.py index bbcd2805f..6b5d006dd 100644 --- a/plugins/op_waf/t/index.py +++ b/plugins/op_waf/t/index.py @@ -212,10 +212,10 @@ def test_start(): # test_OK() # test_Dir() # test_UA() - test_UA_for(1000) + # test_UA_for(1000) # test_POST() # test_scan() - # test_CC() + test_CC() # test_url_ext() # test_cdn() diff --git a/plugins/op_waf/waf/html/safe_js.html b/plugins/op_waf/waf/html/safe_js.html index bd922a6c5..fe7df84ab 100755 --- a/plugins/op_waf/waf/html/safe_js.html +++ b/plugins/op_waf/waf/html/safe_js.html @@ -125,14 +125,14 @@ function ajax(type,bool){ return xhr; } -var ok = setInterval(function(){ - - ajax('JSON',true).post('{uri}',{'pass':"ok"},function(data){ - if (data['status'] == 0){ - location.reload(); - } - }); +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){ diff --git a/plugins/op_waf/waf/lua/common.lua b/plugins/op_waf/waf/lua/common.lua index 00a43ce9c..5326c4db5 100644 --- a/plugins/op_waf/waf/lua/common.lua +++ b/plugins/op_waf/waf/lua/common.lua @@ -180,7 +180,10 @@ end function _M.return_message(self, status, msg) ngx.header.content_type = "application/json" + self:D("return_message:"..tostring(status)..tostring(msg)) local data = self:return_state(status, msg) + + self:D("return_message[data]:"..tostring(data)) ngx.say(json.encode(data)) ngx.exit(200) end diff --git a/plugins/op_waf/waf/lua/init.lua b/plugins/op_waf/waf/lua/init.lua index e139b56d4..601023725 100644 --- a/plugins/op_waf/waf/lua/init.lua +++ b/plugins/op_waf/waf/lua/init.lua @@ -62,6 +62,15 @@ local function get_waf_drop_ip() return data end +local function return_json(status,msg) + ngx.header.content_type = "application/json" + result = {} + result['status'] = status + result['msg'] = msg + ngx.say(json.encode(data)) + ngx.exit(200) +end + local function is_chekc_table(data,strings) if type(data) ~= 'table' then return 1 end if not data then return 1 end @@ -308,8 +317,10 @@ local function waf_cc_increase() if params['uri_request_args']['token'] then local args_token = params['uri_request_args']['token'] if args_token == make_token then - ngx.shared.waf_limit:set(cache_token,1, config['safe_verify']['time']) - C:return_message(0,'ok') + ngx.shared.waf_limit:set(cache_token, 1, config['safe_verify']['time']) + local data = get_return_state(0, "ok") + ngx.say(json.encode(data)) + ngx.exit(200) end end