Skip to content

Commit

Permalink
feat: 提供WAF页面和请求失败页面模板
Browse files Browse the repository at this point in the history
feat: 调整协议
  • Loading branch information
iamtsm committed Aug 30, 2022
1 parent 87241a4 commit 922766a
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 206 deletions.
222 changes: 21 additions & 201 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,201 +1,21 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.

"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.

"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.

"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.

"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.

"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.

"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).

"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.

"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."

"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:

(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and

(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and

(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and

(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.

You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.

9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
MIT License

Copyright (c) 2022 iamtsm

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ qq交流群 : 624214498,欢迎有兴趣的童鞋提交PR一起迭代维护,

# 开源协议

#### Apache License 2.0
MIT License

Copyright (c) 2022 iamtsm
4 changes: 3 additions & 1 deletion doc/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@ QQ : 624214498, welcome to submit PR, we will continue to update ....

# License

#### Apache License 2.0
MIT License

Copyright (c) 2022 iamtsm
24 changes: 21 additions & 3 deletions plugins/tl_ops_time_alert/time_alert.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,16 @@ local tl_ops_time_alert_consume = function( )
return
end

tlog:dbg("tl_ops_time_alert_consume list len, consume_count=",consume_count,",len=",len)
tlog:dbg("tl_ops_time_alert_consume list len, consume_count=",consume_count,",len=",len,",key=",list_cache_key .. consume_count)

-- 用于批量操作日志记录
local log_group = {}

-- 一次消费一个缓冲组
while true do
local content_json = shared:rpop(list_cache_key .. consume_count)
if not content_json then
tlog:dbg("tl_ops_time_alert_consume content json nil, ",content_json)
tlog:dbg("tl_ops_time_alert_consume content json nil, key=",list_cache_key .. consume_count)
break
end

Expand All @@ -106,10 +109,17 @@ local tl_ops_time_alert_consume = function( )
local option = content.option
local alert_type = content.alert_type
local mode = option.mode
local target = option.target

-- 日志
if mode == ALERT_MODE.log then
time_alert_log:handler(option, content)
local target_list = log_group[target]
if not target_list then
target_list = utils:new_tab(0, 50)
end
table.insert(target_list, content)

log_group[target] = target_list
end

-- 邮件
Expand All @@ -118,6 +128,14 @@ local tl_ops_time_alert_consume = function( )
end

end

-- 批量IO
for target, target_list in ipairs(log_group) do
local option = {
target = target
}
time_alert_log:handler(option, target_list)
end

-- 更新消费指针
local new_consume_count = math.min(max_list_count, consume_count + 1)
Expand Down
18 changes: 18 additions & 0 deletions web/template/balancepage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>请求失败页面</title>
</head>
<body style="background: cornsilk;">
<div style="text-align: center; width: 60%;margin-left: 20%;margin-top: 8%;">
<svg style="width: 64px; height:64px;" viewBox="0 0 1024 1024" p-id="3937">
<path d="M358.419788 392.527249c0-37.683671-30.557838-68.26503-68.256849-68.26503-37.700034 0-68.257872 30.582382-68.257872 68.26503 0 37.715373 30.557838 68.26503 68.257872 68.26503C327.86195 460.793302 358.419788 430.242622 358.419788 392.527249zM733.847287 324.262218c-37.699011 0-68.267076 30.582382-68.267076 68.26503 0 37.715373 30.568065 68.26503 68.267076 68.26503s68.256849-30.55068 68.256849-68.26503C802.104137 354.843577 771.546298 324.262218 733.847287 324.262218zM511.999489 0c-282.737469 0-511.94222 229.212932-511.94222 511.991307s229.204751 512.008693 511.94222 512.008693 511.943243-229.229295 511.943243-512.008693S794.736958 0 511.999489 0zM511.999489 972.783586c-254.462188 0-460.743192-206.313728-460.743192-460.792279 0-254.478551 206.279981-460.775917 460.743192-460.775917 254.463211 0 460.75035 206.297366 460.75035 460.775917C972.749839 766.469858 766.463722 972.783586 511.999489 972.783586zM512.066984 597.339725c-154.214767 0-204.796114 136.532106-204.796114 136.532106l51.199028 0c0 0 39.032548-85.331032 153.597085-85.331032 116.072948 0 153.597085 85.331032 153.597085 85.331032l51.198006 0C716.863098 733.871831 666.28175 597.339725 512.066984 597.339725z" p-id="3938" fill="#1296db"></path>
</svg>
<div style="margin-top: 15px;">
<div> <b>为什么会出现这个页面 ?</b> <p>1. 请求链接有误</p> <p>2. 服务器限流中</p> <p>3. 服务或已下线</p> </div>
<div> <b>如何解决 ?</b> <p>1. 请降低请求频率后重试</p> <p>2. 请检查请求链接是否正确</p> <p>3. 联系网站管理者或者客服</p> <p>4. <a href="https://github.com/iamtsm/tl-ops-manage" target="_balank">反馈误报</a></p></div>
</div>
</div>
</body>
</html>
19 changes: 19 additions & 0 deletions web/template/wafpage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>请求拦截页面</title>
</head>
<body style="background: cornsilk;">
<div style="text-align: center; width: 60%;margin-left: 20%;margin-top: 8%;">
<svg style="width: 64px; height:64px;" viewBox="0 0 1024 1024" p-id="2162" width="128" height="128">
<path d="M514.2 101.54L98.16 255.81l9.08 32.85c13.91 50.34 20.81 94.27 27.5 136.76 20.54 130.69 36.77 233.91 231.59 368.01 53.08 36.53 102.55 86.29 118.8 102.64l28.82 28.82 26.24-25.74c17.96-17.6 66.35-63.05 127.96-104.8C842.1 676.53 918.62 301.92 921.8 286.04l6.2-31.06-413.8-153.44zM792.73 467C744.26 600.12 686.78 692.07 626.5 732.9c-46.15 31.27-85.43 64.45-111.65 88.21-25.27-24.35-64.41-59.91-106.43-88.82C239.89 616.27 227.23 535.76 208.07 413.9c-5.29-33.65-11.14-70.86-20.82-111.94L514.2 180.71l327.84 121.57c-8.48 35.44-24.81 97.45-49.31 164.72z" fill="#1296db" p-id="2163"></path>
<path d="M512.24 289.05a211.932 211.932 0 0 0-14.32 0c-99.73 3.78-179.4 85.82-179.4 186.44s79.67 182.67 179.4 186.44a211.932 211.932 0 0 0 14.32 0c99.73-3.78 179.4-85.82 179.4-186.44s-79.67-182.67-179.4-186.44z m144.5 169.48h-67.46c-3.86-56.82-26.59-102.15-45.54-130.77 60.26 15.78 106.05 67.42 113 130.77zM505.11 332.09c16.66 21.71 45.37 67 50.16 126.44h-100.4c4.79-59.19 33.58-104.65 50.24-126.44z m50.17 160.36c-4.79 59.19-33.54 104.65-50.24 126.44-16.66-21.71-45.37-67-50.16-126.44h100.4zM466.4 327.76c-18.95 28.62-41.68 73.95-45.54 130.77H353.4c6.96-63.35 52.75-114.99 113-130.77z m-113 164.69h67.46c3.86 56.78 26.54 102.1 45.5 130.73-60.25-15.73-106-67.38-112.96-130.73z m190.39 130.73c18.95-28.62 41.64-73.95 45.5-130.73h67.46c-6.96 63.35-52.71 115-112.96 130.73z" fill="#1296db" p-id="2164"></path>
</svg>
<div style="margin-top: 15px;">
<div> <b>为什么会出现这个页面 ?</b> <p>1. 拦截到疑似恶意请求</p> <p>2. 请求频率过高</p> <p>3. 请求或IP被列入黑名单</p> </div>
<div> <b>如何解决 ?</b> <p>1. 请降低请求频率后重试</p> <p>2. 请检查请求是否包含非法内容</p> <p>3. 联系网站管理者或者客服</p> <p>4. <a href="https://github.com/iamtsm/tl-ops-manage" target="_balank">反馈误报</a></p></div>
</div>
</div>
</body>
</html>

0 comments on commit 922766a

Please sign in to comment.