pull/63/head
ibuler 2016-09-24 18:00:22 +08:00
parent b56499f7e2
commit 3db5c378fa
3 changed files with 97 additions and 22 deletions

View File

@ -2,16 +2,8 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="2eef964a-b574-48e0-859a-c282c4760328" name="Default" comment="">
<change type="DELETED" beforePath="$PROJECT_DIR$/README.md" afterPath="" />
<change type="DELETED" beforePath="$PROJECT_DIR$/entry.lua" afterPath="" />
<change type="DELETED" beforePath="$PROJECT_DIR$/init.lua" afterPath="" />
<change type="DELETED" beforePath="$PROJECT_DIR$/wafconf/args" afterPath="" />
<change type="DELETED" beforePath="$PROJECT_DIR$/wafconf/cookie" afterPath="" />
<change type="DELETED" beforePath="$PROJECT_DIR$/wafconf/post" afterPath="" />
<change type="DELETED" beforePath="$PROJECT_DIR$/wafconf/url" afterPath="" />
<change type="DELETED" beforePath="$PROJECT_DIR$/wafconf/user_agent" afterPath="" />
<change type="DELETED" beforePath="$PROJECT_DIR$/wafconf/white_url" afterPath="" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/config.lua" afterPath="$PROJECT_DIR$/config.lua" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/core.lua" afterPath="$PROJECT_DIR$/core.lua" />
</list>
<ignored path="ngx_lua_waf.iws" />
<ignored path=".idea/workspace.xml" />
@ -32,7 +24,48 @@
<favorites_list name="ngx_lua_waf" />
</component>
<component name="FileEditorManager">
<leaf />
<leaf>
<file leaf-file-name="core.lua" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/core.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="config.lua" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/config.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="133">
<caret line="7" column="0" selection-start-line="7" selection-start-column="0" selection-end-line="7" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="iputils.lua" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/iputils.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name=".gitattributes" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/.gitattributes">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
@ -41,6 +74,8 @@
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/init.lua" />
<option value="$PROJECT_DIR$/core.lua" />
<option value="$PROJECT_DIR$/config.lua" />
</list>
</option>
</component>
@ -124,9 +159,9 @@
</component>
<component name="ToolWindowManager">
<frame x="49" y="23" width="1260" height="709" extended-state="0" />
<editor active="false" />
<editor active="true" />
<layout>
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.24958949" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.24958949" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="LuaJ" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
@ -179,5 +214,37 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/.gitattributes">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/core.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/iputils.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/config.lua">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="133">
<caret line="7" column="0" selection-start-line="7" selection-start-column="0" selection-end-line="7" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</component>
</project>

View File

@ -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 <ibuler@qq.com>
-- Date: 16/9/22
-- Time: 下午7:13
--
local _M = {}
_M.version = '0.1.0'

View File

@ -1,9 +1,8 @@
--
-- Created by IntelliJ IDEA.
-- User: guang
-- User: ibuler <ibuler@qq.com>
-- 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