diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 7d4efb8..7cb639e 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,16 +2,8 @@ - - - - - - - - - + @@ -32,7 +24,48 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -124,9 +159,9 @@ - + - + @@ -179,5 +214,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/config.lua b/config.lua index ee3056b..11327da 100644 --- a/config.lua +++ b/config.lua @@ -1,11 +1,11 @@ -- -- Created by IntelliJ IDEA. --- User: guang --- Date: 16/9/23 --- Time: 下午4:28 --- To change this template use File | Settings | File Templates. +-- User: ibuler +-- Date: 16/9/22 +-- Time: 下午7:13 -- + local _M = {} _M.version = '0.1.0' diff --git a/core.lua b/core.lua index 590992d..60006ae 100644 --- a/core.lua +++ b/core.lua @@ -1,9 +1,8 @@ -- -- Created by IntelliJ IDEA. --- User: guang +-- User: ibuler -- Date: 16/9/22 -- Time: 下午7:13 --- To change this template use File | Settings | File Templates. -- @@ -63,11 +62,21 @@ function _M.deny_cc(self) if req then if req > max_visit then - ngx.exit(self.config.cc_deny_code) - return true + if self.config.active then + ngx.exit(self.config.cc_deny_code) + return true + else + return false + end elseif req == max_visit then - self:log("[Block] " .. token) + if self.config.active then + self:log("[Deny_cc] Block " .. token) + ngx.exit(self.config.cc_deny_code) + else + self:log("[Deny_cc] FakeBlock " .. token) + end limit:incr(token, 1) + return true else limit:incr(token, 1) end @@ -81,7 +90,6 @@ function _M.log(self, msg) log_inited[self.config.log_path] = io.open(self.config.log_path, 'ab') end self.fd = log_inited[self.config.log_path] - self.fd:write(msg .. '\n') self.fd:flush() end