diff options
author | 2016-09-08 23:20:06 +0800 | |
---|---|---|
committer | 2016-09-09 14:18:38 +0800 | |
commit | b69d850757a7a8c4ff9a368df004a3cfaaf9f1e4 (patch) | |
tree | 6ba5fb3330c763fd3d550ec3671f723587beae65 /msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/make_authed.lua | |
parent | 3be6b09b74dd3e54e631181dc37bd1e5685a1c62 (diff) |
Issue-id: OCS-9
Change-Id: I73c18bdda656c43687810930338f9a949ed08848
Signed-off-by: Zhaoxing <meng.zhaoxing1@zte.com.cn>
Diffstat (limited to 'msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/make_authed.lua')
-rw-r--r-- | msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/make_authed.lua | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/make_authed.lua b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/make_authed.lua deleted file mode 100644 index c4c2d78..0000000 --- a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/make_authed.lua +++ /dev/null @@ -1,44 +0,0 @@ -function ipValidator(ip)
- local chunks = {ip:match("(%d+)%.(%d+)%.(%d+)%.(%d+)")}
- if #chunks == 4 then
- for _,v in pairs(chunks) do
- if tonumber(v) > 255 then return R.STRING end
- end
- return true
- end
- local chunks = {ip:match(("([a-fA-F0-9]*):"):rep(8):gsub(":$","$"))}
- if #chunks == 8 then
- for _,v in pairs(chunks) do
- if #v > 0 and tonumber(v, 16) > 65535 then return R.STRING end
- end
- return true
- end
- return false
-end
-
-if ngx.req.get_method() == "POST" then
- ngx.req.read_body()
- local body = ngx.req.get_body_data()
- local json = require('cjson')
- local tab = json.decode(body)
- local ip = tab["passIp"]
- if not ip then
- ngx.log(ngx.WARN, "ip is nil.")
- ngx.exit(500)
- end
- if ipValidator(ip) then
- local cache = ngx.shared.ceryx
- local succ, err, forcible = cache:set(ip, "place_holder", 3600)
- if not succ then
- ngx.log(ngx.WARN, err)
- ngx.exit(500)
- end
- else
- ngx.log(ngx.WARN, "not a valid ip.")
- ngx.exit(500)
- end
- ngx.exit(201)
-else
- ngx.log(ngx.WARN, "not a POST request.")
- ngx.exit(500)
-end
\ No newline at end of file |