Add .
parent
b56499f7e2
commit
3db5c378fa
|
@ -2,16 +2,8 @@
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="2eef964a-b574-48e0-859a-c282c4760328" name="Default" comment="">
|
<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$/config.lua" afterPath="$PROJECT_DIR$/config.lua" />
|
||||||
|
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/core.lua" afterPath="$PROJECT_DIR$/core.lua" />
|
||||||
</list>
|
</list>
|
||||||
<ignored path="ngx_lua_waf.iws" />
|
<ignored path="ngx_lua_waf.iws" />
|
||||||
<ignored path=".idea/workspace.xml" />
|
<ignored path=".idea/workspace.xml" />
|
||||||
|
@ -32,7 +24,48 @@
|
||||||
<favorites_list name="ngx_lua_waf" />
|
<favorites_list name="ngx_lua_waf" />
|
||||||
</component>
|
</component>
|
||||||
<component name="FileEditorManager">
|
<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>
|
||||||
<component name="Git.Settings">
|
<component name="Git.Settings">
|
||||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
|
@ -41,6 +74,8 @@
|
||||||
<option name="CHANGED_PATHS">
|
<option name="CHANGED_PATHS">
|
||||||
<list>
|
<list>
|
||||||
<option value="$PROJECT_DIR$/init.lua" />
|
<option value="$PROJECT_DIR$/init.lua" />
|
||||||
|
<option value="$PROJECT_DIR$/core.lua" />
|
||||||
|
<option value="$PROJECT_DIR$/config.lua" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
@ -124,9 +159,9 @@
|
||||||
</component>
|
</component>
|
||||||
<component name="ToolWindowManager">
|
<component name="ToolWindowManager">
|
||||||
<frame x="49" y="23" width="1260" height="709" extended-state="0" />
|
<frame x="49" y="23" width="1260" height="709" extended-state="0" />
|
||||||
<editor active="false" />
|
<editor active="true" />
|
||||||
<layout>
|
<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="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="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" />
|
<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>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</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>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -1,11 +1,11 @@
|
||||||
--
|
--
|
||||||
-- Created by IntelliJ IDEA.
|
-- Created by IntelliJ IDEA.
|
||||||
-- User: guang
|
-- User: ibuler <ibuler@qq.com>
|
||||||
-- Date: 16/9/23
|
-- Date: 16/9/22
|
||||||
-- Time: 下午4:28
|
-- Time: 下午7:13
|
||||||
-- To change this template use File | Settings | File Templates.
|
|
||||||
--
|
--
|
||||||
|
|
||||||
|
|
||||||
local _M = {}
|
local _M = {}
|
||||||
_M.version = '0.1.0'
|
_M.version = '0.1.0'
|
||||||
|
|
||||||
|
|
20
core.lua
20
core.lua
|
@ -1,9 +1,8 @@
|
||||||
--
|
--
|
||||||
-- Created by IntelliJ IDEA.
|
-- Created by IntelliJ IDEA.
|
||||||
-- User: guang
|
-- User: ibuler <ibuler@qq.com>
|
||||||
-- Date: 16/9/22
|
-- Date: 16/9/22
|
||||||
-- Time: 下午7:13
|
-- 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 then
|
||||||
if req > max_visit then
|
if req > max_visit then
|
||||||
ngx.exit(self.config.cc_deny_code)
|
if self.config.active then
|
||||||
return true
|
ngx.exit(self.config.cc_deny_code)
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
elseif req == max_visit then
|
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)
|
limit:incr(token, 1)
|
||||||
|
return true
|
||||||
else
|
else
|
||||||
limit:incr(token, 1)
|
limit:incr(token, 1)
|
||||||
end
|
end
|
||||||
|
@ -81,7 +90,6 @@ function _M.log(self, msg)
|
||||||
log_inited[self.config.log_path] = io.open(self.config.log_path, 'ab')
|
log_inited[self.config.log_path] = io.open(self.config.log_path, 'ab')
|
||||||
end
|
end
|
||||||
self.fd = log_inited[self.config.log_path]
|
self.fd = log_inited[self.config.log_path]
|
||||||
|
|
||||||
self.fd:write(msg .. '\n')
|
self.fd:write(msg .. '\n')
|
||||||
self.fd:flush()
|
self.fd:flush()
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue