Showing
1 changed file
with
2 additions
and
20 deletions
@@ -4,9 +4,6 @@ _G[modname]=M | @@ -4,9 +4,6 @@ _G[modname]=M | ||
4 | package.loaded[modname]=M | 4 | package.loaded[modname]=M |
5 | 5 | ||
6 | local cjson=require "cjson" | 6 | local cjson=require "cjson" |
7 | -local rate_limit = require "limit_common_flow" | ||
8 | -local iptool=require "iptool" | ||
9 | -local lrucache = require "resty.lrucache" | ||
10 | local http_request = require "http_request" | 7 | local http_request = require "http_request" |
11 | 8 | ||
12 | 9 | ||
@@ -14,21 +11,6 @@ local cache=lua_context.mal_ip_cache | @@ -14,21 +11,6 @@ local cache=lua_context.mal_ip_cache | ||
14 | local redis_limit_ip=lua_context["redis_limit_ip"] | 11 | local redis_limit_ip=lua_context["redis_limit_ip"] |
15 | 12 | ||
16 | 13 | ||
17 | - | ||
18 | -function M.in_array(value,arr) | ||
19 | - if not value then | ||
20 | - return false | ||
21 | - end | ||
22 | - if not arr then | ||
23 | - return false | ||
24 | - end | ||
25 | - for k, v in ipairs(arr) do | ||
26 | - if value==v then | ||
27 | - return true | ||
28 | - end | ||
29 | - end | ||
30 | - return false | ||
31 | -end | ||
32 | 14 | ||
33 | -- mal ip controller api -------- | 15 | -- mal ip controller api -------- |
34 | function M:mal_ip() | 16 | function M:mal_ip() |
@@ -38,7 +20,7 @@ function M:mal_ip() | @@ -38,7 +20,7 @@ function M:mal_ip() | ||
38 | ngx.header["Content-type"]="application/json;charset=utf-8" | 20 | ngx.header["Content-type"]="application/json;charset=utf-8" |
39 | if not method then | 21 | if not method then |
40 | ngx.say('{"code": 400, "msg": "params error!"}') | 22 | ngx.say('{"code": 400, "msg": "params error!"}') |
41 | - ngx.exit(ngx.HTTP_OK) | 23 | + ngx.exit(ngx.HTTP_OK) |
42 | end | 24 | end |
43 | local exists={} | 25 | local exists={} |
44 | if method == 'pubAdd' then | 26 | if method == 'pubAdd' then |
@@ -57,7 +39,7 @@ function M:mal_ip() | @@ -57,7 +39,7 @@ function M:mal_ip() | ||
57 | t.type="flush" | 39 | t.type="flush" |
58 | redis_limit_ip:cmd("publish","mal_ips",cjson.encode(t)) | 40 | redis_limit_ip:cmd("publish","mal_ips",cjson.encode(t)) |
59 | elseif method == 'queryAll' then | 41 | elseif method == 'queryAll' then |
60 | - local all_ips=cache:get_keys(0) | 42 | + local all_ips=cache:get_keys(0) |
61 | for i,v in pairs(all_ips) do | 43 | for i,v in pairs(all_ips) do |
62 | exists[#exists+1]=string.sub(v,8,string.len(v)) | 44 | exists[#exists+1]=string.sub(v,8,string.len(v)) |
63 | end | 45 | end |
-
Please register or login to post a comment