Compare commits
1 commit
main
...
update-doc
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3e481704b9 |
30
.github/ISSUE_TEMPLATE/1feature-request.yaml
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
name: 功能建议
|
||||
# Feature request
|
||||
description: 新功能或现有能力的优化建议
|
||||
title: "[建议] "
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
提示:创建前请搜索一下是否有重复问题。一个 issue 尽量只描述一个问题。简洁、准确的描述有助于集中大家的意见,推进问题尽快解决
|
||||
# Please check for duplicate issue first.
|
||||
# 尽量描述需求的背景、原始问题,避免出现 X-Y 问题,参考: https://coolshell.cn/articles/10804.html
|
||||
- type: textarea
|
||||
id: problem
|
||||
attributes:
|
||||
label: 背景与遇到的问题
|
||||
# Background and the problem that frustrates you
|
||||
placeholder: |
|
||||
例如:我的业务有xxx特性,当我在使用xxx功能的时候,会遇到xxx情况...
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: solution
|
||||
attributes:
|
||||
label: 建议的解决方案
|
||||
# Describe the solution you'd like
|
||||
placeholder: |
|
||||
例如:建议增加xxx功能;将xxx改为xxx...
|
||||
validations:
|
||||
required: false
|
31
.github/ISSUE_TEMPLATE/2bug-report.yaml
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
name: Bug
|
||||
description: 明确的软件故障或缺陷
|
||||
# Create a report to help us improve
|
||||
title: "[Bug] "
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
提示:提问前请先搜索一下是否存在重复问题
|
||||
# Please check for duplicate issue first.
|
||||
- type: textarea
|
||||
id: Description
|
||||
attributes:
|
||||
label: 问题描述
|
||||
# Describe the bug
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: Reproduce
|
||||
attributes:
|
||||
label: 复现方法
|
||||
# To Reproduce
|
||||
placeholder: |
|
||||
1. ...
|
||||
2. ...
|
||||
- type: textarea
|
||||
id: Expected
|
||||
attributes:
|
||||
label: 期望的结果
|
||||
# Expected behavior. Descript what you expected to happen.
|
14
.github/ISSUE_TEMPLATE/3other.yaml
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
name: 其他问题与反馈
|
||||
description: 文档、部署失败等其他问题。
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
提示:创建前请先搜索一下是否存在重复问题
|
||||
# Please check for duplicate issue first.
|
||||
# 尽量描述需求的背景、原始问题,避免出现 X-Y 问题,参考: https://coolshell.cn/articles/10804.html
|
||||
# 提問的智慧: https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md
|
||||
- type: textarea
|
||||
id: content
|
||||
attributes:
|
||||
label: 反馈内容
|
45
.github/ISSUE_TEMPLATE/bug-report.yaml
vendored
|
@ -1,45 +0,0 @@
|
|||
name: Bug
|
||||
description: Report a bug
|
||||
# Create a report to help us improve
|
||||
title: "[Bug] "
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Please search the [open issues](https://github.com/chaitin/SafeLine/issues) and [discussion](https://github.com/chaitin/SafeLine/discussions) for duplicate issue first.
|
||||
The more information you share, the faster we can identify and fix the bug.
|
||||
# Please check for duplicate issue first.
|
||||
- type: textarea
|
||||
id: Description
|
||||
attributes:
|
||||
label: What happened?
|
||||
# Describe the bug
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: Reproduce
|
||||
attributes:
|
||||
label: How we reproduce?
|
||||
description: |
|
||||
Reports cannot be reproduced will Most likely be closed.
|
||||
# To Reproduce
|
||||
value: |
|
||||
1. ...
|
||||
2. ...
|
||||
3. ...
|
||||
- type: textarea
|
||||
id: Expected
|
||||
attributes:
|
||||
label: Expected behavior
|
||||
# placeholder: |
|
||||
# Descript what you expected to happen.
|
||||
# Expected behavior. Descript what you expected to happen.
|
||||
- type: textarea
|
||||
id: Errorlog
|
||||
attributes:
|
||||
label: Error log
|
||||
placeholder: |
|
||||
Paste the error logs if any.
|
||||
# Expected behavior. Descript what you expected to happen.
|
||||
|
10
.github/ISSUE_TEMPLATE/config.yml
vendored
|
@ -1,11 +1,5 @@
|
|||
blank_issues_enabled: false
|
||||
blank_issues_enabled: Ture
|
||||
contact_links:
|
||||
- name: Discord
|
||||
url: https://discord.gg/wyshSVuvxC
|
||||
about: Ask questions and discuss with other SafeLine users in real time.
|
||||
- name: Home page 官网
|
||||
url: https://waf.chaitin.com/
|
||||
about: Get feature descriptions, technical documentation and more information. 获取功能描述、技术文档和更多信息。
|
||||
- name: 绕过反馈
|
||||
url: https://stack.chaitin.com/security-challenge/safeline/index
|
||||
about: Waf 绕过可在 CT Stack 安全挑战赛提交细节
|
||||
about: Waf 绕过可在 CT Stack 安全挑战赛提交细节
|
||||
|
|
28
.github/ISSUE_TEMPLATE/feature-request.yaml
vendored
|
@ -1,28 +0,0 @@
|
|||
name: Suggestion
|
||||
# Feature request
|
||||
description: New feature or improvements.
|
||||
title: "[Suggestion] "
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Please search the [open issues](https://github.com/chaitin/SafeLine/issues) and [discussion](https://github.com/chaitin/SafeLine/discussions) for duplicate issue first.
|
||||
Please rise only one suggestion in an issue.
|
||||
- type: textarea
|
||||
id: solution
|
||||
attributes:
|
||||
label: What would you like to be added or improved?
|
||||
# Describe the solution you'd like
|
||||
# placeholder: |
|
||||
#
|
||||
- type: textarea
|
||||
id: problem
|
||||
attributes:
|
||||
label: Why is it needed?
|
||||
# Background and the specific problem that frustrates you
|
||||
placeholder: |
|
||||
Background and the problem that frustrates you
|
||||
|
||||
validations:
|
||||
required: true
|
12
.github/ISSUE_TEMPLATE/other.yaml
vendored
|
@ -1,12 +0,0 @@
|
|||
name: Other
|
||||
description: Other issues such as Doc
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Please search the [open issues](https://github.com/chaitin/SafeLine/issues) and [discussion](https://github.com/chaitin/SafeLine/discussions) for duplicate issue first.
|
||||
Please rise only one suggestion in an issue.
|
||||
- type: textarea
|
||||
id: content
|
||||
attributes:
|
||||
label: Content
|
5
.gitignore
vendored
|
@ -1,7 +1,2 @@
|
|||
*.Zone.Identifier
|
||||
.DS_Store
|
||||
*.zip
|
||||
*.tar
|
||||
*.tar.gz
|
||||
build.sh
|
||||
compose.yml
|
||||
|
|
8
.gitmodules
vendored
|
@ -1,5 +1,9 @@
|
|||
[submodule "blazehttp"]
|
||||
path = blazehttp
|
||||
url = https://github.com/chaitin/blazehttp
|
||||
|
||||
|
||||
[submodule "lua-resty-t1k"]
|
||||
path = lua-resty-t1k
|
||||
url = https://github.com/chaitin/lua-resty-t1k
|
||||
[submodule "plugins"]
|
||||
path = plugins
|
||||
url = https://github.com/chaitin/safeline-open-platform
|
||||
|
|
283
CHANGELOG.md
Normal file
|
@ -0,0 +1,283 @@
|
|||
SAFELINE-CE CHANGELOG
|
||||
===
|
||||
|
||||
## [3.0.1] - 2023-08-18
|
||||
|
||||
- 更新底层语义分析引擎,加强基础防护能力
|
||||
- 修复站点详情中,不同域名的资源会重复记录问题
|
||||
- 修复攻击事件有小概率时间排序错误的问题
|
||||
- 修复关闭再打开频率限制时,配置不会重置到默认值的问题
|
||||
- 修复首次创建站点且配置 SSL 端口的情况下提示“端口被占用”的问题
|
||||
|
||||
## [3.0.0] - 2023-08-18
|
||||
|
||||
### 新增
|
||||
|
||||
- 新增站点详情,能自动从流量中记录网站资源,一览资源的存活、访问情况
|
||||
- PS. 考虑机器资源消耗问题,当前版本每个站点下最多记录 250 个资源
|
||||
- 站点支持输入多个域名、端口([#162](https://github.com/chaitin/safeline/issues/162))
|
||||
- 通用配置中新增 “站点通用配置”,支持一键开启:
|
||||
- 强制 HTTPS([#67](https://github.com/chaitin/safeline/issues/67))
|
||||
- 使用 HTTP/2([#161](https://github.com/chaitin/safeline/issues/161))
|
||||
- 监听 IPv6([#166](https://github.com/chaitin/safeline/issues/166))
|
||||
- 传递客户端连接的 Host 和协议,方便后续服务器处理
|
||||
|
||||
### 优化
|
||||
|
||||
- 优化限频配置的默认值
|
||||
- 增加 HTTP 497 错误重定向。当以 HTTP 协议访问 HTTPS 端口时,将重定向到 HTTPS([#186](https://github.com/chaitin/safeline/issues/186))
|
||||
- 默认拒绝 IP 和其他非指定域名的访问。如果需要通过 IP 访问站点,可以给站点添加一个 "*" 域名([#58](https://github.com/chaitin/safeline/issues/58))
|
||||
- 优化若干 UI 交互细节和文字提示
|
||||
|
||||
## [2.6.0] - 2023-08-10
|
||||
|
||||
### 新增
|
||||
|
||||
- 新增高频攻击封禁,即多次攻击后自动封禁 IP ([#29](https://github.com/chaitin/safeline/issues/29))
|
||||
- 频率限制日志显示封禁 IP 的地理位置 ([#198](https://github.com/chaitin/safeline/issues/198))
|
||||
|
||||
### 优化
|
||||
|
||||
- 攻击检测的原始日志支持搜索端口 ([#193](https://github.com/chaitin/safeline/issues/193))
|
||||
- 修复编辑站点后,“维护模式” 会失效的问题
|
||||
- 修改默认占用的网段,避免跟腾讯云默认网段冲突 ([#40](https://github.com/chaitin/safeline/issues/40))
|
||||
- 优化安装脚本 ([#194](https://github.com/chaitin/safeline/issues/194)),优化界面一些 UI 交互、错误提示
|
||||
|
||||
## [2.5.0] - 2023-08-03
|
||||
|
||||
### 新增
|
||||
|
||||
- 请求频率限制([#29](https://github.com/chaitin/safeline/issues/29))
|
||||
|
||||
### 优化
|
||||
|
||||
- 支持筛选攻击检测日志的 ID([#74](https://github.com/chaitin/safeline/issues/74)),优化筛选的交互
|
||||
- 证书支持 .cer 格式([#181](https://github.com/chaitin/safeline/issues/181))
|
||||
- 优化人机校验页面,适配移动端([#184](https://github.com/chaitin/safeline/issues/184))
|
||||
- 界面增加一些配置提示:添加站点时 “域名” 的格式、黑白名单/人机验证中匹配条件的生效逻辑
|
||||
|
||||
## [2.4.0] - 2023-07-27
|
||||
|
||||
### 新增
|
||||
|
||||
- IP 组支持注释 [#143](https://github.com/chaitin/safeline/issues/143)
|
||||
|
||||
### 优化
|
||||
|
||||
- 优化编辑 IP 组和相关规则时的性能
|
||||
- 优化一些界面 UI 交互细节
|
||||
|
||||
## [2.3.2] - 2023-07-24
|
||||
|
||||
### 修复
|
||||
- 修复了攻击事件 - 原始日志中,请求报文没有格式化的问题
|
||||
- 优化了一些已知问题
|
||||
|
||||
## [2.3.1] - 2023-07-20
|
||||
|
||||
### 新增
|
||||
|
||||
- 检测日志升级为**攻击事件** ,自动聚合同一攻击 IP 短时间内的所有攻击日志,方便管理员进行监控和处置
|
||||
- 日志支持按时间([#102](https://github.com/chaitin/safeline/issues/102))、动作筛选
|
||||
|
||||
### 修复
|
||||
|
||||
- 修复添加/编辑站点时,上传证书处未翻译中文的问题
|
||||
- 修复数据统计中,“访问来源地区” 小概率出现的部分地区显示不正确的问题
|
||||
|
||||
## [2.2.0] - 2023-07-14
|
||||
|
||||
### 新增
|
||||
|
||||
- IP 组中新增长亭社区恶意 IP 情报,内容来自社区版共享的攻击 IP,每日自动更新
|
||||
|
||||
### 优化
|
||||
|
||||
- 升级核心检测引擎,修复一些绕过和误报
|
||||
- 管理界面增加浏览器版本检查,如果版本过旧,会提示升级浏览器
|
||||
- 优化一些界面的 UI 交互细节
|
||||
- 修复一些中英文翻译的问题
|
||||
|
||||
## [2.1.2] - 2023-07-07
|
||||
|
||||
- 修复了日志详情中防护策略模块没有翻译的问题
|
||||
|
||||
## [2.1.1] - 2023-07-06
|
||||
|
||||
- 修复了防护策略模块没有翻译的问题
|
||||
|
||||
## [2.1.0] - 2023-07-06
|
||||
|
||||
### 新增
|
||||
|
||||
- 添加/编辑站点时,自动检查端口占用情况,避免保存后配置不生效
|
||||
- 支持自定义站点的 nginx conf,详情可见[官网文档](https://waf-ce.chaitin.cn/posts/faq_other#%E8%87%AA%E5%AE%9A%E4%B9%89%E7%AB%99%E7%82%B9-nginx-conf)
|
||||
- [站点列表支持按域名、端口或访问量进行排序](https://github.com/chaitin/safeline/issues/14)
|
||||
- [绑定 TOTP 密钥时,支持直接复制密钥;登录时的 6 位动态密码输入框,支持粘贴](https://github.com/chaitin/safeline/issues/30)
|
||||
|
||||
### 优化
|
||||
|
||||
- [黑白名单和人机验证列表中,可以鼠标悬浮查看 “复合条件” 的具体内容](https://github.com/chaitin/safeline/issues/120)
|
||||
- 修复人机验证列表中,“源 IP 不属于 IP 组” 的规则,IP 组名称显示成了 id 的问题
|
||||
- [优化人机验证启用/禁用交互](https://github.com/chaitin/safeline/issues/130)
|
||||
- [优化描述文字](https://github.com/chaitin/safeline/issues/122)
|
||||
- 优化一些界面 UI 交互、提示文字
|
||||
- 修复一些已知问题
|
||||
|
||||
## [2.0.1] - 2023-06-30
|
||||
|
||||
- 调整了人机验证的策略,降低误拦的情况
|
||||
- 修复了人机验证启动/禁用规则不会自动刷新状态的问题
|
||||
- 修复其他一些已知问题
|
||||
|
||||
## [2.0.0] - 2023-06-29
|
||||
|
||||
### 新增
|
||||
|
||||
- 人机验证
|
||||
- 支持嵌入式部署,可以通过 [t1k 协议](https://github.com/chaitin/lua-resty-t1k) 直接把流量转发到雷池进行检测
|
||||
- 把日志详情中的源 IP 加入到 IP 组时,支持调整 IP 为任意 IP 或网段
|
||||
|
||||
### 优化
|
||||
- 日志列表按照时间和 ID 排序,防止出现小范围的时间乱序
|
||||
- 转发流量时,自动设置请求头 X-Forwarded-Proto,适配更多代理场景
|
||||
- 优化界面 UI,修复其他一些已知问题
|
||||
|
||||
## [1.10.0] - 2023-06-21
|
||||
|
||||
### 新增
|
||||
|
||||
- 防护站点新增 “运行模式”,可以一键将站点设为 观察 或 维护 模式了
|
||||
|
||||
### 优化
|
||||
|
||||
- 修复了站点列表没有分页器的问题
|
||||
- 修复了窗口水平滚动时导航栏会错位的问题
|
||||
- 修复了黑白名单配置 “不属于 IP 组” 的条件时,列表显示组 ID,而未显示组名称的问题
|
||||
- 优化了界面的 UI 与交互
|
||||
|
||||
## [1.9.0] - 2023-06-16
|
||||
|
||||
### 新增
|
||||
|
||||
- 界面 UI 改造,信息层级更清晰
|
||||
- 黑白名单支持添加 源 IP - 不属于 IP 组 的条件
|
||||
|
||||
### 优化
|
||||
|
||||
- 检测日志的路由进一步完善
|
||||
- 数据统计页面更加紧凑,现在可以在 1920*1080 的屏幕上完全显示了
|
||||
- 黑白名单的展示优化
|
||||
- 修复 通用配置-防护模块配置 中,“批量配置为” 按钮有时候不生效的问题
|
||||
- 修复一些已知问题
|
||||
|
||||
## [1.8.2] - 2023-06-12
|
||||
|
||||
- 修复了「30 天访问情况」和「30 天拦截情况」显示相同数据的问题
|
||||
|
||||
## [1.8.1] - 2023-06-09
|
||||
|
||||
- 修复了「全部请求」和「仅拦截」数据一样的问题
|
||||
|
||||
## [1.8.0] - 2023-06-09
|
||||
|
||||
### 新增
|
||||
|
||||
- 数据统计页面增加访问来源地区、流量统计,更好把控网站运营情况
|
||||
|
||||
### 优化
|
||||
|
||||
- 更新语义引擎版本,优化了一大批检测逻辑,降低误报
|
||||
- 优化了部分操作提示信息:
|
||||
- IP 组正在使用时,无法被删除的提示
|
||||
- 未创建 IP 组时,在黑白名单中无法选择属于 IP 组的提示
|
||||
- 添加站点时,域名格式错误的提示
|
||||
|
||||
## [1.7.1] - 2023-06-05
|
||||
|
||||
### 修复
|
||||
- 部分情况下无法打开日志详情页面的问题
|
||||
- 部分情况下页面查询数量只有 10 条的问题
|
||||
|
||||
## [1.7.0] - 2023-06-01
|
||||
|
||||
### 新增
|
||||
- 新增 “IP 组” 功能,可以快速配置大量 IP 的黑/白名单了
|
||||
- 防护策略增加 “仅观察” 配置
|
||||
- 防护策略增加 “批量配置为” 按钮,可以快速切换所有模块的防护策略
|
||||
|
||||
### 优化
|
||||
- 自定义规则列表增加翻页
|
||||
- 优化规则生效顺序,现在会优先执行完所有白名单,再执行黑名单
|
||||
|
||||
## [1.6.0] - 2023-05-25
|
||||
|
||||
### 新增
|
||||
- 自定义规则支持匹配 Header 和 Body
|
||||
- 检测日志支持按域名搜索
|
||||
- 支持命令行清理检测日志和统计信息
|
||||
|
||||
## [1.5.1] - 2023-05-18
|
||||
|
||||
- 修复了自定义规则切换白名单之后,无法创建/编辑的问题
|
||||
|
||||
## [1.5.0] - 2023-05-18
|
||||
|
||||
### 新增
|
||||
- 支持 i18n
|
||||
- 数据统计新增 “今日请求错误情况”
|
||||
- 检测日志的筛选条件现在会显示在 URL,方便保存
|
||||
|
||||
### 优化
|
||||
- 修复自定义规则的编辑表单,有时候会丢失编辑中数据的问题
|
||||
- 修复 Safari 浏览器上的一些显示问题
|
||||
- 修复 Payload 中存在非 Unicode 编码时,检测日志会入库失败的问题(不影响拦截)
|
||||
- 修复新增的 “HTTP 请求走私” 攻击类型会被错误地展示成 “未知” 攻击类型的问题
|
||||
|
||||
## [1.4.0] - 2023-05-12
|
||||
|
||||
### 新增
|
||||
- 自定义规则支持匹配域名
|
||||
- 支持在一条自定义规则内,设置多个匹配条件
|
||||
- 站点列表新增 “今日访问 / 拦截量”
|
||||
|
||||
### 优化
|
||||
- 优化交互和提示文案、修复已知问题
|
||||
|
||||
## [1.3.0] - 2023-05-05
|
||||
|
||||
### 新增
|
||||
- 支持按照源 IP、攻击类型、URL 筛选检测日志
|
||||
|
||||
### 修复
|
||||
- 修复 dashboard 在部分低版本浏览器下的兼容问题
|
||||
- 修复按源 IP 添加自定义规则时,添加不了 /8 和更大的网段的问题
|
||||
|
||||
## [1.2.0] - 2023-04-27
|
||||
|
||||
### 新增
|
||||
- 新增了数据统计页面,可以直观的看到流量大小
|
||||
- 支持配置源 IP 提取方式,解决了源 IP 获取不对的问题
|
||||
- 支持自定义检测策略,可以动态调整检测引擎
|
||||
|
||||
## [1.1.0] - 2023-04-20
|
||||
|
||||
### 新增
|
||||
- 支持根据 IP 和 URL 特征配置黑白名单
|
||||
- 默认开启高防模式
|
||||
|
||||
### 优化
|
||||
- 支持在日志详情中展示响应报文
|
||||
- 服务器时间不准导致 TOTP 无法登录时增加了提示语
|
||||
- 修复了上游服务器填 HTTPS 时端口解析不正确的问题
|
||||
- 优化了 SSL 上传逻辑,体验更好
|
||||
|
||||
## [1.0.0] - 2023-04-13
|
||||
|
||||
- 站点配置
|
||||
|
||||
## [0.9.0] - 2023-03-20
|
||||
|
||||
- OTP 登录
|
||||
- 攻击检测日志
|
||||
- 默认防护策略
|
182
FAQ.md
Normal file
|
@ -0,0 +1,182 @@
|
|||
# FAQ
|
||||
|
||||
## docker compose or docker-compose?
|
||||
|
||||
tl;dr The `docker compose` (with a space), aka v2, is a newer project to migrate compose to Go. The original python project `docker-compose`, aka v1 has now been deprecated.
|
||||
|
||||
refers also: [https://stackoverflow.com/questions/66514436/difference-between-docker-compose-and-docker-compose](https://stackoverflow.com/a/66516826)
|
||||
|
||||
## Setup and Deploy
|
||||
|
||||
### What specs should I deploy SafeLine to protect my web services? / Minimum hardware specs requirements
|
||||
|
||||
1C1G is ok for running docker containers of SafeLine. But the specific hardware specs depends on the traffic characteristics your services, such as qps, network io and so on. For now, no detailed datasheet is provided for references.
|
||||
|
||||
### ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
|
||||
|
||||
As shown, you shall start docker first. Try `systemctl start docker`.
|
||||
|
||||
### docker not found, unable to deploy
|
||||
|
||||
As shown, you shall install `docker` first. Try `curl -fLsS https://get.docker.com/ | sh` or [Install Docker Engine](https://docs.docker.com/engine/install/)
|
||||
|
||||
### docker compose v2 not found, unable to deploy
|
||||
|
||||
As shown, you shall install `docker compose v2`. Try `[Install Docker Compose](https://docs.docker.com/compose/install/)`
|
||||
|
||||
### safeline-postgres: Operation not permitted
|
||||
|
||||
`docker logs -f safeline-postgres` with error `Operation not permitted`
|
||||
|
||||
Upgrade your docker engine and retry.
|
||||
|
||||
### safeline-tengine: Address already in use
|
||||
|
||||
`docker logs -f safeline-tengine` with error `Address already in use`
|
||||
|
||||
Port conflicts. Based on the port number in the error message, troubleshoot which service is occupying it and handle the conflict manually.
|
||||
|
||||
### How to customize safeline-ce installation path?
|
||||
|
||||
With the latest `compose.yaml`, you can manually modify the `SAFELINE_DIR` variable in the `.env` file after `setup.sh`.
|
||||
|
||||
### How to change the default port of SafeLine management, as for `:9443` is already in used by some other services?
|
||||
|
||||
With the latest `compose.yaml`, you can add `MGT_PORT` variable in `.env` file.
|
||||
|
||||
## Login
|
||||
|
||||
### TOTP login failed with correct code
|
||||
|
||||
TOTP is calculated and verified according to time. So check your server time.
|
||||
|
||||
# 常见问题
|
||||
|
||||
## docker compose 还是 docker-compose?
|
||||
|
||||
`docker compose`(带空格)是 V2 版本,Go 写的。`docker-compose` 是 V1 版本,Python 写的,已经不维护了。
|
||||
|
||||
我们推荐使用 V2 版本的 `docker compose`,V1 可能会有兼容性等问题。
|
||||
|
||||
[docker/compose](https://github.com/docker/compose/) 中提到:
|
||||
|
||||
> For a smooth transition from legacy docker-compose 1.xx, please consider installing [compose-switch](https://github.com/docker/compose-switch) to translate `docker-compose ...` commands into Compose V2's `docker compose ....` . Also check V2's `--compatibility` flag.
|
||||
|
||||
其他参考:[https://stackoverflow.com/questions/66514436/difference-between-docker-compose-and-docker-compose](https://stackoverflow.com/a/66516826)
|
||||
|
||||
## 安装部署
|
||||
|
||||
### 机器运行的最低配置
|
||||
|
||||
最低 1C1G 能运行,具体需要多少配置取决于你的业务流量特征,比如 QPS、网络吞吐等等,暂时没有详细的 datasheet 性能参考。
|
||||
|
||||
### 镜像下载缓慢甚至连接超时
|
||||
|
||||
这个是因为 docker hub 默认使用位于美西节点拉取镜像,可以自行配置国内镜像加速源
|
||||
|
||||
### ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
|
||||
|
||||
如描述,你需要启动 docker daemon 才能执行相关的命令。尝试 `systemctl start docker`
|
||||
|
||||
As shown, you shall start docker first. Try `systemctl start docker`.
|
||||
|
||||
### docker not found, unable to deploy
|
||||
|
||||
如描述,你需要安装 `docker`。尝试 `curl -fLsS https://get.docker.com/ | sh` 或者 [Install Docker Engine](https://docs.docker.com/engine/install/)
|
||||
|
||||
### docker compose v2 not found, unable to deploy
|
||||
|
||||
如描述,你需要安装 `docker compose v2`。尝试 `[Install Docker Compose](https://docs.docker.com/compose/install/)`
|
||||
|
||||
### safeline-tengine 出现 Address already in use
|
||||
|
||||
`docker logs -f safeline-tengine` 容器日志中看到 `Address already in use` 信息。
|
||||
|
||||
端口冲突,根据报错信息中的端口号,排查是哪个服务占用了,手动处理冲突。
|
||||
|
||||
### safeline-postgres 出现 Operation not permitted
|
||||
|
||||
`docker logs -f safeline-postgres` 容器日志中看到 `Operation not permitted` 报错
|
||||
|
||||
可能是您的 docker 版本过低,升级 docker 到最新版本尝试一下。
|
||||
|
||||
### 如何自定义 SafeLine 安装路径?
|
||||
|
||||
基于最新的 `compose.yaml`,你可以手动修改 `.env` 文件的 `SAFELINE_DIR` 变量。
|
||||
|
||||
### 如何修改 SafeLine 后台管理的默认端口?本机 `:9443` 已经被别的服务占用了
|
||||
|
||||
基于最新的 `compose.yaml`,你可以手动添加 `MGT_PORT` 变量到 `.env` 文件。
|
||||
|
||||
## 登录问题
|
||||
|
||||
### OTP 认证码登录失败
|
||||
|
||||
TOTP 是基于时间生成和校验的,请检查你的服务器时间是否同步。
|
||||
|
||||
## 站点配置问题
|
||||
|
||||
在没有 SafeLine 的时候,假设小明的域名 `xiaoming.com` 通过 DNS 解析到自己主机 `192.168.1.111`,上面在 `:8888` 端口监听了自己的服务(网站/博客/靶场)等等。
|
||||
|
||||
小明通过 `http://xiaoming.com:8888` 或者 `192.168.1.111:8888` 来访问自己的服务。
|
||||
|
||||
### 我该如何配置?/ 域名填什么?/ 端口怎么写?/ 上游服务器是什么?
|
||||
|
||||
目前社区版 SafeLine 支持的是反向代理的方式接入站点,也就是类似于一台 nginx 服务。这时候小明需要做的就是让流量先抵达 SafeLine,然后经过 SafeLine 检测之后,再转发给自己原先的业务。
|
||||
|
||||
小明只需要按照如下方式创建站点即可:
|
||||
- `xiaoming.com` 填入页面的「域名」
|
||||
- `:7777` 填入「端口」;或者别的任意非 `:8888`和 `:9443`(被 SafeLine 后台管理页面占用)端口
|
||||
- `http://192.168.1.111:8888` 填入「上游服务器」
|
||||
|
||||
创建之后,就可以通过 `http://xiaoming.com:7777` 或者 `192.168.1.111:7777` 访问自己的服务了,这时候请求到 `http://xiaoming.com:7777` 的流量都会被 SafeLine 检测。经过 SafeLine 过滤后,安全的流量会被透传到原先的 `:8888` 业务服务器(即上游服务器)。
|
||||
|
||||
**注:直接访问 `http://xiaoming.com:8888` 的流量,仍然不会被 SafeLine 检测,因为流量并没有经过 SafeLine,而是绕过 SafeLine 直接打到了上游服务器上**
|
||||
|
||||
**如果按照如上配置,还是无法成功访问到我的上游服务器,接着往下看,尝试逐项进行问题排查。**
|
||||
|
||||
## 配置完成之后,还是没有成功访问到上游服务器
|
||||
|
||||
下面例子都还按照上面小明的环境情况介绍。
|
||||
|
||||
#### 1. netstat/ss/lsof 查看端口占用情况
|
||||
|
||||
先确认下 `0.0.0.0:7777` 端口是否有服务在监听。SafeLine 使用 Tengine 来作为代理服务,所以正常来说,应该有一个 nginx 进程监听在 `:7777` 端口。如果没有的话,可能是 SafeLine 的问题,请通过社群或者 Github issue 提交反馈。
|
||||
|
||||
如果有的话,继续往下排查。
|
||||
|
||||
#### 2. 是否是被非 SafeLine 的 nginx 监听
|
||||
|
||||
基于第一步,已经能确认 `:7777` 是被某个 nginx 进程监听了,但是并不能确认是被 SafeLine 自己的 nginx 监听。排查是否自己原先有 nginx conf 中配置了 server 监听 `:7777`。如果有的话,手动解决冲突。要么修改自己原先的 nginx conf,要么修改 SafeLine 的站点配置。
|
||||
|
||||
也可以直接通过 `docker logs -f safeline-tengine` 确认 SafeLine 是否有 nginx 报错说端口冲突。
|
||||
|
||||
*常见的情况就是自己原先有一个服务监听在 `:80`,SafeLine 上配置了站点也监听 `:80` 端口,就产生了冲突。*
|
||||
|
||||
如果没有的话,继续往下排查。
|
||||
|
||||
#### 3. 是否被防火墙拦截
|
||||
|
||||
有操作系统本身的防火墙,还有可能是云服务商的防火墙。根据实际情况逐项排查,配置开放端口的 TCP 访问。
|
||||
|
||||
出现如下情况,可能就是被中间某防火墙拦截了:
|
||||
1. 在 `192.168.1.111` 上 curl -vv `127.0.0.1:7777` 能访问到业务,有 HTTP 返回码。
|
||||
2. 在本机 curl -vv `192.168.1.111:7777` 不通,没有 HTTP 响应;`telnet 192.168.1.111 7777` 返回 `Unable to connect to remote host: Connection refused`
|
||||
|
||||
#### 4. SafeLine 是否能访问到上游服务器
|
||||
|
||||
小明的情况是 SafeLine 和业务在同一台机器,一般不会有不同机器之间的网络问题,但是也建议在 SafeLine 部署的机器上测试一下。如果是两台机器的情况下,需要考虑是否互相之间能正常通信。
|
||||
|
||||
直接 `curl -H "Host: <SafeLine-IP>" -vv http://xiaoming.com:8888` 测一下是否能访问到。如果不行,需要自行排查为什么 SafeLine 的机器没法访问到。
|
||||
|
||||
注:这里需要 -H 指定 Host `Host: <SafeLine-IP>` 进行连通性测试。收到比较多的反馈,在 WAF 上直接配置上游服务器为 HTTPS 的域名,比如 `https://xiaoming.com`。实际场景是希望先测试 WAF 能力正常后再把域名解析切到 WAF 进行上线。这种本地测试的场景,需要修改本机 host,把 `xiaoming.com` 解析到 `SafeLine-IP`,否则可能会无法成功代理。因为 SafeLine 向上游服务器转发时,代理请求中的 Host 使用的是原始 HTTP 请求中的 Host,此时需要自行判断上游业务服务器能够正确处理该代理请求(例如上游业务服务器在 Host 没有匹配自己的站点名称时,是否能够处理)
|
||||
|
||||
#### 5. 其他情况
|
||||
|
||||
如果执行了 1-4:
|
||||
1. 确认有 nginx 进程监听了 SafeLine 机器的 `0.0.0.0:7777` 端口
|
||||
2. 确认 SafeLine tengine 无端口冲突报错
|
||||
3. 确认主机和云服务商的防火墙都没有限制 `:7777` 端口的 TCP 访问
|
||||
4. 确认在 SafeLine 上能访问到「上游服务器」
|
||||
|
||||
问题还是没有解决,可能是 SafeLine 产品的问题,请通过社群或者 Github issue 提交反馈。
|
699
LICENSE.md
|
@ -1,674 +1,59 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
## 软件许可证
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
本许可证(以下简称“许可证”)适用于您所获取的软件(以下简称“软件”),请您在使用本软件前仔细阅读以下条款。使用本软件表示您同意并接受本许可证的条款。
|
||||
|
||||
Preamble
|
||||
1. **版权声明**
|
||||
本产品的所有代码、镜像、文件其版权均属于北京长亭科技有限公司。
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
2. **使用许可**
|
||||
在遵守本许可证条款的前提下,您有权在单一设备上安装、运行本软件,仅用于个人非商业目的。
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
3. **禁止事项**
|
||||
您不得对本软件进行以下行为:
|
||||
a) 破解、逆向工程、反编译、反汇编等行为;
|
||||
b) 二次包装、修改、改编、复制、翻译、再许可或制作衍生作品;
|
||||
c) 用于商业用途或任何盈利活动;
|
||||
d) 未经授权的传播、分发、出售、出租本软件;
|
||||
e) 将本软件与侵犯他人知识产权或违反法律法规的内容、行为结合。
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
4. **保留权利**
|
||||
本软件的版权归原作者所有,除本许可证明确授权外,所有其他权利均由原作者保留。未经原作者明确授权,您不得行使本许可证未明确授权的其他权利。如超出授权使用,原作者保留追究法律责任的权利。
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
5. **免责声明**
|
||||
本软件按“现状”提供,不提供任何形式的保证,包括但不限于对适销性、适用于特定用途、无侵权等方面的保证。原作者对于因使用本软件而造成的任何损失、损害、诉讼等不承担责任。
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
6. **终止条款**
|
||||
本许可证自您接受之日起生效,直至终止。如您未遵守本许可证的任何条款,原作者有权随时终止本许可证。一旦许可证终止,您必须停止使用本软件,并销毁您拥有或控制的所有副本。
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
7. **适用法律与争议解决**
|
||||
本许可证受原作者所在国家或司法管辖区法律的约束并依据其解释。任何因本许可证引起的或与其相关的争议应通过协商解决。如协商无果,任何一方均可将争议提交原作者所在国家或司法管辖区的有管辖权的法院解决。
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
## License
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
This License (hereinafter referred to as "License") applies to the software you have obtained (hereinafter referred to as "Software"). Please read the following terms carefully before using the Software. Using the Software indicates your agreement and acceptance of the terms of this License.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
1. **Copyright Notice**
|
||||
All codes, images, and files of this product are copyrighted by Beijing Chaitin Future Technology Co.,Ltd
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
2. **Usage Permission**
|
||||
Subject to compliance with the terms of this License, you are granted the right to install and run the Software on a single device for personal non-commercial purposes only.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
3. **Prohibitions**
|
||||
You shall not engage in the following activities in relation to the Software:
|
||||
a) Cracking, reverse engineering, decompiling, disassembling, or other similar actions;
|
||||
b) Repackaging, modifying, adapting, copying, translating, sublicensing, or creating derivative works;
|
||||
c) Using for commercial purposes or any profit-making activities;
|
||||
d) Unauthorized dissemination, distribution, sale, or rental of the Software;
|
||||
e) Combining the Software with content or actions that infringe upon the intellectual property rights of others or violate laws and regulations.
|
||||
|
||||
0. Definitions.
|
||||
4. **Reservation of Rights**
|
||||
The copyright of the Software belongs to the original author. All other rights not expressly granted in this License are reserved by the original author. You may not exercise any other rights not expressly granted in this License without the explicit authorization of the original author.If used beyond the scope of the authorization, the original author reserves the right to pursue legal liability.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
5. **Disclaimers**
|
||||
The Software is provided "as is" without any warranties of any kind, including but not limited to warranties of merchantability, fitness for a particular purpose, or non-infringement. The original author shall not be liable for any loss, damage, litigation, or any other consequences resulting from the use of the Software.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
6. **Termination**
|
||||
This License shall be effective upon your acceptance and shall continue in effect until terminated. The original author reserves the right to terminate this License at any time if you fail to comply with any of the terms and conditions of this License. Upon termination, you must cease all use of the Software and destroy all copies in your possession or control.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
7. **Applicable Law and Dispute Resolution**
|
||||
This License shall be governed by and construed in accordance with the laws of the country or jurisdiction where the original author is located. Any disputes arising from or in connection with this License shall be resolved through negotiation. In case no settlement can be reached through negotiation, either party may submit the dispute to the competent court of the country or jurisdiction where the original author is located.
|
218
README.md
|
@ -1,128 +1,118 @@
|
|||
<p align="center">
|
||||
<img src="/images/banner.png" width="400" />
|
||||
<img src="https://waf-ce.chaitin.cn/images/403.svg" width="120">
|
||||
</p>
|
||||
<h1 align="center">雷池 - 广受好评的社区 WAF</h1>
|
||||
<br>
|
||||
<p align="center">
|
||||
<img src="https://img.shields.io/badge/SafeLine-BEST_WAF-blue">
|
||||
<img src="https://img.shields.io/github/release/chaitin/safeline.svg?color=blue" />
|
||||
<img src="https://img.shields.io/github/release-date/chaitin/safeline.svg?color=blue&label=update" />
|
||||
<img src="https://img.shields.io/docker/v/chaitin/safeline-mgt-api?color=blue">
|
||||
<img src="https://img.shields.io/github/stars/chaitin/safeline?style=social">
|
||||
</p>
|
||||
|
||||
<h4 align="center">
|
||||
SafeLine - Make your web apps secure
|
||||
</h4>
|
||||
|
||||
<p align="center">
|
||||
<a target="_blank" href="https://waf.chaitin.com/">🏠 Website</a> |
|
||||
<a target="_blank" href="https://docs.waf.chaitin.com/">📖 Docs</a> |
|
||||
<a target="_blank" href="https://demo.waf.chaitin.com:9443/">🔍 Live Demo</a> |
|
||||
<a target="_blank" href="https://discord.gg/SVnZGzHFvn">🙋♂️ Discord</a> |
|
||||
<a target="_blank" href="/README_CN.md">中文版</a>
|
||||
<a href="https://waf-ce.chaitin.cn/">官方网站</a> |
|
||||
<a href="https://demo.waf-ce.chaitin.cn:9443/dashboard">在线 Demo</a> |
|
||||
<a href="https://waf-ce.chaitin.cn/posts/guide_introduction">技术文档</a> |
|
||||
<a href="README_EN.md">For English</a>
|
||||
</p>
|
||||
|
||||
## 👋 INTRODUCTION
|
||||
一款足够简单、足够好用、足够强的免费 WAF。基于业界领先的语义引擎检测技术,作为反向代理接入,保护你的网站不受黑客攻击。
|
||||
|
||||
SafeLine is a self-hosted **`WAF(Web Application Firewall)`** to protect your web apps from attacks and exploits.
|
||||
核心检测能力由智能语义分析算法驱动,专为社区而生,不让黑客越雷池半步。
|
||||
|
||||
A web application firewall helps protect web apps by filtering and monitoring HTTP traffic between a web application and the Internet. It typically protects web apps from attacks such as `SQL injection`, `XSS`, `code injection`, `os command injection`, `CRLF injection`, `ldap injection`, `xpath injection`, `RCE`, `XXE`, `SSRF`, `path traversal`, `backdoor`, `bruteforce`, `http-flood`, `bot abused`, among others.
|
||||
<img src="https://waf-ce.chaitin.cn/images/album/0.png" />
|
||||
|
||||
#### 💡 How It Works
|
||||
|
||||
<img src="/images/how-it-works.png" width="800" />
|
||||
|
||||
By deploying a WAF in front of a web application, a shield is placed between the web application and the Internet. While a proxy server protects a client machine’s identity by using an intermediary, a WAF is a type of reverse-proxy, protecting the server from exposure by having clients pass through the WAF before reaching the server.
|
||||
|
||||
A WAF protects your web apps by filtering, monitoring, and blocking any malicious HTTP/S traffic traveling to the web application, and prevents any unauthorized data from leaving the app. It does this by adhering to a set of policies that help determine what traffic is malicious and what traffic is safe. Just as a proxy server acts as an intermediary to protect the identity of a client, a WAF operates in similar fashion but acting as an reverse proxy intermediary that protects the web app server from a potentially malicious client.
|
||||
|
||||
its core capabilities include:
|
||||
|
||||
- Defenses for web attacks
|
||||
- Proactive bot abused defense
|
||||
- HTML & JS code encryption
|
||||
- IP-based rate limiting
|
||||
- Web Access Control List
|
||||
|
||||
#### ⚡️ Screenshots
|
||||
|
||||
| <img src="./images/screenshot-1.png" width=370 /> | <img src="./images/screenshot-2.png" width=370 /> |
|
||||
| ------------------------------------------------- | ------------------------------------------------- |
|
||||
| <img src="./images/screenshot-3.png" width=370 /> | <img src="./images/screenshot-4.png" width=370 /> |
|
||||
|
||||
Get [Live Demo](https://demo.waf.chaitin.com:9443/)
|
||||
|
||||
## 🔥 FEATURES
|
||||
|
||||
List of the main features as follows:
|
||||
|
||||
- **`Block Web Attacks`**
|
||||
- It defenses for all of web attacks, such as `SQL injection`, `XSS`, `code injection`, `os command injection`, `CRLF injection`, `XXE`, `SSRF`, `path traversal` and so on.
|
||||
- **`Rate Limiting`**
|
||||
- Defend your web apps against `DoS attacks`, `bruteforce attempts`, `traffic surges`, and other types of abuse by throttling traffic that exceeds defined limits.
|
||||
- **`Anti-Bot Challenge`**
|
||||
- Anti-Bot challenges to protect your website from `bot attacks`, humen users will be allowed, crawlers and bots will be blocked.
|
||||
- **`Authentication Challenge`**
|
||||
- When authentication challenge turned on, visitors need to enter the password, otherwise they will be blocked.
|
||||
- **`Dynamic Protection`**
|
||||
- When dynamic protection turned on, html and js codes in your web server will be dynamically encrypted by each time you visit.
|
||||
|
||||
#### 🧩 Showcases
|
||||
|
||||
| | Legitimate User | Malicious User |
|
||||
| ----------------------------- | --------------------------------------------------- | ---------------------------------------------------------------- |
|
||||
| **`Block Web Attacks`** | <img src="./images/skeleton.png" width=270 /> | <img src="./images/blocked-for-attack-detected.png" width=270 /> |
|
||||
| **`Rate Limiting`** | <img src="./images/skeleton.png" width=270 /> | <img src="./images/blocked-for-access-too-fast.png" width=270 /> |
|
||||
| **`Anti-Bot Challenge`** | <img src="./images/captcha-1.gif" width=270 /> | <img src="./images/captcha-2.gif" width=270 /> |
|
||||
| **`Auth Challenge`** | <img src="./images/auth-1.gif" width=270 /> | <img src="./images/auth-2.gif" width=270 /> |
|
||||
| **`HTML Dynamic Protection`** | <img src="./images/dynamic-html-1.png" width=270 /> | <img src="./images/dynamic-html-2.png" width=270 /> |
|
||||
| **`JS Dynamic Protection`** | <img src="./images/dynamic-js-1.png" width=270 /> | <img src="./images/dynamic-js-2.png" width=270 /> |
|
||||
|
||||
## 🚀 Quickstart
|
||||
|
||||
> [!WARNING]
|
||||
> 中国大陆用户安装国际版可能会导致无法连接云服务,请查看 [中文版安装文档](https://docs.waf-ce.chaitin.cn/zh/%E4%B8%8A%E6%89%8B%E6%8C%87%E5%8D%97/%E5%AE%89%E8%A3%85%E9%9B%B7%E6%B1%A0)
|
||||
|
||||
#### 📦 Installing
|
||||
|
||||
Information on how to install SafeLine can be found in the [Install Guide](https://docs.waf.chaitin.com/en/tutorials/install)
|
||||
|
||||
#### ⚙️ Protecting Web Apps
|
||||
|
||||
to see [Configuration](https://docs.waf.chaitin.com/en/tutorials/Configuration)
|
||||
|
||||
## 📋 More Informations
|
||||
|
||||
#### Effect Evaluation
|
||||
|
||||
| Metric | ModSecurity, Level 1 | CloudFlare, Free | SafeLine, Balance | SafeLine, Strict |
|
||||
| ----------------- | -------------------- | -------------------- | ---------------------- | --------------------- |
|
||||
| Total Samples | 33669 | 33669 | 33669 | 33669 |
|
||||
| **Detection** | 69.74% | 10.70% | 71.65% | **76.17%** |
|
||||
| **False Positive**| 17.58% | 0.07% | **0.07%** | 0.22% |
|
||||
| **Accuracy** | 82.20% | 98.40% | **99.45%** | 99.38% |
|
||||
|
||||
|
||||
#### Is SafeLine Production-Ready?
|
||||
|
||||
Yes, SafeLine is production-ready.
|
||||
|
||||
- Over 180,000 installations worldwide
|
||||
- Protecting over 1,000,000 Websites
|
||||
- Handling over 30,000,000,000 HTTP Requests Daily
|
||||
|
||||
#### 🙋♂️ Community
|
||||
|
||||
Join our [Discord](https://discord.gg/SVnZGzHFvn) to get community support, the core team members are identified by the STAFF role in Discord.
|
||||
|
||||
- channel [#feedback](https://discord.com/channels/1243085666485534830/1243120292822253598): for new features discussion.
|
||||
- channel [#FAQ](https://discord.com/channels/1243085666485534830/1263761679619981413): for FAQ.
|
||||
- channel [#general](https://discord.com/channels/1243085666485534830/1243115843919806486): for any other questions.
|
||||
|
||||
Several contact options exist for our community, the primary one being Discord. These are in addition to GitHub issues for creating a new issue.
|
||||
|
||||
<p align="left">
|
||||
<a target="_blank" href="https://discord.gg/SVnZGzHFvn"><img src="https://img.shields.io/badge/Discord-5865F2?style=flat&logo=discord&logoColor=white"></a>
|
||||
<a target="_blank" href="https://x.com/safeline_waf"><img src="https://img.shields.io/badge/X.com-000000?style=flat&logo=x&logoColor=white"></a>
|
||||
<a target="_blank" href="/images/wechat.png"><img src="https://img.shields.io/badge/WeChat-07C160?style=flat&logo=wechat&logoColor=white"></a>
|
||||
<h4 align="center">相关源码仓库</h4>
|
||||
<p align="center">
|
||||
<a href="https://github.com/chaitin/yanshi">语义分析自动机引擎</a> |
|
||||
<a href="https://github.com/chaitin/safeline-open-platform">流量分析插件</a> |
|
||||
<a href="https://github.com/chaitin/lua-resty-t1k">T1K 协议</a> |
|
||||
<a href="https://github.com/chaitin/blazehttp">测试工具</a>
|
||||
</p>
|
||||
|
||||
#### 💪 PRO Edition
|
||||
## 相关特性
|
||||
|
||||
Coming soon!
|
||||
#### 便捷性
|
||||
|
||||
#### 📝 License
|
||||
采用容器化部署,一条命令即可完成安装,0 成本上手。安全配置开箱即用,无需人工维护,可实现安全躺平式管理。
|
||||
|
||||
See [LICENSE](/LICENSE.md) for details.
|
||||
#### 安全性
|
||||
|
||||
首创业内领先的智能语义分析算法,精准检测、低误报、难绕过。语义分析算法无规则,面对未知特征的 0day 攻击不再手足无措。
|
||||
|
||||
#### 高性能
|
||||
|
||||
无规则引擎,线性安全检测算法,平均请求检测延迟在 1 毫秒级别。并发能力强,单核轻松检测 2000+ TPS,只要硬件足够强,可支撑的流量规模无上限。
|
||||
|
||||
#### 高可用
|
||||
|
||||
流量处理引擎基于 Nginx 开发,性能与稳定性均可得到保障。内置完善的健康检查机制,服务可用性高达 99.99%。
|
||||
|
||||
## 🚀 安装
|
||||
|
||||
### 配置需求
|
||||
|
||||
- 操作系统:Linux
|
||||
- 指令架构:x86_64
|
||||
- 软件依赖:Docker 20.10.6 版本以上
|
||||
- 软件依赖:Docker Compose 2.0.0 版本以上
|
||||
- 最小化环境:1 核 CPU / 1 GB 内存 / 10 GB 磁盘
|
||||
|
||||
|
||||
### 一键安装
|
||||
|
||||
```
|
||||
bash -c "$(curl -fsSLk https://waf-ce.chaitin.cn/release/latest/setup.sh)"
|
||||
```
|
||||
|
||||
> 更多安装方式请参考 <a href="https://waf-ce.chaitin.cn/posts/guide_install">安装雷池</a>
|
||||
|
||||
## 🕹️ 快速使用
|
||||
|
||||
### 登录
|
||||
|
||||
浏览器打开后台管理页面 `https://<waf-ip>:9443`。根据界面提示,使用 **支持 TOTP 的认证软件** 扫描二维码,然后输入动态口令登录:
|
||||
|
||||

|
||||
|
||||
### 配置防护站点
|
||||
|
||||
雷池以反向代理方式接入,优先于网站服务器接收流量,对流量中的攻击行为进行检测和清洗,将清洗过后的流量转发给网站服务器。
|
||||
|
||||

|
||||
|
||||
<font color=grey>💡 TIPS: 添加后,执行 `curl -H "Host: <域名>" http://<WAF IP>:<端口>` 应能获取到业务网站的响应。</font>
|
||||
|
||||
### 测试效果
|
||||
|
||||
使用以下方式尝试模拟黑客攻击,看看雷池的防护效果如何
|
||||
|
||||
- 浏览器访问 `http://<IP或域名>:<端口>/?id=1%20AND%201=1`
|
||||
- 浏览器访问 `http://<IP或域名>:<端口>/?a=<script>alert(1)</script>`
|
||||
|
||||

|
||||
|
||||
> 如果你需要进行深度测试,请参考 <a href="https://waf-ce.chaitin.cn/posts/guide_test">测试防护效果</a>
|
||||
|
||||
### FAQ
|
||||
|
||||
- [安装问题](https://waf-ce.chaitin.cn/posts/faq_install)
|
||||
- [登录问题](https://waf-ce.chaitin.cn/posts/faq_login)
|
||||
- [网站无法访问](https://waf-ce.chaitin.cn/posts/faq_access)
|
||||
- [配置问题](https://waf-ce.chaitin.cn/posts/faq_config)
|
||||
- [其他问题](https://waf-ce.chaitin.cn/posts/faq_other)
|
||||
|
||||
## 🏘️ 联系我们
|
||||
|
||||
1. 可以通过 GitHub Issue 直接进行 Bug 反馈和功能建议
|
||||
2. 可以扫描下方二维码加入雷池社区版用户讨论群
|
||||
|
||||
<img src="https://waf-ce.chaitin.cn/images/wechat-230717.png" width="30%" />
|
||||
|
||||
## Star History <a name="star-history"></a>
|
||||
|
||||
<a href="https://github.com/chaitin/safeline/stargazers">
|
||||
<img width="500" alt="Star History Chart" src="https://api.star-history.com/svg?repos=chaitin/safeline&type=Date">
|
||||
</a>
|
||||
|
|
115
README_CN.md
|
@ -1,115 +0,0 @@
|
|||
<p align="center">
|
||||
<img src="/images/banner.png" width="400" />
|
||||
</p>
|
||||
|
||||
<h4 align="center">
|
||||
SafeLine - 雷池 - 不让黑客越过半步
|
||||
</h4>
|
||||
|
||||
<p align="center">
|
||||
<a target="_blank" href="https://waf-ce.chaitin.cn/">🏠 官网</a> |
|
||||
<a target="_blank" href="https://docs.waf-ce.chaitin.cn/">📖 文档</a> |
|
||||
<a target="_blank" href="https://demo.waf-ce.chaitin.cn:9443/">🔍 演示环境</a> |
|
||||
<a target="_blank" href="/images/wechat.png">🙋♂️ 社区微信群</a> |
|
||||
<a target="_blank" href="https://github.com/chaitin/SafeLine">国际版</a>
|
||||
</p>
|
||||
|
||||
## 👋 项目介绍
|
||||
|
||||
SafeLine,中文名 "雷池",是一款简单好用, 效果突出的 **`Web 应用防火墙(WAF)`**,可以保护 Web 服务不受黑客攻击。
|
||||
|
||||
雷池通过过滤和监控 Web 应用与互联网之间的 HTTP 流量来保护 Web 服务。可以保护 Web 服务免受 `SQL 注入`、`XSS`、 `代码注入`、`命令注入`、`CRLF 注入`、`ldap 注入`、`xpath 注入`、`RCE`、`XXE`、`SSRF`、`路径遍历`、`后门`、`暴力破解`、`CC`、`爬虫` 等攻击。
|
||||
|
||||
#### 💡 工作原理
|
||||
|
||||
<img src="/images/how-it-works.png" width="800" />
|
||||
|
||||
雷池通过阻断流向 Web 服务的恶意 HTTP 流量来保护 Web 服务。雷池作为反向代理接入网络,通过在 Web 服务前部署雷池,可在 Web 服务和互联网之间设置一道屏障。
|
||||
|
||||
雷池的核心功能如下:
|
||||
|
||||
- 防护 Web 攻击
|
||||
- 防爬虫, 防扫描
|
||||
- 前端代码动态加密
|
||||
- 基于源 IP 的访问速率限制
|
||||
- HTTP 访问控制
|
||||
|
||||
#### ⚡️ 项目截图
|
||||
|
||||
| <img src="./images/screenshot-1.png" width=370 /> | <img src="./images/screenshot-2.png" width=370 /> |
|
||||
| ------------------------------------------------- | ------------------------------------------------- |
|
||||
| <img src="./images/screenshot-3.png" width=370 /> | <img src="./images/screenshot-4.png" width=370 /> |
|
||||
|
||||
查看 [演示环境](https://demo.waf-ce.chaitin.cn:9443/)
|
||||
|
||||
## 🔥 核心能力
|
||||
|
||||
对于你的网站而言, 雷池可以实现如下效果:
|
||||
|
||||
- **`阻断 Web 攻击`**
|
||||
- 可以防御所有的 Web 攻击,例如 `SQL 注入`、`XSS`、`代码注入`、`操作系统命令注入`、`CRLF 注入`、`XXE`、`SSRF`、`路径遍历` 等等。
|
||||
- **`限制访问频率`**
|
||||
- 限制用户的访问速率,让 Web 服务免遭 `CC 攻击`、`暴力破解`、`流量激增` 和其他类型的滥用。
|
||||
- **`人机验证`**
|
||||
- 互联网上有来自真人用户的流量,但更多的是由爬虫, 漏洞扫描器, 蠕虫病毒, 漏洞利用程序等自动化程序发起的流量,开启雷池的人机验证功能后真人用户会被放行,恶意爬虫将会被阻断。
|
||||
- **`身份认证`**
|
||||
- 雷池的 "身份认证" 功能可以很好的解决 "未授权访问" 漏洞,当用户访问您的网站时,需要输入您配置的用户名和密码信息,不持有认证信息的用户将被拒之门外。
|
||||
- **`动态防护`**
|
||||
- 在用户浏览到的网页内容不变的情况下,将网页赋予动态特性,对 HTML 和 JavaScript 代码进行动态加密,确保每次访问时这些代码都以随机且独特的形态呈现。
|
||||
|
||||
#### 🧩 核心能力展示
|
||||
|
||||
| | Legitimate User | Malicious User |
|
||||
| ----------------------------- | --------------------------------------------------- | ---------------------------------------------------------------- |
|
||||
| **`阻断 Web 攻击`** | <img src="./images/skeleton.png" width=270 /> | <img src="./images/blocked-for-attack-detected.png" width=270 /> |
|
||||
| **`限制访问频率`** | <img src="./images/skeleton.png" width=270 /> | <img src="./images/blocked-for-access-too-fast.png" width=270 /> |
|
||||
| **`人机验证`** | <img src="./images/captcha-1.gif" width=270 /> | <img src="./images/captcha-2.gif" width=270 /> |
|
||||
| **`身份认证`** | <img src="./images/auth-1.gif" width=270 /> | <img src="./images/auth-2.gif" width=270 /> |
|
||||
| **`HTML 动态防护`** | <img src="./images/dynamic-html-1.png" width=270 /> | <img src="./images/dynamic-html-2.png" width=270 /> |
|
||||
| **`JS 动态防护`** | <img src="./images/dynamic-js-1.png" width=270 /> | <img src="./images/dynamic-js-2.png" width=270 /> |
|
||||
|
||||
## 🚀 上手指南
|
||||
|
||||
#### 📦 安装
|
||||
|
||||
查看 [安装雷池](https://docs.waf-ce.chaitin.cn/zh/%E4%B8%8A%E6%89%8B%E6%8C%87%E5%8D%97/%E5%AE%89%E8%A3%85%E9%9B%B7%E6%B1%A0)
|
||||
|
||||
#### ⚙️ 配置防护站点
|
||||
|
||||
查看 [快速配置](https://docs.waf-ce.chaitin.cn/zh/%E4%B8%8A%E6%89%8B%E6%8C%87%E5%8D%97/%E5%BF%AB%E9%80%9F%E9%85%8D%E7%BD%AE)
|
||||
|
||||
## 📋 更多信息
|
||||
|
||||
#### 防护效果测试
|
||||
|
||||
| Metric | ModSecurity, Level 1 | CloudFlare | 雷池, 平衡 | 雷池, 严格 |
|
||||
| ----------------- | -------------------- | -------------------- | ---------------------- | --------------------- |
|
||||
| 样本数量 | 33669 | 33669 | 33669 | 33669 |
|
||||
| **检出率** | 69.74% | 10.70% | 71.65% | **76.17%** |
|
||||
| **误报率** | 17.58% | 0.07% | **0.07%** | 0.22% |
|
||||
| **准确率** | 82.20% | 98.40% | **99.45%** | 99.38% |
|
||||
|
||||
|
||||
#### 雷池可以投入生产使用吗
|
||||
|
||||
是的,已经有不少用户将雷池投入生产使用,截至目前
|
||||
|
||||
- 全球累计装机量已超过 18 万台
|
||||
- 防护的网站数量超过 100 万个
|
||||
- 每天清洗 HTTP 请求超过 300 亿次
|
||||
|
||||
#### 🙋♂️ 用户社区
|
||||
|
||||
欢迎加入雷池 [社区微信群](/images/wechat.png) 进行技术交流。
|
||||
|
||||
也可以加入雷池 [Discord](https://discord.gg/SVnZGzHFvn) 来获取更多社区支持。
|
||||
|
||||
<p align="left">
|
||||
<a target="_blank" href="/images/wechat.png"><img src="https://img.shields.io/badge/WeChat-07C160?style=flat&logo=wechat&logoColor=white"></a>
|
||||
<a target="_blank" href="https://discord.gg/SVnZGzHFvn"><img src="https://img.shields.io/badge/Discord-5865F2?style=flat&logo=discord&logoColor=white"></a>
|
||||
<a target="_blank" href="https://x.com/safeline_waf"><img src="https://img.shields.io/badge/X.com-000000?style=flat&logo=x&logoColor=white"></a>
|
||||
</p>
|
||||
|
||||
#### 💪 专业版
|
||||
|
||||
查看 [社区版 vs 专业版](https://waf-ce.chaitin.cn/version)
|
112
README_EN.md
Normal file
|
@ -0,0 +1,112 @@
|
|||
<p align="center">
|
||||
<img src="https://ctstack-oss.oss-cn-beijing.aliyuncs.com/veinmind/safeline-assets/safeline_logo.png" width="120">
|
||||
</p>
|
||||
<h1 align="center">SafeLine Community Edition</h1>
|
||||
<h3 align="center">Keep hackers at bay</h3>
|
||||
<br>
|
||||
<p align="center">
|
||||
<img src="https://img.shields.io/badge/SafeLine-BEST_WAF-blue">
|
||||
<img src="https://img.shields.io/github/release/chaitin/safeline.svg?color=blue" />
|
||||
<img src="https://img.shields.io/github/release-date/chaitin/safeline.svg?color=blue&label=update" />
|
||||
<img src="https://img.shields.io/docker/v/chaitin/safeline-mgt-api?color=blue">
|
||||
<img src="https://img.shields.io/github/stars/chaitin/safeline?style=social">
|
||||
</p>
|
||||
|
||||
<p align="center"> <a href="https://waf-ce.chaitin.cn/">Official Website</a> </p>
|
||||
<p align="center"> English | <a href="README_CN.md">中文文档</a> </p>
|
||||
|
||||
A simple and easy to use WAF tool. Built on [Chaitin Technology](https://www.chaitin.cn/en/)'s ace 🤖️Intelligent Semantic Analysis algorithm🤖️, designed for the community.
|
||||
|
||||
## ✨ Demo
|
||||
|
||||
### 🔥🔥🔥 Online Demo: https://demo.waf-ce.chaitin.cn:9443/
|
||||
|
||||
There is a simple http server, listened on `http://127.0.0.1:8889`, can be used as for testing.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## 🚀 Installation
|
||||
|
||||
### 1. Make sure [Docker](https://docs.docker.com/engine/install/) and [Compose V2](https://docs.docker.com/compose/install/) are installed correctly on the machine
|
||||
```shell
|
||||
docker info # >= 20.10.6
|
||||
docker compose version # >= 2.0.0
|
||||
```
|
||||
|
||||
### 2. Setup and deploy
|
||||
|
||||
```shell
|
||||
mkdir -p safeline && cd safeline
|
||||
# setup
|
||||
curl -kfLsS https://waf-ce.chaitin.cn/release/latest/setup.sh | bash
|
||||
|
||||
# launch
|
||||
sudo docker compose up -d
|
||||
```
|
||||
|
||||
#### Upgrade
|
||||
|
||||
**WARN: SafeLine will be restarted and your traffic will be unavailable for a short period of time. You may need to choose a proper time for upgration.**
|
||||
|
||||
```shell
|
||||
curl -kfLsS https://waf-ce.chaitin.cn/release/latest/upgrade.sh | bash
|
||||
|
||||
# delete the old used image layers if necessary.
|
||||
docker rmi $(docker images | grep "safeline" | grep "none" | awk '{print $3}')
|
||||
```
|
||||
|
||||
## 🕹️ Quick Start
|
||||
|
||||
### 1. Login
|
||||
|
||||
Open admin page `https://<waf-ip>:9443` and scan qrcode with any authenticator Apps that support TOTP, enter the code to login.
|
||||
|
||||

|
||||
|
||||
### 2. Create website
|
||||
|
||||

|
||||
|
||||
<font color=grey>💡 TIPS: After creating website,execute `curl -H "Host: <Domain>" http://<WAF IP>:<Port>` to check if you can get correct response from web server.</font>
|
||||
|
||||
### 3. Deploy your website to SafeLine
|
||||
|
||||
- If your website is hosted by DNS, just modify your DNS record to WAF
|
||||
- If your website is behind any reverse-proxy like nginx, you can modify your nginx conf and set upstream to WAF
|
||||
|
||||
### 4. Protected!👌
|
||||
|
||||
Try these:
|
||||
|
||||
- `http://<IP or Domain>:<Port>/webshell.php`
|
||||
- `http://<IP or Domain>:<Port>/?id=1%20AND%201=1`
|
||||
- `http://<IP or Domain>:<Port>/?a=<script>alert(1)</script>`
|
||||
|
||||
## 📖 FAQ
|
||||
|
||||
Please refer to our [FAQ](FAQ.md) first if you have any questions.
|
||||
|
||||
For examples:
|
||||
- [docker compose or docker-compose?](FAQ.md#docker-compose-or-docker-compose)
|
||||
- [website configurations](FAQ.md#站点配置问题)
|
||||
- [website not working / not correctly response](FAQ.md#配置完成之后还是没有成功访问到上游服务器)
|
||||
|
||||
## 🏘️ Contact Us
|
||||
|
||||
1. You can make bug feedback and feature suggestions directly through GitHub Issues.
|
||||
2. By scanning the QR code below (use wechat or qq), you can join the discussion group of SafeLine users for detailed discussions.
|
||||
|
||||
<img src="https://waf-ce.chaitin.cn/images/wechat-230717.png" width="30%" />
|
||||
|
||||
## ✨ CTStack
|
||||
<img src="https://ctstack-oss.oss-cn-beijing.aliyuncs.com/CT%20Stack-2.png" width="30%" />
|
||||
|
||||
SafeLine has already joined [CTStack](https://stack.chaitin.com/tool/detail?id=717) community.
|
||||
|
||||
## Star History <a name="star-history"></a>
|
||||
|
||||
<a href="https://github.com/chaitin/safeline/stargazers">
|
||||
<img width="500" alt="Star History Chart" src="https://api.star-history.com/svg?repos=chaitin/safeline&type=Date">
|
||||
</a>
|
|
@ -1 +1 @@
|
|||
Subproject commit afc88a94d03db1cd52156c34c3c9c58053c9f658
|
||||
Subproject commit aba9547bda15661657da5f90b264444eb2480d88
|
316
blockpage/index.html
Normal file
|
@ -0,0 +1,316 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<title>请求存在威胁,已被拦截</title>
|
||||
<link
|
||||
rel="shortcut icon"
|
||||
href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAC8VBMVEUAAAAqKipISEgnJydDQkIDAwMcHBw8PDw8PDwWFhYVFRUqKionJycLCws+Pz8ICAgmJiYICAhHR0cNDQ0QEBApKSksLCwbGxs9PT1HR0cjIyNDQ0MwMDA5OTlHR0cHBwdGRkYyMjIVFRUODg5AQEAYGBgxMTEDAwNJSUkfHx8lJSVBQUELCwsHBwdHR0cwMDAcHBxAQEALCws6OzsDAwMyMjL///89Pj79/v0DAgInt3UnuncoKCgFBAQICQk2NzcWFxYPDw9FRUUlvHhBQUE6PTsLCgtGSEY5OTohISESEhIuLy4slnoyl3grlHM+o21htI0rk3dIqXRCpnEzMzMwoFlgsJNEqWwroFMxMTH2+vg4oWQonUwkJiUeHR02mXxPrHotlnQrlW8ynWqEwqZnuolitoY9nX84oGs9o2o/p2Y6pmEtLCz5/Pvf7+g7nngpkHVLrXA5pGg2o10jm0xLS0selUkLAADu9fKx1sJnt5BMpoZLqXgwmnIzoGE4QT3C3dBSqYpYsINIpn1AoHtBpHc2nHU6o3AnrG4qqGw0PjkQGxYIEA5ksZZdtYFSq4FDoYBZs3xTsHc0lWEqnFo2glkvFSsaHBvn8+7b6+K43Mx5vaFasIhHooVVr344m20smmQaWEZEMT8xST642san0rtxuZhZrI4+oXIbmGEAjlRFTEg3MDgwOTRasZNvvI49sn4iuXQor3EdqGkkfGYipWEsm18npE4tV0Q5SUFDOkBFKj05IDQnAR0KFBF0v5cniG80jF0dmlUAlTiwzrqezrdpt5cns3MvoWksmmkyf1g6dFQvdVMCl1AwbVA9ZE4oZUoxY0EVAAHX5t3S5t3L39Kix66Sx6yWwKVNqIFIsHcpjm8yl24VmlosiUoAjkaBvZuBtZBZo3osk2IwpFohalMvekwvckE/LToZSTg2KDQwIC0UMyceLSUOKiFWsI92rY1IrX4rhVoAkiwiABZxr4Ihw3xfqnMmgGAMmkcAjgBUQVAtAAAANnRSTlMABP4G/v0bGjcoNyEKyEbs4NPMvEMR/fz78uzYzcG7bmxsbEsq/PT05sy4rKuVk5OTfn3v202D2tR1AAAI+UlEQVRYw7SSP2uDQBjGeyqc0OIgFBKk4pChEAiEDkIcAv7B+wqd+xk635p0Le7FjtrFqf5ZMiVoiN8ihHyAzH3vbEmTJk069IeeD+/r85x33sU/Il7jjgx08LX4dzNWjJ6uareApuo9Q8HnhyCElZ7afmQIABdttadghM6xi5eGDm5hD8jQjUsRnZ7dUAXBF+DmRFHzFHhRNU58BbpSdF+wfcm3OVEeBHnEJS8Kvq5coV/8uN+2GXUmRWz6MEoSP+RSymreavcxOurvdG1Jkmw7rJ6zPAzzsB5Z1qgOmc6eqxC60O52jiSIsgpvuIx8Np1UVTAbWAO4ZkFVTaaznPcgQZXFw34N7A2ZlGwcy3EGHAfkJpEyaDQR2qEEJGtuy/zEzdIH8ANgZ1gPaeZ+dVuuJqOf678B/xayqoOgLOcvL/OyDIJ6RaC4TbjZ3weEu2bL80xCKIycVVHE8XA8juO4KFZNzfMoITC2zC5Gu/+/b3oAWaRrSqnHoGlK38eOM35nyuNQuk4XhCmzv3MekHJHAFosR4u3++ETg5DXMrFgD5LyddiUhvdvi9GyoAS4U9D3BXxwRT4hiYRhGGcJ+gvRpQ6hBy8eunRqCBM8SKc5CObgjuNCB2dAHYUcEV0WkU5jB5fJ2cEM2oO6ECjuJmqHlkhb3ENBErWLkBRFQd6KiPa07/fNuMQ+Mwzf9877/Ob53tGj2mKxHalakw8nu7lcbvfoWrSCH/6jVbw+wqWTh6S1GmkXF1G3/tUhBgwWpGIuHAaC1dQSxZ3WAtg1wbK1I4otkxX84XCuiNsNA/8CjOlw5b5bRwTTApLpP6lF5K9373G7buxNH2CwOODau6u73eFIpCFCN9Y3TdrWJDYikbDbXb/bwwZDHzCktzgcDrrkrruBgBDVSiWZrFS+alJ3VWQHP7SVaDBY9EMaYM4I25ICAd6CKEqW5drn7e2Pmx6PZxM9vny4qKVrUKZQA4qglMBinNNGOAufRwGwW/D7fc4VZ/J9IZvN5rOJRDYPix9c0m73+fyCQCEIRKAhxKw6xkEdDVLaYL8RkFuSOuV8ECkTPD/MZPAixnYkacUJDIRoKzRJ07pBDBg3kiCle0Nh+3pKKuej8y6XiwgknpvNqw0i4HIF5qMxVkqtq4ibroI8xnEMMJBTJMmv9e3sfixDEPNwn141XwSq+XIehQ0UMoUy20es8STYDOoIyCme7rX9mr/sCWI/4fr9p8FQMJamcOhSETG2zEmA8PvbPRoAeAiTM/wUT36/FdQEEseysaiKOH16bAgyxciPz2cEKuURAGe4VWiwzUwCYExnNvN4BHEmpIZI7Z8F8CcDeV+TYeJx5rh5FX0NCH1SSN5s1o0BYGTCbDaTvYO4LEOn12Zf2eLY1K8NNXT0/PjCG4cXjzBLIpZCALvTGzrokWCbGAHAMALwfDrExOUahPA67curLMcWtNEFL3/amDjTOIR1ocOltpYRIM3zCDAMgNFpM4hMg9PG1BDCtmRfTrHcfgLOQQQ2LpfsNi/DHD+dErEOt6oBUIB306MY8JfJ8glJJAzDOLEgRHQqCDoaHbp1Wjp4mFMwgczgwBxcnNVRajq0wl5aRwX/ewhJiDLTssP6F9ZzF5FglRUqxLVSMgw7BUm1dOi4z/epu72n+eR7fj7PO++LmkywAIDgMhuA+MQhh+toVV29jm/E0+XyqtkgcF/Xb7tX1wOAQBxADwCNwBLCDv3iI59LuT1f58izj1cTaZutklB5HxFxCtphBoDgdoieRQTSRJY16fZOw5zgAoB/abW6eU4hJ75crsQ3mjZe5Y9ckHHK8bFiMLsELny6pzOxLG3ixALLsrrS7j+A4+Nl71wBwWC4axrJRB1keDW57RIETrECIQCwW9JBtjBBB4kCzsK5oGvbl+Rf0pBc5RWrIvy6Gw1xhedVHxC5MEFYlfAZBdBB+rAoIUPphAKSfCbpwAuPd3NWqzWXr42G+DfJsd32B0EgiJMSEkiLdJ+10oxkYn+kckE/AajfMXL7z918CoRUoXe5RAlGD83hD+YI4r4vsZBp6TZOz8YkWDgNvgNgk3uFWqpWS+UL2Ge6Gt/SqsoPEOE/r6wkxWanKUCzEIOF1/oQUHUMTBt/3hdSHYLotowDxBdbpsr7kCNYfzXBwIIGctKE2HxMkvode8Df9vLVjGPUulahkIKFZ6wWtXCQqIrJtj9g7+gkCSK0gNbcDMMwscZFKASEMys+JTyj1j0XCj0PHmioxJOYdUIeCl00YpDMzEFMM0wx8zj3ZXfIDoRXjBRtTbSOIDyj19C0FSOitx2A3i33GQaSKc0QMKZlqIW6uwNEIOr0imJxtM/DlayIouh1RiHHpToMoLRjI8D4JI4rTOPNLbuHiIgYSe9DjEJ4R1WMZAdyXHlrMCsQTI7//3HVrqCY5ccbWbZY9EAcOrORYpV0k0xAogj5YdQe0rstsnzzuMyQ+1q0cGRBM0U+2dp8kFEWvf7zWvTQCwS6uUTDw/2aXa+3yKiHzS1ye0rz/g/C39rLl7dBIA7DaxaaUCCEQDUCUQOG1CCOBHOCXJtgapuqWRx6Gr5CBapuCk0w+wwT1YgmDfsKe48jpQtJm4m9Cclx93ue+6fO0qM4jvKsPGyRQYHT/P76/Nj1+B54P1ZmOa/VLfCjQPXjCIFhe+BVveLIT3PHV/828BgEj8I48tV7ATbhopMbLmd2WwQUp9P7cZyenS8D7942MN5EhNA8u1YsSdMkSViv4Ph+g1/0seqa5TRCNBn877wuDBpRSussK8+DYrOHAjgTeFNmWU0pyowFbmBisIShqIOubZhwbIALmjVtF9SF4C3BT9aghZSGYViTIC+rlN0lrco8IDUGUaEN808NsosCXgRF0JVtVTVIVbVlFwDnQ/hcecKPd+HrJERIWBQBDwC4kKIIeSSi+/NHTxbVMQmRJIkQOACBHhpDt+mos8ePrrltYEIUc1YELU6j27Dns9nTZ59sayvuQAQvCXql2fLriD9chePBcR/QnjPO/jyqYtmeaax1ZG2Ynm0p6stfoy4VeYHIyhLwv+UH4kmftbvi1LgAAAAASUVORK5CYII="
|
||||
/>
|
||||
<style>
|
||||
html {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.container {
|
||||
text-align: center;
|
||||
word-break: keep-all;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background: white;
|
||||
font-size: 12px;
|
||||
min-height: 450px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.logo {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.intercepted {
|
||||
margin-top: 3.5rem;
|
||||
margin-bottom: 1.5rem;
|
||||
font-size: 20px;
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.intercepted-item {
|
||||
margin: 8px 0;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.footer {
|
||||
position: absolute;
|
||||
bottom: 32px;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
color: #a8a8a8;
|
||||
font-size: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
.footer-waflink {
|
||||
color: #27b876;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<table class="content">
|
||||
<tr>
|
||||
<td>
|
||||
<div class="logo">
|
||||
<svg
|
||||
width="200px"
|
||||
height="200px"
|
||||
viewBox="0 0 396 407"
|
||||
version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
>
|
||||
<title>编组 12</title>
|
||||
<defs>
|
||||
<linearGradient
|
||||
x1="50%"
|
||||
y1="0%"
|
||||
x2="50%"
|
||||
y2="100%"
|
||||
id="linearGradient-1"
|
||||
>
|
||||
<stop stop-color="#4B4B4B" offset="0%"></stop>
|
||||
<stop stop-color="#000000" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
<filter
|
||||
x="-3.0%"
|
||||
y="-2.8%"
|
||||
width="106.1%"
|
||||
height="105.6%"
|
||||
filterUnits="objectBoundingBox"
|
||||
id="filter-2"
|
||||
>
|
||||
<feGaussianBlur
|
||||
stdDeviation="3"
|
||||
in="SourceGraphic"
|
||||
></feGaussianBlur>
|
||||
</filter>
|
||||
<linearGradient
|
||||
x1="50%"
|
||||
y1="0%"
|
||||
x2="50%"
|
||||
y2="100%"
|
||||
id="linearGradient-3"
|
||||
>
|
||||
<stop
|
||||
stop-color="#24BC43"
|
||||
stop-opacity="0.8"
|
||||
offset="0%"
|
||||
></stop>
|
||||
<stop
|
||||
stop-color="#3ACBAB"
|
||||
stop-opacity="0.7"
|
||||
offset="100%"
|
||||
></stop>
|
||||
</linearGradient>
|
||||
<path
|
||||
d="M110.049657,49.667649 C110.049657,49.667649 81.1358702,46.2263115 76.8,26.7636364 C72.4880848,46.2263115 43.5503431,49.667649 43.5503431,49.667649 C14.2053649,53.3001718 0,36.4567369 0,36.4567369 C13.941859,65.8036979 38.4,64.7712967 38.4,64.7712967 L115.2,64.7712967 C115.2,64.7712967 139.634186,65.8036979 153.6,36.4567369 C153.6,36.4567369 139.394635,53.3192904 110.049657,49.667649 Z"
|
||||
id="path-4"
|
||||
></path>
|
||||
<filter
|
||||
x="-16.9%"
|
||||
y="-57.9%"
|
||||
width="133.9%"
|
||||
height="236.8%"
|
||||
filterUnits="objectBoundingBox"
|
||||
id="filter-5"
|
||||
>
|
||||
<feOffset
|
||||
dx="0"
|
||||
dy="4"
|
||||
in="SourceAlpha"
|
||||
result="shadowOffsetOuter1"
|
||||
></feOffset>
|
||||
<feGaussianBlur
|
||||
stdDeviation="8"
|
||||
in="shadowOffsetOuter1"
|
||||
result="shadowBlurOuter1"
|
||||
></feGaussianBlur>
|
||||
<feColorMatrix
|
||||
values="0 0 0 0 0 0 0 0 0 0.490319293 0 0 0 0 0.292243323 0 0 0 1 0"
|
||||
type="matrix"
|
||||
in="shadowBlurOuter1"
|
||||
></feColorMatrix>
|
||||
</filter>
|
||||
</defs>
|
||||
<g
|
||||
id="页面-1"
|
||||
stroke="none"
|
||||
stroke-width="1"
|
||||
fill="none"
|
||||
fill-rule="evenodd"
|
||||
>
|
||||
<g id="编组-12" transform="translate(49.000000, 38.000000)">
|
||||
<path
|
||||
d="M292.40836,59.04 C290.927217,51.9634286 285.002646,46.6971429 277.761503,46.368 C222.13636,44.8868571 176.385503,16.5805714 157.953503,3.08571429 C152.358074,-1.02857143 144.95236,-1.02857143 139.356931,3.08571429 C120.431217,16.5805714 75.1740742,44.8868571 19.5489314,46.368 C12.4723599,46.6971429 6.21864565,51.9634286 4.90207422,59.04 C-3.98478292,103.474286 -19.2899258,254.057143 148.902074,324 C316.60036,253.892571 300.966074,103.474286 292.40836,59.04 Z"
|
||||
id="路径"
|
||||
fill="url(#linearGradient-1)"
|
||||
fill-rule="nonzero"
|
||||
></path>
|
||||
<path
|
||||
d="M292.40836,59.04 C290.927217,51.9634286 285.002646,46.6971429 277.761503,46.368 C222.13636,44.8868571 176.385503,16.5805714 157.953503,3.08571429 C152.358074,-1.02857143 144.95236,-1.02857143 139.356931,3.08571429 C120.431217,16.5805714 75.1740742,44.8868571 19.5489314,46.368 C12.4723599,46.6971429 6.21864565,51.9634286 4.90207422,59.04 C-3.98478292,103.474286 -19.2899258,254.057143 148.902074,324 C316.60036,253.892571 300.966074,103.474286 292.40836,59.04 Z"
|
||||
id="路径"
|
||||
fill="url(#linearGradient-1)"
|
||||
fill-rule="nonzero"
|
||||
filter="url(#filter-2)"
|
||||
></path>
|
||||
<path
|
||||
d="M149,261.4 C205.553958,261.4 251.4,215.553958 251.4,159 C251.4,131.275004 240.381593,106.123494 222.484813,87.6855068 C209.900749,96.0964568 185.81512,106.024178 175.564259,100.853688 C166.334879,96.1984273 157.476591,88.4505652 148.989396,77.610101 C142.047769,88.5334102 134.670586,95.5517221 126.857848,98.6650367 C120.689419,101.123107 98.2592604,102.915695 75.4419467,87.761039 C57.5883513,106.192154 46.6,131.312844 46.6,159 C46.6,215.553958 92.4460416,261.4 149,261.4 Z"
|
||||
id="椭圆形备份-26"
|
||||
fill="url(#linearGradient-3)"
|
||||
></path>
|
||||
<g
|
||||
id="编组-5备份-6"
|
||||
transform="translate(91.771423, 102.101722)"
|
||||
fill="#FFFFFF"
|
||||
>
|
||||
<polygon
|
||||
id="路径-130备份-29"
|
||||
transform="translate(57.217971, 95.920999) rotate(-180.000000) translate(-57.217971, -95.920999) "
|
||||
points="56.6651511 64.9496372 -7.57241738e-17 97.1108413 50.6084036 126.892361 68.8016729 117.264704 34.3433228 97.1108413 56.6651511 84.5503086 96.9001091 107.376711 96.9001091 114.88399 114.435942 125.435553 114.435942 97.1108413"
|
||||
></polygon>
|
||||
<polygon
|
||||
id="路径-130备份-30"
|
||||
transform="translate(57.217971, 30.971362) rotate(-360.000000) translate(-57.217971, -30.971362) "
|
||||
points="56.6651511 2.84217094e-14 -7.57241738e-17 32.1612041 50.6084036 61.9427239 68.8016729 52.3150668 34.3433228 32.1612041 56.6651511 19.6006714 96.9001091 42.4270741 96.9001091 49.9343528 114.435942 60.4859155 114.435942 32.1612041"
|
||||
></polygon>
|
||||
<polygon
|
||||
id="路径-130备份-29"
|
||||
opacity="0.40499442"
|
||||
transform="translate(57.217971, 95.920999) rotate(-180.000000) translate(-57.217971, -95.920999) "
|
||||
points="56.6651511 64.9496372 -7.57241738e-17 97.1108413 50.6084036 126.892361 68.8016729 117.264704 34.3433228 97.1108413 56.6651511 84.5503086 96.9001091 107.376711 96.9001091 114.88399 114.435942 125.435553 114.435942 97.1108413"
|
||||
></polygon>
|
||||
<polygon
|
||||
id="路径-130备份-30"
|
||||
opacity="0.40499442"
|
||||
transform="translate(57.217971, 30.971362) rotate(-360.000000) translate(-57.217971, -30.971362) "
|
||||
points="56.6651511 4.8316906e-13 -7.57241738e-17 32.1612041 50.6084036 61.9427239 68.8016729 52.3150668 34.3433228 32.1612041 56.6651511 19.6006714 96.9001091 42.4270741 96.9001091 49.9343528 114.435942 60.4859155 114.435942 32.1612041"
|
||||
></polygon>
|
||||
</g>
|
||||
<g
|
||||
id="长亭logo备份-18"
|
||||
transform="translate(72.200000, 45.222222)"
|
||||
fill-rule="nonzero"
|
||||
>
|
||||
<g id="编组-7">
|
||||
<path
|
||||
d="M96.7632666,18.0061837 C96.7632666,18.0061837 79.3862969,15.2966085 76.7907961,0 C74.1952953,15.2966085 56.8183256,18.0061837 56.8183256,18.0061837 C39.1836466,20.8694936 30.6424242,7.60987058 30.6424242,7.60987058 C39.0363842,30.6893013 53.7258141,29.862977 53.7258141,29.862977 L99.8741859,29.862977 C99.8741859,29.862977 114.563616,30.6700845 122.957576,7.60987058 C122.957576,7.60987058 114.416353,20.8694936 96.7816744,18.0061837 L96.7632666,18.0061837 Z"
|
||||
id="路径"
|
||||
fill="#27B876"
|
||||
></path>
|
||||
<g id="路径">
|
||||
<use
|
||||
fill="black"
|
||||
fill-opacity="1"
|
||||
filter="url(#filter-5)"
|
||||
xlink:href="#path-4"
|
||||
></use>
|
||||
<use fill="#27B876" xlink:href="#path-4"></use>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="intercepted">请求存在威胁,已被拦截</div>
|
||||
<div class="intercepted-item" id="EventID"></div>
|
||||
<div class="intercepted-item" id="TYPE"></div>
|
||||
<div class="intercepted-item">拦截时间: <span id="now"></span></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="footer">
|
||||
安全检测能力由
|
||||
<a class="footer-waflink" href="https://waf-ce.chaitin.cn"
|
||||
>长亭雷池 WAF</a
|
||||
>
|
||||
驱动
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
// 显示当前时间
|
||||
function timestring() {
|
||||
var d = new Date();
|
||||
function p(d) {
|
||||
return d < 10 ? "0" + d : d;
|
||||
}
|
||||
return (
|
||||
d.getFullYear() +
|
||||
"-" +
|
||||
p(d.getMonth() + 1) +
|
||||
"-" +
|
||||
p(d.getDate()) +
|
||||
" " +
|
||||
p(d.getHours()) +
|
||||
":" +
|
||||
p(d.getMinutes())
|
||||
);
|
||||
}
|
||||
document.getElementById("now").innerText = timestring();
|
||||
</script>
|
||||
|
||||
<script>
|
||||
// 这段代码是从源文件上直接抄下来的,原封不动的复制下来的
|
||||
window.onload = function () {
|
||||
var nodes = document.getElementsByTagName("body")[0].childNodes;
|
||||
var fit2inserts = null;
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
if (
|
||||
nodes[i].nodeType == 8 &&
|
||||
nodes[i].data.trimLeft().startsWith("event_id")
|
||||
) {
|
||||
fit2inserts = nodes[i];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 以后引擎按此约定插入新参数:
|
||||
* <!-- event_id: ****** type: A anymore: **** -->
|
||||
*/
|
||||
|
||||
try {
|
||||
var inserts =
|
||||
document.getElementsByTagName("html")[0].nextSibling || fit2inserts;
|
||||
var insertsData = inserts && (inserts.data || "");
|
||||
var incertDataList = insertsData.split(" ");
|
||||
var getVal = function (key) {
|
||||
return incertDataList[incertDataList.indexOf(key + ":") + 1];
|
||||
};
|
||||
var event_id = getVal("event_id");
|
||||
var type = getVal("TYPE");
|
||||
// var anymore = getVal('anymore') // 新增参数示例
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
if (event_id) {
|
||||
document.getElementById("EventID").innerText = "ID: " + event_id;
|
||||
}
|
||||
if (type) {
|
||||
document.getElementById("TYPE").innerText = "TYPE: " + type;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
287
blockpage/limited.html
Normal file
|
@ -0,0 +1,287 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<title>请求存在威胁,已被拦截</title>
|
||||
<link
|
||||
rel="shortcut icon"
|
||||
href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAC8VBMVEUAAAAqKipISEgnJydDQkIDAwMcHBw8PDw8PDwWFhYVFRUqKionJycLCws+Pz8ICAgmJiYICAhHR0cNDQ0QEBApKSksLCwbGxs9PT1HR0cjIyNDQ0MwMDA5OTlHR0cHBwdGRkYyMjIVFRUODg5AQEAYGBgxMTEDAwNJSUkfHx8lJSVBQUELCwsHBwdHR0cwMDAcHBxAQEALCws6OzsDAwMyMjL///89Pj79/v0DAgInt3UnuncoKCgFBAQICQk2NzcWFxYPDw9FRUUlvHhBQUE6PTsLCgtGSEY5OTohISESEhIuLy4slnoyl3grlHM+o21htI0rk3dIqXRCpnEzMzMwoFlgsJNEqWwroFMxMTH2+vg4oWQonUwkJiUeHR02mXxPrHotlnQrlW8ynWqEwqZnuolitoY9nX84oGs9o2o/p2Y6pmEtLCz5/Pvf7+g7nngpkHVLrXA5pGg2o10jm0xLS0selUkLAADu9fKx1sJnt5BMpoZLqXgwmnIzoGE4QT3C3dBSqYpYsINIpn1AoHtBpHc2nHU6o3AnrG4qqGw0PjkQGxYIEA5ksZZdtYFSq4FDoYBZs3xTsHc0lWEqnFo2glkvFSsaHBvn8+7b6+K43Mx5vaFasIhHooVVr344m20smmQaWEZEMT8xST642san0rtxuZhZrI4+oXIbmGEAjlRFTEg3MDgwOTRasZNvvI49sn4iuXQor3EdqGkkfGYipWEsm18npE4tV0Q5SUFDOkBFKj05IDQnAR0KFBF0v5cniG80jF0dmlUAlTiwzrqezrdpt5cns3MvoWksmmkyf1g6dFQvdVMCl1AwbVA9ZE4oZUoxY0EVAAHX5t3S5t3L39Kix66Sx6yWwKVNqIFIsHcpjm8yl24VmlosiUoAjkaBvZuBtZBZo3osk2IwpFohalMvekwvckE/LToZSTg2KDQwIC0UMyceLSUOKiFWsI92rY1IrX4rhVoAkiwiABZxr4Ihw3xfqnMmgGAMmkcAjgBUQVAtAAAANnRSTlMABP4G/v0bGjcoNyEKyEbs4NPMvEMR/fz78uzYzcG7bmxsbEsq/PT05sy4rKuVk5OTfn3v202D2tR1AAAI+UlEQVRYw7SSP2uDQBjGeyqc0OIgFBKk4pChEAiEDkIcAv7B+wqd+xk635p0Le7FjtrFqf5ZMiVoiN8ihHyAzH3vbEmTJk069IeeD+/r85x33sU/Il7jjgx08LX4dzNWjJ6uareApuo9Q8HnhyCElZ7afmQIABdttadghM6xi5eGDm5hD8jQjUsRnZ7dUAXBF+DmRFHzFHhRNU58BbpSdF+wfcm3OVEeBHnEJS8Kvq5coV/8uN+2GXUmRWz6MEoSP+RSymreavcxOurvdG1Jkmw7rJ6zPAzzsB5Z1qgOmc6eqxC60O52jiSIsgpvuIx8Np1UVTAbWAO4ZkFVTaaznPcgQZXFw34N7A2ZlGwcy3EGHAfkJpEyaDQR2qEEJGtuy/zEzdIH8ANgZ1gPaeZ+dVuuJqOf678B/xayqoOgLOcvL/OyDIJ6RaC4TbjZ3weEu2bL80xCKIycVVHE8XA8juO4KFZNzfMoITC2zC5Gu/+/b3oAWaRrSqnHoGlK38eOM35nyuNQuk4XhCmzv3MekHJHAFosR4u3++ETg5DXMrFgD5LyddiUhvdvi9GyoAS4U9D3BXxwRT4hiYRhGGcJ+gvRpQ6hBy8eunRqCBM8SKc5CObgjuNCB2dAHYUcEV0WkU5jB5fJ2cEM2oO6ECjuJmqHlkhb3ENBErWLkBRFQd6KiPa07/fNuMQ+Mwzf9877/Ob53tGj2mKxHalakw8nu7lcbvfoWrSCH/6jVbw+wqWTh6S1GmkXF1G3/tUhBgwWpGIuHAaC1dQSxZ3WAtg1wbK1I4otkxX84XCuiNsNA/8CjOlw5b5bRwTTApLpP6lF5K9373G7buxNH2CwOODau6u73eFIpCFCN9Y3TdrWJDYikbDbXb/bwwZDHzCktzgcDrrkrruBgBDVSiWZrFS+alJ3VWQHP7SVaDBY9EMaYM4I25ICAd6CKEqW5drn7e2Pmx6PZxM9vny4qKVrUKZQA4qglMBinNNGOAufRwGwW/D7fc4VZ/J9IZvN5rOJRDYPix9c0m73+fyCQCEIRKAhxKw6xkEdDVLaYL8RkFuSOuV8ECkTPD/MZPAixnYkacUJDIRoKzRJ07pBDBg3kiCle0Nh+3pKKuej8y6XiwgknpvNqw0i4HIF5qMxVkqtq4ibroI8xnEMMJBTJMmv9e3sfixDEPNwn141XwSq+XIehQ0UMoUy20es8STYDOoIyCme7rX9mr/sCWI/4fr9p8FQMJamcOhSETG2zEmA8PvbPRoAeAiTM/wUT36/FdQEEseysaiKOH16bAgyxciPz2cEKuURAGe4VWiwzUwCYExnNvN4BHEmpIZI7Z8F8CcDeV+TYeJx5rh5FX0NCH1SSN5s1o0BYGTCbDaTvYO4LEOn12Zf2eLY1K8NNXT0/PjCG4cXjzBLIpZCALvTGzrokWCbGAHAMALwfDrExOUahPA67curLMcWtNEFL3/amDjTOIR1ocOltpYRIM3zCDAMgNFpM4hMg9PG1BDCtmRfTrHcfgLOQQQ2LpfsNi/DHD+dErEOt6oBUIB306MY8JfJ8glJJAzDOLEgRHQqCDoaHbp1Wjp4mFMwgczgwBxcnNVRajq0wl5aRwX/ewhJiDLTssP6F9ZzF5FglRUqxLVSMgw7BUm1dOi4z/epu72n+eR7fj7PO++LmkywAIDgMhuA+MQhh+toVV29jm/E0+XyqtkgcF/Xb7tX1wOAQBxADwCNwBLCDv3iI59LuT1f58izj1cTaZutklB5HxFxCtphBoDgdoieRQTSRJY16fZOw5zgAoB/abW6eU4hJ75crsQ3mjZe5Y9ckHHK8bFiMLsELny6pzOxLG3ixALLsrrS7j+A4+Nl71wBwWC4axrJRB1keDW57RIETrECIQCwW9JBtjBBB4kCzsK5oGvbl+Rf0pBc5RWrIvy6Gw1xhedVHxC5MEFYlfAZBdBB+rAoIUPphAKSfCbpwAuPd3NWqzWXr42G+DfJsd32B0EgiJMSEkiLdJ+10oxkYn+kckE/AajfMXL7z918CoRUoXe5RAlGD83hD+YI4r4vsZBp6TZOz8YkWDgNvgNgk3uFWqpWS+UL2Ge6Gt/SqsoPEOE/r6wkxWanKUCzEIOF1/oQUHUMTBt/3hdSHYLotowDxBdbpsr7kCNYfzXBwIIGctKE2HxMkvode8Df9vLVjGPUulahkIKFZ6wWtXCQqIrJtj9g7+gkCSK0gNbcDMMwscZFKASEMys+JTyj1j0XCj0PHmioxJOYdUIeCl00YpDMzEFMM0wx8zj3ZXfIDoRXjBRtTbSOIDyj19C0FSOitx2A3i33GQaSKc0QMKZlqIW6uwNEIOr0imJxtM/DlayIouh1RiHHpToMoLRjI8D4JI4rTOPNLbuHiIgYSe9DjEJ4R1WMZAdyXHlrMCsQTI7//3HVrqCY5ccbWbZY9EAcOrORYpV0k0xAogj5YdQe0rstsnzzuMyQ+1q0cGRBM0U+2dp8kFEWvf7zWvTQCwS6uUTDw/2aXa+3yKiHzS1ye0rz/g/C39rLl7dBIA7DaxaaUCCEQDUCUQOG1CCOBHOCXJtgapuqWRx6Gr5CBapuCk0w+wwT1YgmDfsKe48jpQtJm4m9Cclx93ue+6fO0qM4jvKsPGyRQYHT/P76/Nj1+B54P1ZmOa/VLfCjQPXjCIFhe+BVveLIT3PHV/828BgEj8I48tV7ATbhopMbLmd2WwQUp9P7cZyenS8D7942MN5EhNA8u1YsSdMkSViv4Ph+g1/0seqa5TRCNBn877wuDBpRSussK8+DYrOHAjgTeFNmWU0pyowFbmBisIShqIOubZhwbIALmjVtF9SF4C3BT9aghZSGYViTIC+rlN0lrco8IDUGUaEN808NsosCXgRF0JVtVTVIVbVlFwDnQ/hcecKPd+HrJERIWBQBDwC4kKIIeSSi+/NHTxbVMQmRJIkQOACBHhpDt+mos8ePrrltYEIUc1YELU6j27Dns9nTZ59sayvuQAQvCXql2fLriD9chePBcR/QnjPO/jyqYtmeaax1ZG2Ynm0p6stfoy4VeYHIyhLwv+UH4kmftbvi1LgAAAAASUVORK5CYII="
|
||||
/>
|
||||
<style>
|
||||
html {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.container {
|
||||
text-align: center;
|
||||
word-break: keep-all;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background: white;
|
||||
font-size: 12px;
|
||||
min-height: 450px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.logo {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.intercepted {
|
||||
margin-top: 3.5rem;
|
||||
margin-bottom: 1.5rem;
|
||||
font-size: 20px;
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.intercepted-item {
|
||||
margin: 8px 0;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.footer {
|
||||
position: absolute;
|
||||
bottom: 32px;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
color: #a8a8a8;
|
||||
font-size: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
.footer-waflink {
|
||||
color: #27b876;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<table class="content">
|
||||
<tr>
|
||||
<td>
|
||||
<div class="logo">
|
||||
<svg
|
||||
width="200px"
|
||||
height="200px"
|
||||
viewBox="0 0 396 407"
|
||||
version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
>
|
||||
<title>编组 12</title>
|
||||
<defs>
|
||||
<linearGradient
|
||||
x1="50%"
|
||||
y1="0%"
|
||||
x2="50%"
|
||||
y2="100%"
|
||||
id="linearGradient-1"
|
||||
>
|
||||
<stop stop-color="#4B4B4B" offset="0%"></stop>
|
||||
<stop stop-color="#000000" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
<filter
|
||||
x="-3.0%"
|
||||
y="-2.8%"
|
||||
width="106.1%"
|
||||
height="105.6%"
|
||||
filterUnits="objectBoundingBox"
|
||||
id="filter-2"
|
||||
>
|
||||
<feGaussianBlur
|
||||
stdDeviation="3"
|
||||
in="SourceGraphic"
|
||||
></feGaussianBlur>
|
||||
</filter>
|
||||
<linearGradient
|
||||
x1="50%"
|
||||
y1="0%"
|
||||
x2="50%"
|
||||
y2="100%"
|
||||
id="linearGradient-3"
|
||||
>
|
||||
<stop
|
||||
stop-color="#24BC43"
|
||||
stop-opacity="0.8"
|
||||
offset="0%"
|
||||
></stop>
|
||||
<stop
|
||||
stop-color="#3ACBAB"
|
||||
stop-opacity="0.7"
|
||||
offset="100%"
|
||||
></stop>
|
||||
</linearGradient>
|
||||
<path
|
||||
d="M110.049657,49.667649 C110.049657,49.667649 81.1358702,46.2263115 76.8,26.7636364 C72.4880848,46.2263115 43.5503431,49.667649 43.5503431,49.667649 C14.2053649,53.3001718 0,36.4567369 0,36.4567369 C13.941859,65.8036979 38.4,64.7712967 38.4,64.7712967 L115.2,64.7712967 C115.2,64.7712967 139.634186,65.8036979 153.6,36.4567369 C153.6,36.4567369 139.394635,53.3192904 110.049657,49.667649 Z"
|
||||
id="path-4"
|
||||
></path>
|
||||
<filter
|
||||
x="-16.9%"
|
||||
y="-57.9%"
|
||||
width="133.9%"
|
||||
height="236.8%"
|
||||
filterUnits="objectBoundingBox"
|
||||
id="filter-5"
|
||||
>
|
||||
<feOffset
|
||||
dx="0"
|
||||
dy="4"
|
||||
in="SourceAlpha"
|
||||
result="shadowOffsetOuter1"
|
||||
></feOffset>
|
||||
<feGaussianBlur
|
||||
stdDeviation="8"
|
||||
in="shadowOffsetOuter1"
|
||||
result="shadowBlurOuter1"
|
||||
></feGaussianBlur>
|
||||
<feColorMatrix
|
||||
values="0 0 0 0 0 0 0 0 0 0.490319293 0 0 0 0 0.292243323 0 0 0 1 0"
|
||||
type="matrix"
|
||||
in="shadowBlurOuter1"
|
||||
></feColorMatrix>
|
||||
</filter>
|
||||
</defs>
|
||||
<g
|
||||
id="页面-1"
|
||||
stroke="none"
|
||||
stroke-width="1"
|
||||
fill="none"
|
||||
fill-rule="evenodd"
|
||||
>
|
||||
<g id="编组-12" transform="translate(49.000000, 38.000000)">
|
||||
<path
|
||||
d="M292.40836,59.04 C290.927217,51.9634286 285.002646,46.6971429 277.761503,46.368 C222.13636,44.8868571 176.385503,16.5805714 157.953503,3.08571429 C152.358074,-1.02857143 144.95236,-1.02857143 139.356931,3.08571429 C120.431217,16.5805714 75.1740742,44.8868571 19.5489314,46.368 C12.4723599,46.6971429 6.21864565,51.9634286 4.90207422,59.04 C-3.98478292,103.474286 -19.2899258,254.057143 148.902074,324 C316.60036,253.892571 300.966074,103.474286 292.40836,59.04 Z"
|
||||
id="路径"
|
||||
fill="url(#linearGradient-1)"
|
||||
fill-rule="nonzero"
|
||||
></path>
|
||||
<path
|
||||
d="M292.40836,59.04 C290.927217,51.9634286 285.002646,46.6971429 277.761503,46.368 C222.13636,44.8868571 176.385503,16.5805714 157.953503,3.08571429 C152.358074,-1.02857143 144.95236,-1.02857143 139.356931,3.08571429 C120.431217,16.5805714 75.1740742,44.8868571 19.5489314,46.368 C12.4723599,46.6971429 6.21864565,51.9634286 4.90207422,59.04 C-3.98478292,103.474286 -19.2899258,254.057143 148.902074,324 C316.60036,253.892571 300.966074,103.474286 292.40836,59.04 Z"
|
||||
id="路径"
|
||||
fill="url(#linearGradient-1)"
|
||||
fill-rule="nonzero"
|
||||
filter="url(#filter-2)"
|
||||
></path>
|
||||
<path
|
||||
d="M149,261.4 C205.553958,261.4 251.4,215.553958 251.4,159 C251.4,131.275004 240.381593,106.123494 222.484813,87.6855068 C209.900749,96.0964568 185.81512,106.024178 175.564259,100.853688 C166.334879,96.1984273 157.476591,88.4505652 148.989396,77.610101 C142.047769,88.5334102 134.670586,95.5517221 126.857848,98.6650367 C120.689419,101.123107 98.2592604,102.915695 75.4419467,87.761039 C57.5883513,106.192154 46.6,131.312844 46.6,159 C46.6,215.553958 92.4460416,261.4 149,261.4 Z"
|
||||
id="椭圆形备份-26"
|
||||
fill="url(#linearGradient-3)"
|
||||
></path>
|
||||
<g
|
||||
id="编组-5备份-6"
|
||||
transform="translate(91.771423, 102.101722)"
|
||||
fill="#FFFFFF"
|
||||
>
|
||||
<polygon
|
||||
id="路径-130备份-29"
|
||||
transform="translate(57.217971, 95.920999) rotate(-180.000000) translate(-57.217971, -95.920999) "
|
||||
points="56.6651511 64.9496372 -7.57241738e-17 97.1108413 50.6084036 126.892361 68.8016729 117.264704 34.3433228 97.1108413 56.6651511 84.5503086 96.9001091 107.376711 96.9001091 114.88399 114.435942 125.435553 114.435942 97.1108413"
|
||||
></polygon>
|
||||
<polygon
|
||||
id="路径-130备份-30"
|
||||
transform="translate(57.217971, 30.971362) rotate(-360.000000) translate(-57.217971, -30.971362) "
|
||||
points="56.6651511 2.84217094e-14 -7.57241738e-17 32.1612041 50.6084036 61.9427239 68.8016729 52.3150668 34.3433228 32.1612041 56.6651511 19.6006714 96.9001091 42.4270741 96.9001091 49.9343528 114.435942 60.4859155 114.435942 32.1612041"
|
||||
></polygon>
|
||||
<polygon
|
||||
id="路径-130备份-29"
|
||||
opacity="0.40499442"
|
||||
transform="translate(57.217971, 95.920999) rotate(-180.000000) translate(-57.217971, -95.920999) "
|
||||
points="56.6651511 64.9496372 -7.57241738e-17 97.1108413 50.6084036 126.892361 68.8016729 117.264704 34.3433228 97.1108413 56.6651511 84.5503086 96.9001091 107.376711 96.9001091 114.88399 114.435942 125.435553 114.435942 97.1108413"
|
||||
></polygon>
|
||||
<polygon
|
||||
id="路径-130备份-30"
|
||||
opacity="0.40499442"
|
||||
transform="translate(57.217971, 30.971362) rotate(-360.000000) translate(-57.217971, -30.971362) "
|
||||
points="56.6651511 4.8316906e-13 -7.57241738e-17 32.1612041 50.6084036 61.9427239 68.8016729 52.3150668 34.3433228 32.1612041 56.6651511 19.6006714 96.9001091 42.4270741 96.9001091 49.9343528 114.435942 60.4859155 114.435942 32.1612041"
|
||||
></polygon>
|
||||
</g>
|
||||
<g
|
||||
id="长亭logo备份-18"
|
||||
transform="translate(72.200000, 45.222222)"
|
||||
fill-rule="nonzero"
|
||||
>
|
||||
<g id="编组-7">
|
||||
<path
|
||||
d="M96.7632666,18.0061837 C96.7632666,18.0061837 79.3862969,15.2966085 76.7907961,0 C74.1952953,15.2966085 56.8183256,18.0061837 56.8183256,18.0061837 C39.1836466,20.8694936 30.6424242,7.60987058 30.6424242,7.60987058 C39.0363842,30.6893013 53.7258141,29.862977 53.7258141,29.862977 L99.8741859,29.862977 C99.8741859,29.862977 114.563616,30.6700845 122.957576,7.60987058 C122.957576,7.60987058 114.416353,20.8694936 96.7816744,18.0061837 L96.7632666,18.0061837 Z"
|
||||
id="路径"
|
||||
fill="#27B876"
|
||||
></path>
|
||||
<g id="路径">
|
||||
<use
|
||||
fill="black"
|
||||
fill-opacity="1"
|
||||
filter="url(#filter-5)"
|
||||
xlink:href="#path-4"
|
||||
></use>
|
||||
<use fill="#27B876" xlink:href="#path-4"></use>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
</div>
|
||||
<div id="intercepted" class="intercepted">
|
||||
请求频率过高,存在威胁,已被拦截
|
||||
</div>
|
||||
<div class="intercepted-item">
|
||||
<span id="intercepted-at">拦截时间</span>: <span id="now"></span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="footer" class="footer">
|
||||
安全检测能力由
|
||||
<a class="footer-waflink" href="https://waf-ce.chaitin.cn"
|
||||
>长亭雷池 WAF</a
|
||||
>
|
||||
驱动
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
// 显示当前时间
|
||||
function timestring() {
|
||||
var d = new Date();
|
||||
function p(d) {
|
||||
return d < 10 ? "0" + d : d;
|
||||
}
|
||||
return (
|
||||
d.getFullYear() +
|
||||
"-" +
|
||||
p(d.getMonth() + 1) +
|
||||
"-" +
|
||||
p(d.getDate()) +
|
||||
" " +
|
||||
p(d.getHours()) +
|
||||
":" +
|
||||
p(d.getMinutes())
|
||||
);
|
||||
}
|
||||
document.getElementById("now").innerText = timestring();
|
||||
</script>
|
||||
|
||||
<script>
|
||||
if (navigator.language.startsWith("en")) {
|
||||
document.title = "Requested too frequently";
|
||||
|
||||
document.getElementById("intercepted").innerText =
|
||||
"Requested too frequently, please try again later";
|
||||
document.getElementById("intercepted-at").innerText = "Intercepted at";
|
||||
document.getElementById("footer").style.display = "none";
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
212
blockpage/maintaining.html
Normal file
|
@ -0,0 +1,212 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<title>网站维护中</title>
|
||||
<style>
|
||||
html {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.container {
|
||||
text-align: center;
|
||||
word-break: keep-all;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background: white;
|
||||
font-size: 12px;
|
||||
min-height: 450px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.logo {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.intercepted {
|
||||
margin-top: 3.5rem;
|
||||
margin-bottom: 1.5rem;
|
||||
font-size: 20px;
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.intercepted-item {
|
||||
margin: 8px 0;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.footer {
|
||||
position: absolute;
|
||||
bottom: 32px;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
color: #a8a8a8;
|
||||
font-size: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
.footer-waflink {
|
||||
color: #27b876;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<table class="content">
|
||||
<tr>
|
||||
<td>
|
||||
<div class="logo">
|
||||
<svg
|
||||
width="300px"
|
||||
height="112px"
|
||||
viewBox="0 0 300 112"
|
||||
version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
>
|
||||
<title>编组 65</title>
|
||||
<defs>
|
||||
<linearGradient
|
||||
x1="50%"
|
||||
y1="0%"
|
||||
x2="50%"
|
||||
y2="100%"
|
||||
id="linearGradient-1"
|
||||
>
|
||||
<stop
|
||||
stop-color="#0FC6C2"
|
||||
stop-opacity="0.1"
|
||||
offset="0%"
|
||||
></stop>
|
||||
<stop
|
||||
stop-color="#0FC6C2"
|
||||
stop-opacity="0"
|
||||
offset="100%"
|
||||
></stop>
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
x1="50%"
|
||||
y1="0%"
|
||||
x2="50%"
|
||||
y2="100%"
|
||||
id="linearGradient-2"
|
||||
>
|
||||
<stop stop-color="#A9D6D3" offset="0%"></stop>
|
||||
<stop stop-color="#8EC6C4" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
x1="17.048305%"
|
||||
y1="8.1635079%"
|
||||
x2="76.1348779%"
|
||||
y2="89.9397366%"
|
||||
id="linearGradient-3"
|
||||
>
|
||||
<stop stop-color="#ECF7F7" offset="0%"></stop>
|
||||
<stop stop-color="#CEEFEE" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g
|
||||
id="问脉"
|
||||
stroke="none"
|
||||
stroke-width="1"
|
||||
fill="none"
|
||||
fill-rule="evenodd"
|
||||
>
|
||||
<g id="编组-65" transform="translate(0.000000, 0.656106)">
|
||||
<path
|
||||
d="M158.105468,46.4305012 C230.638275,48.8882768 280.048484,89.2493521 291.411562,97.5896283 C298.986948,103.149812 301.288867,107.707461 298.317319,111.262574 L0,111.262574 C57.0484407,66.4026752 109.750263,44.7919842 158.105468,46.4305012 Z"
|
||||
id="路径-14备份"
|
||||
fill="url(#linearGradient-1)"
|
||||
opacity="0.6"
|
||||
></path>
|
||||
<path
|
||||
d="M133.744707,59.2516792 C128.220216,62.212914 142.271748,72.3438938 152.603912,72.3438938 C162.936076,72.3438938 170.384509,66.1002168 166.415224,63.7091176 C162.445939,61.3180184 139.269199,56.2904444 133.744707,59.2516792 Z"
|
||||
id="路径-23备份"
|
||||
fill="#CEEEED"
|
||||
></path>
|
||||
<g
|
||||
id="维护备份"
|
||||
transform="translate(125.841376, 4.000000)"
|
||||
fill="url(#linearGradient-2)"
|
||||
fill-rule="nonzero"
|
||||
>
|
||||
<path
|
||||
d="M53.4407915,17.8309532 C49.850381,20.6412105 45.048111,20.2807339 42.738148,17.0275722 C40.428185,13.7744105 41.4704292,8.83897736 45.0608397,6.02872002 L48.4302392,3.3908402 C50.2893442,1.93421992 49.6588911,0.00928311389 46.813125,0.241953931 C43.8131226,0.486558233 40.8354442,1.6843377 38.3140089,3.66074708 C34.2763868,6.82838427 31.8308675,11.6191742 31.8089552,16.4041942 L3.55036904,38.5271177 C-0.0421309333,41.3487126 -1.07876034,46.2575577 1.22851314,49.522012 C2.33804924,51.0840803 4.09016048,52.0468265 6.09769574,52.1975197 C8.105231,52.3482129 10.2029338,51.6744483 11.9272901,50.3251027 L40.1897428,28.2024695 C43.7454976,29.2914901 47.8019094,28.7846954 51.4034487,26.8014661 C55.004988,24.8182368 57.8332485,21.5339069 59.2220045,17.7221341 C60.2487908,14.9244912 58.6731626,13.7367433 56.810191,15.1930733 L53.4407915,17.8309532 Z M5.56827104,46.1206895 C4.79626286,45.0334702 5.14228458,43.3949223 6.34222301,42.4557247 C7.541301,41.5714856 9.09674694,41.7145817 9.85296424,42.7787018 C10.6091815,43.842822 10.2920189,45.4421908 9.13710773,46.3885799 C7.9371693,47.3277774 6.34027921,47.2079088 5.56827104,46.1206895 Z M13.7446583,12.4428814 L20.5888502,22.087378 L24.9316389,18.6903037 L18.087447,9.04580702 L16.9394989,5.05163029 L11.6667257,0 L7.32393706,3.39707438 L10.4272492,10.147387 L13.7446583,12.4428814 Z M38.1657743,33.2576704 C37.8311845,33.2325548 37.4815663,33.3450613 37.1943929,33.5702592 L30.6813074,38.6699737 C30.0831963,39.1405877 29.9105495,39.9581375 30.2943314,40.5024561 L40.1788997,54.4239027 C41.7237519,56.5943835 44.9213986,56.8344109 47.3165731,54.9596835 C49.7156141,53.0852463 50.4093292,49.8002347 48.8653128,47.6257961 L38.976878,33.7040592 C38.7922954,33.4434496 38.5003642,33.282786 38.1657743,33.2576704 Z"
|
||||
id="形状"
|
||||
></path>
|
||||
</g>
|
||||
<g
|
||||
id="维护备份-2"
|
||||
transform="translate(123.841376, 0.000000)"
|
||||
fill="url(#linearGradient-3)"
|
||||
fill-rule="nonzero"
|
||||
>
|
||||
<path
|
||||
d="M53.4407915,17.8309532 C49.850381,20.6412105 45.048111,20.2807339 42.738148,17.0275722 C40.428185,13.7744105 41.4704292,8.83897736 45.0608397,6.02872002 L48.4302392,3.3908402 C50.2893442,1.93421992 49.6588911,0.00928311389 46.813125,0.241953931 C43.8131226,0.486558233 40.8354442,1.6843377 38.3140089,3.66074708 C34.2763868,6.82838427 31.8308675,11.6191742 31.8089552,16.4041942 L3.55036904,38.5271177 C-0.0421309333,41.3487126 -1.07876034,46.2575577 1.22851314,49.522012 C2.33804924,51.0840803 4.09016048,52.0468265 6.09769574,52.1975197 C8.105231,52.3482129 10.2029338,51.6744483 11.9272901,50.3251027 L40.1897428,28.2024695 C43.7454976,29.2914901 47.8019094,28.7846954 51.4034487,26.8014661 C55.004988,24.8182368 57.8332485,21.5339069 59.2220045,17.7221341 C60.2487908,14.9244912 58.6731626,13.7367433 56.810191,15.1930733 L53.4407915,17.8309532 Z M5.56827104,46.1206895 C4.79626286,45.0334702 5.14228458,43.3949223 6.34222301,42.4557247 C7.541301,41.5714856 9.09674694,41.7145817 9.85296424,42.7787018 C10.6091815,43.842822 10.2920189,45.4421908 9.13710773,46.3885799 C7.9371693,47.3277774 6.34027921,47.2079088 5.56827104,46.1206895 Z M13.7446583,12.4428814 L20.5888502,22.087378 L24.9316389,18.6903037 L18.087447,9.04580702 L16.9394989,5.05163029 L11.6667257,0 L7.32393706,3.39707438 L10.4272492,10.147387 L13.7446583,12.4428814 Z M38.1657743,33.2576704 C37.8311845,33.2325548 37.4815663,33.3450613 37.1943929,33.5702592 L30.6813074,38.6699737 C30.0831963,39.1405877 29.9105495,39.9581375 30.2943314,40.5024561 L40.1788997,54.4239027 C41.7237519,56.5943835 44.9213986,56.8344109 47.3165731,54.9596835 C49.7156141,53.0852463 50.4093292,49.8002347 48.8653128,47.6257961 L38.976878,33.7040592 C38.7922954,33.4434496 38.5003642,33.282786 38.1657743,33.2576704 Z"
|
||||
id="形状"
|
||||
></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="intercepted" id="intercepted">
|
||||
网站维护中,暂时无法访问
|
||||
</div>
|
||||
<div class="intercepted-item"><span id="now"></span></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="footer" id="footer">
|
||||
安全检测能力由
|
||||
<a class="footer-waflink" href="https://waf-ce.chaitin.cn"
|
||||
>长亭雷池 WAF</a
|
||||
>
|
||||
驱动
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
// 显示当前时间
|
||||
function timestring() {
|
||||
var d = new Date();
|
||||
function p(d) {
|
||||
return d < 10 ? "0" + d : d;
|
||||
}
|
||||
return (
|
||||
d.getFullYear() +
|
||||
"-" +
|
||||
p(d.getMonth() + 1) +
|
||||
"-" +
|
||||
p(d.getDate()) +
|
||||
" " +
|
||||
p(d.getHours()) +
|
||||
":" +
|
||||
p(d.getMinutes())
|
||||
);
|
||||
}
|
||||
document.getElementById("now").innerText = timestring();
|
||||
</script>
|
||||
<script>
|
||||
if (navigator.language.startsWith("en")) {
|
||||
document.title = "Site is Maintaining";
|
||||
|
||||
document.getElementById("intercepted").innerText =
|
||||
"The site is on maintaining, please try again later";
|
||||
document.getElementById("footer").style.display = "none";
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
176
compose.yaml
|
@ -5,135 +5,115 @@ networks:
|
|||
ipam:
|
||||
driver: default
|
||||
config:
|
||||
- gateway: ${SUBNET_PREFIX:?SUBNET_PREFIX required}.1
|
||||
subnet: ${SUBNET_PREFIX}.0/24
|
||||
- gateway: ${SUBNET_PREFIX:?SUBNET_PREFIX required}.1
|
||||
subnet: ${SUBNET_PREFIX}.0/24
|
||||
driver_opts:
|
||||
com.docker.network.bridge.name: safeline-ce
|
||||
|
||||
services:
|
||||
postgres:
|
||||
container_name: safeline-pg
|
||||
container_name: safeline-postgres
|
||||
restart: always
|
||||
image: ${IMAGE_PREFIX}/safeline-postgres${ARCH_SUFFIX}:15.2
|
||||
image: postgres:15.2
|
||||
volumes:
|
||||
- ${SAFELINE_DIR}/resources/postgres/data:/var/lib/postgresql/data
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- ${SAFELINE_DIR}/resources/postgres/data:/var/lib/postgresql/data
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
environment:
|
||||
- POSTGRES_USER=safeline-ce
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:?postgres password required}
|
||||
- POSTGRES_USER=safeline-ce
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:?postgres password required}
|
||||
networks:
|
||||
safeline-ce:
|
||||
ipv4_address: ${SUBNET_PREFIX}.2
|
||||
command: [postgres, -c, max_connections=600]
|
||||
healthcheck:
|
||||
test: pg_isready -U safeline-ce -d safeline-ce
|
||||
mgt:
|
||||
container_name: safeline-mgt
|
||||
cap_drop:
|
||||
- net_raw
|
||||
command: [postgres, -c, max_connections=200]
|
||||
redis:
|
||||
container_name: safeline-redis
|
||||
restart: always
|
||||
image: ${IMAGE_PREFIX}/safeline-mgt${REGION}${ARCH_SUFFIX}${RELEASE}:${IMAGE_TAG:?image tag required}
|
||||
image: redis:7.0.10
|
||||
volumes:
|
||||
- ${SAFELINE_DIR}/resources/redis/data:/data
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- ${SAFELINE_DIR}/resources/mgt:/app/data
|
||||
- ${SAFELINE_DIR}/logs/nginx:/app/log/nginx:z
|
||||
- ${SAFELINE_DIR}/resources/sock:/app/sock
|
||||
- /var/run:/app/run
|
||||
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD}
|
||||
networks:
|
||||
safeline-ce:
|
||||
ipv4_address: ${SUBNET_PREFIX}.3
|
||||
cap_drop:
|
||||
- net_raw
|
||||
sysctls:
|
||||
net.core.somaxconn: "511"
|
||||
management:
|
||||
container_name: safeline-mgt-api
|
||||
restart: always
|
||||
image: chaitin/safeline-mgt-api:${IMAGE_TAG:?image tag required}
|
||||
volumes:
|
||||
- ${SAFELINE_DIR?safeline dir required}/resources/management:/resources/management
|
||||
- ${SAFELINE_DIR}/resources/nginx:/resources/nginx
|
||||
- ${SAFELINE_DIR}/logs:/logs
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
ports:
|
||||
- ${MGT_PORT:-9443}:1443
|
||||
healthcheck:
|
||||
test: curl -k -f https://localhost:1443/api/open/health
|
||||
- ${MGT_PORT:-9443}:1443
|
||||
environment:
|
||||
- MGT_PG=postgres://safeline-ce:${POSTGRES_PASSWORD}@safeline-pg/safeline-ce?sslmode=disable
|
||||
depends_on:
|
||||
- postgres
|
||||
- fvm
|
||||
logging:
|
||||
options:
|
||||
max-size: "100m"
|
||||
max-file: "5"
|
||||
- MANAGEMENT_RESOURCES_DIR=/resources/management
|
||||
- NGINX_RESOURCES_DIR=/resources/nginx
|
||||
- DATABASE_URL=postgres://safeline-ce:${POSTGRES_PASSWORD}@safeline-postgres/safeline-ce
|
||||
- MARIO_URL=http://safeline-mario:3335
|
||||
- DETECTOR_URL=http://safeline-detector:8001
|
||||
- REDIS_URL=redis://:${REDIS_PASSWORD}@safeline-redis:6379/0
|
||||
- MANAGEMENT_LOGS_DIR=/logs/management
|
||||
dns: 223.5.5.5
|
||||
networks:
|
||||
safeline-ce:
|
||||
ipv4_address: ${SUBNET_PREFIX}.4
|
||||
detect:
|
||||
cap_drop:
|
||||
- net_raw
|
||||
detector:
|
||||
container_name: safeline-detector
|
||||
restart: always
|
||||
image: ${IMAGE_PREFIX}/safeline-detector${REGION}${ARCH_SUFFIX}${RELEASE}:${IMAGE_TAG}
|
||||
image: chaitin/safeline-detector:${IMAGE_TAG}
|
||||
volumes:
|
||||
- ${SAFELINE_DIR}/resources/detector:/resources/detector
|
||||
- ${SAFELINE_DIR}/logs/detector:/logs/detector
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- ${SAFELINE_DIR}/resources/detector:/resources/detector
|
||||
- ${SAFELINE_DIR}/logs/detector:/logs/detector
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
environment:
|
||||
- LOG_DIR=/logs/detector
|
||||
- LOG_DIR=/logs/detector
|
||||
networks:
|
||||
safeline-ce:
|
||||
ipv4_address: ${SUBNET_PREFIX}.5
|
||||
cap_drop:
|
||||
- net_raw
|
||||
mario:
|
||||
container_name: safeline-mario
|
||||
restart: always
|
||||
image: chaitin/safeline-mario:${IMAGE_TAG}
|
||||
volumes:
|
||||
- ${SAFELINE_DIR}/resources/mario:/resources/mario
|
||||
- ${SAFELINE_DIR}/logs/mario:/logs/mario
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
environment:
|
||||
- LOG_DIR=/logs/mario
|
||||
- GOGC=100
|
||||
- DATABASE_URL=postgres://safeline-ce:${POSTGRES_PASSWORD}@safeline-postgres/safeline-ce
|
||||
- REDIS_URL=redis://:${REDIS_PASSWORD}@safeline-redis:6379/0
|
||||
networks:
|
||||
safeline-ce:
|
||||
ipv4_address: ${SUBNET_PREFIX}.6
|
||||
cap_drop:
|
||||
- net_raw
|
||||
tengine:
|
||||
container_name: safeline-tengine
|
||||
restart: always
|
||||
image: ${IMAGE_PREFIX}/safeline-tengine${REGION}${ARCH_SUFFIX}${RELEASE}:${IMAGE_TAG}
|
||||
image: chaitin/safeline-tengine:${IMAGE_TAG}
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- /etc/resolv.conf:/etc/resolv.conf:ro
|
||||
- ${SAFELINE_DIR}/resources/nginx:/etc/nginx
|
||||
- ${SAFELINE_DIR}/resources/detector:/resources/detector
|
||||
- ${SAFELINE_DIR}/resources/chaos:/resources/chaos
|
||||
- ${SAFELINE_DIR}/logs/nginx:/var/log/nginx:z
|
||||
- ${SAFELINE_DIR}/resources/cache:/usr/local/nginx/cache
|
||||
- ${SAFELINE_DIR}/resources/sock:/app/sock
|
||||
- ${SAFELINE_DIR}/resources/nginx:/etc/nginx
|
||||
- ${SAFELINE_DIR}/resources/management:/resources/management
|
||||
- ${SAFELINE_DIR}/resources/detector:/resources/detector
|
||||
- ${SAFELINE_DIR}/logs/nginx:/var/log/nginx
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- ${SAFELINE_DIR}/resources/cache:/usr/local/nginx/cache
|
||||
- /etc/resolv.conf:/etc/resolv.conf
|
||||
environment:
|
||||
- TCD_MGT_API=https://${SUBNET_PREFIX}.4:1443/api/open/publish/server
|
||||
- TCD_SNSERVER=${SUBNET_PREFIX}.5:8000
|
||||
# deprecated
|
||||
- SNSERVER_ADDR=${SUBNET_PREFIX}.5:8000
|
||||
- CHAOS_ADDR=${SUBNET_PREFIX}.10
|
||||
- MGT_ADDR=${SUBNET_PREFIX}.4:9002
|
||||
ulimits:
|
||||
nofile: 131072
|
||||
network_mode: host
|
||||
luigi:
|
||||
container_name: safeline-luigi
|
||||
restart: always
|
||||
image: ${IMAGE_PREFIX}/safeline-luigi${REGION}${ARCH_SUFFIX}${RELEASE}:${IMAGE_TAG}
|
||||
environment:
|
||||
- MGT_IP=${SUBNET_PREFIX}.4
|
||||
- LUIGI_PG=postgres://safeline-ce:${POSTGRES_PASSWORD}@safeline-pg/safeline-ce?sslmode=disable
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- ${SAFELINE_DIR}/resources/luigi:/app/data
|
||||
logging:
|
||||
options:
|
||||
max-size: "100m"
|
||||
max-file: "5"
|
||||
depends_on:
|
||||
- detect
|
||||
- mgt
|
||||
networks:
|
||||
safeline-ce:
|
||||
ipv4_address: ${SUBNET_PREFIX}.7
|
||||
fvm:
|
||||
container_name: safeline-fvm
|
||||
restart: always
|
||||
image: ${IMAGE_PREFIX}/safeline-fvm${REGION}${ARCH_SUFFIX}${RELEASE}:${IMAGE_TAG}
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
logging:
|
||||
options:
|
||||
max-size: "100m"
|
||||
max-file: "5"
|
||||
networks:
|
||||
safeline-ce:
|
||||
ipv4_address: ${SUBNET_PREFIX}.8
|
||||
chaos:
|
||||
container_name: safeline-chaos
|
||||
restart: always
|
||||
image: ${IMAGE_PREFIX}/safeline-chaos${REGION}${ARCH_SUFFIX}${RELEASE}:${IMAGE_TAG}
|
||||
logging:
|
||||
options:
|
||||
max-size: "100m"
|
||||
max-file: "10"
|
||||
environment:
|
||||
- DB_ADDR=postgres://safeline-ce:${POSTGRES_PASSWORD}@safeline-pg/safeline-ce?sslmode=disable
|
||||
volumes:
|
||||
- ${SAFELINE_DIR}/resources/sock:/app/sock
|
||||
- ${SAFELINE_DIR}/resources/chaos:/app/chaos
|
||||
networks:
|
||||
safeline-ce:
|
||||
ipv4_address: ${SUBNET_PREFIX}.10
|
Before Width: | Height: | Size: 1.3 MiB |
Before Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 226 KiB |
Before Width: | Height: | Size: 245 KiB |
Before Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 821 KiB |
Before Width: | Height: | Size: 806 KiB |
Before Width: | Height: | Size: 141 KiB |
Before Width: | Height: | Size: 281 KiB |
Before Width: | Height: | Size: 148 KiB |
Before Width: | Height: | Size: 276 KiB |
Before Width: | Height: | Size: 501 KiB |
Before Width: | Height: | Size: 1.3 MiB |
Before Width: | Height: | Size: 343 KiB |
Before Width: | Height: | Size: 353 KiB |
Before Width: | Height: | Size: 243 KiB |
Before Width: | Height: | Size: 113 KiB |
Before Width: | Height: | Size: 68 KiB |
1
lua-resty-t1k
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 64461663018b9e5436e51fc30d68a808459096f3
|
17
management/.gitignore
vendored
|
@ -1,17 +0,0 @@
|
|||
# Test binary, build with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
**/.idea
|
||||
*.iml
|
||||
|
||||
#OSX system files.
|
||||
**/.DS_Store
|
||||
|
||||
/build
|
||||
|
||||
*.pb.go
|
||||
|
||||
submodule/
|
|
@ -1,15 +0,0 @@
|
|||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- deadcode
|
||||
- errcheck
|
||||
- gofmt
|
||||
- goimports
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- typecheck
|
||||
- unused
|
||||
- varcheck
|
|
@ -1,46 +0,0 @@
|
|||
GO = GO111MODULE=on go
|
||||
#GO = GO111MODULE=on GOOS=linux GOARCH=amd64 go
|
||||
GOBUILD = $(GO) build -mod=readonly
|
||||
GOTEST = $(GO) test -v -p 1 -coverprofile=coverage-management.out
|
||||
|
||||
STAMP = $(shell date +%s)
|
||||
GITHASH = $(shell git rev-parse --short=8 HEAD)
|
||||
GITTAG = $(shell git describe --tags --abbrev=0)
|
||||
|
||||
BUILDFLAGS := -ldflags "-X main.buildstamp=$(STAMP) -X main.githash=$(GITHASH) -X main.version=$(GITTAG)"
|
||||
pkgs = ./...
|
||||
|
||||
all: build-all
|
||||
|
||||
.PHONY: build-all
|
||||
build-all: proto build-webserver build-tcd
|
||||
|
||||
.PHONY: build-webserver
|
||||
build-webserver:
|
||||
cd webserver && $(GOBUILD) $(BUILDFLAGS) -o ../build/webserver main.go
|
||||
|
||||
.PHONY: build-tcd
|
||||
build-tcd:
|
||||
cd tcontrollerd && CGO_ENABLED=0 $(GOBUILD) $(BUILDFLAGS) -o ../build/tcontrollerd main.go
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
$(GOTEST) -failfast $(pkgs)
|
||||
|
||||
.PHONY: proto
|
||||
proto:
|
||||
@./scripts/genproto.sh
|
||||
|
||||
.PHONY: lint
|
||||
lint:
|
||||
# 'go list' needs to be executed before staticcheck to prepopulate the modules cache.
|
||||
# Otherwise staticcheck might fail randomly for some reason not yet explained.
|
||||
$(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
|
||||
goimports -local chaitin.cn -w $$(find . -type f -name '*.go' -not -path "./vendor/*")
|
||||
golangci-lint version
|
||||
cd webserver && golangci-lint run -v --skip-dirs vendor --deadline 10m
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf build
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# Management Micro Service
|
||||
|
||||
## Requirements
|
||||
|
||||
Go 1.18+
|
|
@ -1,33 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Generate all protobuf bindings.
|
||||
# Run from repository root.
|
||||
|
||||
set -u
|
||||
|
||||
if ! [[ "$0" =~ scripts/genproto.sh ]]; then
|
||||
echo "must be run from repository root"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
DIRS="webserver/proto tcontrollerd/proto"
|
||||
|
||||
echo "generating code"
|
||||
protoc --version
|
||||
for dir in ${DIRS}; do
|
||||
pushd "${dir}" || return
|
||||
find . -type d -print0 | while IFS= read -r -d '' sdir ; do
|
||||
pushd "${sdir}" || return
|
||||
# shellcheck disable=SC2010
|
||||
FS=$(ls | grep "\.proto\$")
|
||||
if [ -n "${FS}" ] ; then
|
||||
protoc --go_out=. --go_opt=paths=source_relative \
|
||||
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
|
||||
"${FS}"
|
||||
|
||||
goimports -local chaitin.cn -w ./*.pb.go
|
||||
fi
|
||||
popd || return
|
||||
done
|
||||
popd || return
|
||||
done
|
|
@ -1,29 +0,0 @@
|
|||
# TControllerD
|
||||
|
||||
Tengine Controller Daemon (abbr. TCD) will be running in the Tengine container,
|
||||
designed to be in place with minion on the host machine.
|
||||
|
||||
## Requirements
|
||||
|
||||
Go 1.18+
|
||||
|
||||
## Development
|
||||
|
||||
### init protobuf
|
||||
|
||||
```shell
|
||||
# Refer: https://grpc.io/docs/languages/go/quickstart/
|
||||
# 1. Install protoc
|
||||
# https://grpc.io/docs/protoc-installation/
|
||||
|
||||
# 2. Install Go plugins
|
||||
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30.0
|
||||
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0
|
||||
|
||||
# 3. Update your PATH so that the protoc compiler can find the plugins
|
||||
# export PATH="$PATH:$(go env GOPATH)/bin"
|
||||
|
||||
# 4. Generate proto go code
|
||||
# cd /path/to/management
|
||||
./scripts/genproto.sh
|
||||
```
|
|
@ -1,5 +0,0 @@
|
|||
# develop use only. For production, refer to `package/build/tengine/tcontrollerd/config.yml`
|
||||
log:
|
||||
output: stdout # "stdout", "stderr" or file path
|
||||
level: debug # "debug", "info", "warn" or "error"
|
||||
mgt_addr: 169.254.0.4:9002 # gRPC addr of mgt-api webserver
|
|
@ -1,41 +0,0 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/tcontrollerd/pkg/config"
|
||||
"chaitin.cn/patronus/safeline-2/management/tcontrollerd/pkg/log"
|
||||
pb "chaitin.cn/patronus/safeline-2/management/tcontrollerd/proto/website"
|
||||
)
|
||||
|
||||
var (
|
||||
logger = log.GetLogger("controller")
|
||||
)
|
||||
|
||||
func Handle() error {
|
||||
logger.Infof("Connect mgt-webserver at %s", config.GlobalConfig.MgtWebserver)
|
||||
gRPCConn, err := grpc.Dial(config.GlobalConfig.MgtWebserver, []grpc.DialOption{
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
}...)
|
||||
if err != nil {
|
||||
logger.Errorf("Fail to dial: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
wsClient := pb.NewWebsiteClient(gRPCConn)
|
||||
|
||||
defer func(conn *grpc.ClientConn) {
|
||||
err := conn.Close()
|
||||
if err != nil {
|
||||
logger.Errorf("Fail to close: %v", err)
|
||||
return
|
||||
}
|
||||
}(gRPCConn)
|
||||
|
||||
if err = websiteHandler(wsClient); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package controller
|
||||
|
||||
var nginxConfigTpl = `
|
||||
upstream %s {
|
||||
%s
|
||||
keepalive 128;
|
||||
keepalive_timeout 75;
|
||||
}
|
||||
server {
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
location = /forbidden_page {
|
||||
internal;
|
||||
root /etc/nginx/forbidden_pages;
|
||||
try_files /default_forbidden_page.html =403;
|
||||
}
|
||||
location ^~ / {
|
||||
proxy_pass %s://%s;
|
||||
include proxy_params;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Accept-Encoding "";
|
||||
t1k_append_header SL-CE-SUID %d;
|
||||
t1k_body_size 1024k;
|
||||
tx_body_size 4k;
|
||||
t1k_error_page 403 /forbidden_page;
|
||||
tx_error_page 403 /forbidden_page;
|
||||
}
|
||||
}`
|
||||
|
||||
var upstreamAddrTpl = `server %s;`
|
||||
var serverListenTpl = `listen 0.0.0.0:%s%s%s;`
|
||||
var addrAnyPropertiesTpl = " default_server backlog=65536 reuseport"
|
||||
var serverNameTpl = `server_name %s;`
|
||||
var certTpl = `ssl_certificate /etc/nginx/certs/%s;`
|
||||
var certKeyTpl = `ssl_certificate_key /etc/nginx/certs/%s;`
|
||||
var backendTpl = `backend_%d`
|
|
@ -1,296 +0,0 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/tcontrollerd/model"
|
||||
"chaitin.cn/patronus/safeline-2/management/tcontrollerd/pkg/ngcmd"
|
||||
pb "chaitin.cn/patronus/safeline-2/management/tcontrollerd/proto/website"
|
||||
"chaitin.cn/patronus/safeline-2/management/tcontrollerd/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
Ping = "ping"
|
||||
Pong = "pong"
|
||||
EventTypeWebsite = "website"
|
||||
EventTypeDeleteWebsite = "deleteWebsite"
|
||||
EventTypeFullWebsite = "fullWebsite"
|
||||
|
||||
nginxConfigPath = "/etc/nginx/sites-enabled/" // 修改的为 host /resources/nginx/ 中的文件
|
||||
nginxFilePrefix = "IF_backend_"
|
||||
nginxBackupFilePrefix = "BAK_IF_backend_"
|
||||
nginxFileMode = 0644
|
||||
|
||||
HttpsScheme = "https"
|
||||
DefaultHttpsPort = "443"
|
||||
)
|
||||
|
||||
var pong = pb.Response{Type: Pong, Msg: nil, Err: false}
|
||||
|
||||
func generateNginxConfig(website *model.WebsiteConfig) (string, error) {
|
||||
// only ONE upstream supported in v1.0
|
||||
var upstreamAddr string
|
||||
scheme := "http"
|
||||
for _, upstream := range website.Upstreams {
|
||||
urlInfo, err := url.Parse(upstream)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if urlInfo.Scheme == HttpsScheme && urlInfo.Port() == "" {
|
||||
urlInfo.Host = urlInfo.Host + ":" + DefaultHttpsPort
|
||||
}
|
||||
upstreamAddr = fmt.Sprintf(upstreamAddrTpl, urlInfo.Host)
|
||||
if len(urlInfo.Scheme) > 0 {
|
||||
scheme = urlInfo.Scheme
|
||||
}
|
||||
}
|
||||
|
||||
sslFlag := ""
|
||||
sslCertFilename := ""
|
||||
sslCertKeyFilename := ""
|
||||
if website.KeyFilename != "" && website.CertFilename != "" {
|
||||
sslFlag = " ssl" // with a blank ahead
|
||||
sslCertFilename = fmt.Sprintf(certTpl, website.CertFilename)
|
||||
sslCertKeyFilename = fmt.Sprintf(certKeyTpl, website.KeyFilename)
|
||||
}
|
||||
|
||||
// only ONE server name supported in v1.0
|
||||
var serverName string
|
||||
var addrAnyProperties string
|
||||
for _, sn := range website.ServerNames {
|
||||
if sn == "*" || sn == "" {
|
||||
sn = "_"
|
||||
addrAnyProperties = addrAnyPropertiesTpl
|
||||
}
|
||||
serverName = fmt.Sprintf(serverNameTpl, sn)
|
||||
}
|
||||
|
||||
// only ONE port supported in v1.0
|
||||
var serverListen string
|
||||
for _, port := range website.Ports {
|
||||
serverListen = fmt.Sprintf(serverListenTpl, port, sslFlag, addrAnyProperties)
|
||||
}
|
||||
|
||||
upstreamName := fmt.Sprintf(backendTpl, website.Id)
|
||||
nginxConfig := strings.TrimSpace(fmt.Sprintf(nginxConfigTpl, upstreamName, upstreamAddr, serverListen, serverName, sslCertFilename, sslCertKeyFilename, scheme, upstreamName, website.Id))
|
||||
return nginxConfig, nil
|
||||
}
|
||||
|
||||
func nginxTestAndReload() error {
|
||||
err := ngcmd.NginxConfTest()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = ngcmd.NginxConfReload()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func generateFullConfigAndReload(msg []byte) error {
|
||||
var websites []model.WebsiteConfig
|
||||
if err := json.Unmarshal(msg, &websites); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
configFilename := make(map[string]struct{})
|
||||
for _, website := range websites {
|
||||
configFilename[fmt.Sprintf("%s%d", nginxFilePrefix, website.Id)] = struct{}{}
|
||||
}
|
||||
filepath.Walk(nginxConfigPath, func(path string, info fs.FileInfo, err error) error {
|
||||
_, ok := configFilename[info.Name()]
|
||||
if !ok && strings.HasPrefix(info.Name(), nginxFilePrefix) {
|
||||
if err := os.Remove(path); err != nil {
|
||||
// not return error only logged error in order to delete not exist website nginx conf
|
||||
logger.Warn(err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
for _, website := range websites {
|
||||
if err := generateConfigAndReload(&website); err != nil {
|
||||
// trigger a full site push when tcd starts, ignore some site errors, and push as much as possible
|
||||
logger.Warn(err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func generateConfigAndReload(website *model.WebsiteConfig) error {
|
||||
nginxConfig, err := generateNginxConfig(website)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
configPath := filepath.Join(nginxConfigPath, fmt.Sprintf("%s%d", nginxFilePrefix, website.Id))
|
||||
backupPath := filepath.Join(nginxConfigPath, fmt.Sprintf("%s%d", nginxBackupFilePrefix, website.Id))
|
||||
|
||||
oldConfigExists, err := utils.FileExist(configPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if oldConfigExists {
|
||||
oldConfig, err := ioutil.ReadFile(configPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if string(oldConfig) == nginxConfig {
|
||||
logger.Info("No changes in the new website config, skip nginx -s reload")
|
||||
return nil
|
||||
}
|
||||
|
||||
// tmp save old config to the backup path
|
||||
if err = utils.CopyFile(configPath, backupPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err = utils.EnsureWriteFile(configPath, []byte(nginxConfig), nginxFileMode); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = nginxTestAndReload(); err != nil {
|
||||
nginxError := err
|
||||
if err = os.Remove(configPath); err != nil {
|
||||
return err
|
||||
}
|
||||
if oldConfigExists {
|
||||
// new config err, restore old config
|
||||
if err = utils.CopyFile(backupPath, configPath); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = os.Remove(backupPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nginxError
|
||||
}
|
||||
|
||||
if oldConfigExists {
|
||||
if err = os.Remove(backupPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func deleteConfigAndReload(config []byte) error {
|
||||
var websiteIds []uint
|
||||
if err := json.Unmarshal(config, &websiteIds); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, id := range websiteIds {
|
||||
configPath := filepath.Join(nginxConfigPath, fmt.Sprintf("%s%d", nginxFilePrefix, id))
|
||||
exists, err := utils.FileExist(configPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if exists {
|
||||
if err := os.Remove(configPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := nginxTestAndReload(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func sendResponse(stream pb.Website_SubscribeClient, eventType string, errMsg []byte) error {
|
||||
return stream.Send(&pb.Response{
|
||||
Type: eventType,
|
||||
Msg: errMsg,
|
||||
Err: len(errMsg) != 0,
|
||||
})
|
||||
}
|
||||
|
||||
func websiteHandler(wc pb.WebsiteClient) error {
|
||||
stream, err := wc.Subscribe(context.Background())
|
||||
if err != nil {
|
||||
logger.Errorf("Subscribe failed: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
for {
|
||||
event, err := stream.Recv()
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
// read done.
|
||||
logger.Infof("Recv EOF from webserver")
|
||||
return nil
|
||||
} else {
|
||||
logger.Errorf("Handle failed: %v", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
logger.Debugf("Got message Type %s, Msg: %s", event.GetType(), event.GetMsg())
|
||||
if event.Type == Ping {
|
||||
if err = stream.Send(&pong); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if event.Type == EventTypeWebsite {
|
||||
logger.Infof("Update website with config: %s", event.GetMsg())
|
||||
var website model.WebsiteConfig
|
||||
if err := json.Unmarshal(event.GetMsg(), &website); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = generateConfigAndReload(&website); err != nil {
|
||||
logger.Error(err)
|
||||
if err := sendResponse(stream, EventTypeDeleteWebsite, []byte(err.Error())); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err = sendResponse(stream, EventTypeDeleteWebsite, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else if event.Type == EventTypeFullWebsite {
|
||||
if err = generateFullConfigAndReload(event.Msg); err != nil {
|
||||
logger.Error(err)
|
||||
sendErr := sendResponse(stream, EventTypeFullWebsite, []byte(err.Error()))
|
||||
if sendErr != nil {
|
||||
return sendErr
|
||||
}
|
||||
} else {
|
||||
if err = sendResponse(stream, EventTypeFullWebsite, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else if event.Type == EventTypeDeleteWebsite {
|
||||
if err = deleteConfigAndReload(event.Msg); err != nil {
|
||||
logger.Error(err)
|
||||
sendErr := sendResponse(stream, EventTypeDeleteWebsite, []byte(err.Error()))
|
||||
if sendErr != nil {
|
||||
return sendErr
|
||||
}
|
||||
} else {
|
||||
if err = sendResponse(stream, EventTypeDeleteWebsite, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
module chaitin.cn/patronus/safeline-2/management/tcontrollerd
|
||||
|
||||
go 1.21
|
||||
|
||||
toolchain go1.21.3
|
||||
|
||||
require (
|
||||
chaitin.cn/dev/go/errors v0.0.0-20210324055134-dc5247602af6
|
||||
chaitin.cn/dev/go/log v0.0.0-20221220104336-05125760b10c
|
||||
chaitin.cn/dev/go/settings v0.0.0-20221220104336-05125760b10c
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
github.com/sirupsen/logrus v1.9.3
|
||||
google.golang.org/grpc v1.65.0
|
||||
)
|
||||
|
||||
require (
|
||||
golang.org/x/net v0.25.0 // indirect
|
||||
golang.org/x/sys v0.20.0 // indirect
|
||||
golang.org/x/text v0.15.0 // indirect
|
||||
)
|
|
@ -1,127 +0,0 @@
|
|||
chaitin.cn/dev/go/errors v0.0.0-20200717101723-df6132d53dc8/go.mod h1:u+ZD0shdyUt0UG9XfCgD1R5mSqXpTVoO5rwQXQeo3Eo=
|
||||
chaitin.cn/dev/go/errors v0.0.0-20210324055134-dc5247602af6 h1:1Qa9ABk907/9ZrOLbbRcS8Fqq9VhjAF/mLjbSP1qAJY=
|
||||
chaitin.cn/dev/go/errors v0.0.0-20210324055134-dc5247602af6/go.mod h1:u+ZD0shdyUt0UG9XfCgD1R5mSqXpTVoO5rwQXQeo3Eo=
|
||||
chaitin.cn/dev/go/log v0.0.0-20221220104336-05125760b10c h1:Xn9IYkxmnpDcEpV+7JIR5ufEIexd1dhqKwpOLG1mYOE=
|
||||
chaitin.cn/dev/go/log v0.0.0-20221220104336-05125760b10c/go.mod h1:xJIYwUoA2TX5mNg/RBrEPyE251BPwj+70/mM7UIhoxg=
|
||||
chaitin.cn/dev/go/settings v0.0.0-20221220104336-05125760b10c h1:tXsraF7o9iUsQY6IwpDJusc6OFhB7iv/bBTfgR3MPUU=
|
||||
chaitin.cn/dev/go/settings v0.0.0-20221220104336-05125760b10c/go.mod h1:fUvtmpG8Z8Zf5aciadL9a/vn5SB3knG7pdNJixDplPg=
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
|
||||
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
|
||||
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.39.0-dev h1:K4VkkiYp4LCvQiW6OiGglzm5nO4Zyryf7pHhzP15cmI=
|
||||
google.golang.org/grpc v1.39.0-dev/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
|
||||
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
|
||||
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
|
||||
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
|
@ -1,107 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/tcontrollerd/controller"
|
||||
"chaitin.cn/patronus/safeline-2/management/tcontrollerd/pkg/cron"
|
||||
"chaitin.cn/patronus/safeline-2/management/tcontrollerd/pkg/ngcmd"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/tcontrollerd/pkg/config"
|
||||
"chaitin.cn/patronus/safeline-2/management/tcontrollerd/pkg/constants"
|
||||
"chaitin.cn/patronus/safeline-2/management/tcontrollerd/pkg/log"
|
||||
)
|
||||
|
||||
var (
|
||||
logger = log.GetLogger("main")
|
||||
|
||||
version = "undefined"
|
||||
githash = "undefined"
|
||||
buildstamp = "undefined"
|
||||
goVersion = "undefined"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// do something that do not raise error
|
||||
}
|
||||
|
||||
func handleLoop(ctx context.Context) {
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
os.Exit(0)
|
||||
default:
|
||||
if err := controller.Handle(); err != nil {
|
||||
logger.Error("Error occurred when handling controller: ", err)
|
||||
}
|
||||
time.Sleep(time.Second * 5)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.SetLogFormatter()
|
||||
|
||||
fs := flag.NewFlagSet("tcontrollerd", flag.ExitOnError)
|
||||
showVersion := fs.Bool("v", false, "show version")
|
||||
nginxTest := fs.Bool("t", false, "nginx -t")
|
||||
nginxReload := fs.Bool("r", false, "nginx -s reload")
|
||||
cfgFile := fs.String("c", constants.ConfigFilePath, "config file path")
|
||||
if err := fs.Parse(os.Args[1:]); err != nil {
|
||||
logger.Fatalln("Failed to parse args: ", err)
|
||||
}
|
||||
|
||||
if *showVersion {
|
||||
i, _ := strconv.Atoi(buildstamp)
|
||||
t := time.Unix(int64(i), 0).Format("2006-01-02 15:04:05")
|
||||
fmt.Println("Version: ", version)
|
||||
fmt.Println("Githash: ", githash)
|
||||
fmt.Println("Build: ", t)
|
||||
fmt.Println("Go version: ", goVersion)
|
||||
return
|
||||
}
|
||||
|
||||
// init configs
|
||||
if err := config.InitConfigs(*cfgFile); err != nil {
|
||||
logger.Fatalln("Failed to init configs: ", err)
|
||||
}
|
||||
|
||||
if err := log.InitLogger(); err != nil {
|
||||
logger.Fatalln("Failed to init db: ", err)
|
||||
}
|
||||
|
||||
if *nginxTest {
|
||||
if err := ngcmd.NginxConfTest(); err != nil {
|
||||
logger.Fatalln("Failed to test nginx conf: ", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if *nginxReload {
|
||||
if err := ngcmd.NginxConfReload(); err != nil {
|
||||
logger.Fatalln("Failed to reload nginx conf: ", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if err := cron.StartCron(); err != nil {
|
||||
logger.Fatalln("Failed to start cron: ", err)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
sig := make(chan os.Signal, 1)
|
||||
signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-sig
|
||||
cancel()
|
||||
}()
|
||||
|
||||
handleLoop(ctx)
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package model
|
||||
|
||||
// WebsiteConfig is supposed to be same with webserver/model/website.go
|
||||
type WebsiteConfig struct {
|
||||
Id int `json:"id"`
|
||||
ServerNames []string `json:"server_names"`
|
||||
Ports []string `json:"ports"`
|
||||
Upstreams []string `json:"upstreams"`
|
||||
CertFilename string `json:"cert_filename"`
|
||||
KeyFilename string `json:"key_filename"`
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"chaitin.cn/dev/go/settings"
|
||||
)
|
||||
|
||||
var (
|
||||
GlobalConfig = DefaultGlobalConfig()
|
||||
)
|
||||
|
||||
func InitConfigs(configFilePath string) error {
|
||||
s, err := settings.New(configFilePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = GlobalConfig.Log.Load(s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := s.Unmarshal("mgt_addr", &GlobalConfig.MgtWebserver); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if v, ok := os.LookupEnv("MGT_ADDR"); ok {
|
||||
GlobalConfig.MgtWebserver = v
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package config
|
||||
|
||||
type Config struct {
|
||||
Log LogConfig
|
||||
MgtWebserver string
|
||||
}
|
||||
|
||||
func DefaultGlobalConfig() Config {
|
||||
return Config{
|
||||
Log: DefaultLogConfig(),
|
||||
MgtWebserver: "169.254.0.4:9002",
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"chaitin.cn/dev/go/settings"
|
||||
)
|
||||
|
||||
type LogConfig struct {
|
||||
Output string `yaml:"output"`
|
||||
Level string `yaml:"level"`
|
||||
}
|
||||
|
||||
func DefaultLogConfig() LogConfig {
|
||||
return LogConfig{
|
||||
Output: "stdout",
|
||||
Level: "info",
|
||||
}
|
||||
}
|
||||
|
||||
func (lc *LogConfig) Load(setting *settings.Setting) error {
|
||||
if err := setting.Unmarshal("log", lc); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
package constants
|
||||
|
||||
const (
|
||||
ConfigFilePath = "config.yml"
|
||||
)
|
|
@ -1,6 +0,0 @@
|
|||
package constants
|
||||
|
||||
const (
|
||||
DefaultForbiddenPageMd5 = "d9921f84f36a6cc92a6fc13946a18e98"
|
||||
DefaultForbiddenPage = ``
|
||||
)
|
|
@ -1,27 +0,0 @@
|
|||
package cron
|
||||
|
||||
import (
|
||||
"github.com/robfig/cron/v3"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/tcontrollerd/pkg/log"
|
||||
)
|
||||
|
||||
var logger = log.GetLogger("cron")
|
||||
|
||||
func newCronWithSeconds() *cron.Cron {
|
||||
secondParser := cron.NewParser(cron.Second | cron.Minute | cron.Hour |
|
||||
cron.Dom | cron.Month | cron.DowOptional | cron.Descriptor)
|
||||
return cron.New(cron.WithParser(secondParser), cron.WithChain())
|
||||
}
|
||||
|
||||
func StartCron() error {
|
||||
cronInstance := newCronWithSeconds()
|
||||
|
||||
_, err := cronInstance.AddFunc(specCheckForbiddenPage, checkAndUpdateForbiddenPage)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cronInstance.Start()
|
||||
return nil
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
package cron
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"io/ioutil"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/tcontrollerd/pkg/constants"
|
||||
"chaitin.cn/patronus/safeline-2/management/tcontrollerd/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
// SpecUpdatePolicy http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/tutorial-lesson-06.html
|
||||
// Seconds Minutes Hours Day-of-Month Month Day-of-Week Year (optional field)
|
||||
// every 30 second (starting from 0s)
|
||||
specCheckForbiddenPage = "0/30 * * * * ?"
|
||||
|
||||
forbiddenPagePath = "/etc/nginx/forbidden_pages/default_forbidden_page.html"
|
||||
)
|
||||
|
||||
func checkAndUpdateForbiddenPage() {
|
||||
existed, err := utils.FileExist(forbiddenPagePath)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
return
|
||||
}
|
||||
if !existed {
|
||||
err = utils.EnsureWriteFile(forbiddenPagePath, []byte(constants.DefaultForbiddenPage), 0644)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
content, err := ioutil.ReadFile(forbiddenPagePath)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
hash := md5.New()
|
||||
hash.Write([]byte(content))
|
||||
forbiddenMd5 := hex.EncodeToString(hash.Sum(nil))
|
||||
if forbiddenMd5 == constants.DefaultForbiddenPageMd5 {
|
||||
return
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(forbiddenPagePath, []byte(constants.DefaultForbiddenPage), 0644)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
return
|
||||
}
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
package log
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"chaitin.cn/dev/go/log"
|
||||
"chaitin.cn/patronus/safeline-2/management/tcontrollerd/pkg/config"
|
||||
"chaitin.cn/patronus/safeline-2/management/tcontrollerd/utils"
|
||||
)
|
||||
|
||||
func GetLogger(name string) *log.Logger {
|
||||
return log.GetLogger(name)
|
||||
}
|
||||
|
||||
func LoadLogLevel() {
|
||||
lv, _ := log.ParseLevel(config.GlobalConfig.Log.Level)
|
||||
log.SetLevel(log.AllLoggers, lv)
|
||||
}
|
||||
|
||||
func SetLogFormatter() {
|
||||
// format
|
||||
formatter := new(log.TextFormatter)
|
||||
formatter.FullTimestamp = true
|
||||
formatter.TimestampFormat = "2006/01/02 15:04:05"
|
||||
log.SetFormatter(log.AllLoggers, formatter)
|
||||
}
|
||||
|
||||
func InitLogger() error {
|
||||
// output
|
||||
switch config.GlobalConfig.Log.Output {
|
||||
case "stdout":
|
||||
log.SetOutput(log.AllLoggers, os.Stdout)
|
||||
case "stderr":
|
||||
log.SetOutput(log.AllLoggers, os.Stderr)
|
||||
default:
|
||||
exist, err := utils.FileExist(config.GlobalConfig.Log.Output)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fileFlag := os.O_WRONLY | os.O_APPEND | os.O_SYNC
|
||||
if !exist {
|
||||
if err := utils.EnsureFileDir(config.GlobalConfig.Log.Output); err != nil {
|
||||
return err
|
||||
}
|
||||
fileFlag = fileFlag | os.O_CREATE
|
||||
}
|
||||
|
||||
if fp, err := os.OpenFile(config.GlobalConfig.Log.Output, fileFlag, os.ModePerm); err != nil {
|
||||
return fmt.Errorf("failed to open log file: %s", err.Error())
|
||||
} else {
|
||||
log.SetOutput(log.AllLoggers, log.NewLockOutput(fp))
|
||||
}
|
||||
}
|
||||
|
||||
// hook
|
||||
log.AddHook(log.AllLoggers, NewRuntimeHook())
|
||||
log.AddHook(log.AllLoggers, log.NewErrorStackHook(true))
|
||||
// level
|
||||
LoadLogLevel()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type RuntimeHook struct{}
|
||||
|
||||
func (h *RuntimeHook) Levels() []logrus.Level {
|
||||
return logrus.AllLevels
|
||||
}
|
||||
|
||||
func (h *RuntimeHook) Fire(entry *logrus.Entry) error {
|
||||
file := "???"
|
||||
funcName := "???"
|
||||
line := 0
|
||||
|
||||
pc := make([]uintptr, 64)
|
||||
// Skip runtime.Callers, self, and another call from logrus
|
||||
n := runtime.Callers(3, pc)
|
||||
if n != 0 {
|
||||
pc = pc[:n] // pass only valid pcs to runtime.CallersFrames
|
||||
frames := runtime.CallersFrames(pc)
|
||||
|
||||
// Loop to get frames.
|
||||
// A fixed number of pcs can expand to an indefinite number of Frames.
|
||||
for {
|
||||
frame, more := frames.Next()
|
||||
if !strings.Contains(frame.File, "github.com/sirupsen/logrus") && !strings.Contains(frame.Function, "chaitin.cn/dev/go") {
|
||||
file = frame.File
|
||||
funcName = frame.Function
|
||||
line = frame.Line
|
||||
break
|
||||
}
|
||||
if !more {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
slices := strings.Split(file, "/")
|
||||
file = slices[len(slices)-1]
|
||||
|
||||
funcName = strings.ReplaceAll(funcName, "chaitin.cn", "")
|
||||
|
||||
entry.Data["file"] = file
|
||||
entry.Data["func"] = funcName
|
||||
entry.Data["line"] = line
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewRuntimeHook() *RuntimeHook {
|
||||
return &RuntimeHook{}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package ngcmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"chaitin.cn/dev/go/errors"
|
||||
"chaitin.cn/patronus/safeline-2/management/tcontrollerd/pkg/log"
|
||||
)
|
||||
|
||||
var logger = log.GetLogger("ngcmd")
|
||||
|
||||
// NginxConfTest exec nginx -t and return stderr
|
||||
func NginxConfTest() error {
|
||||
out, err := exec.Command("nginx", "-t").CombinedOutput()
|
||||
logger.Debugf("nginx -t output: %v", string(out))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, string(out))
|
||||
}
|
||||
|
||||
//logger.Debugf("nginx -t output: %v", out)
|
||||
if strings.Contains(string(out), "syntax is ok") && strings.Contains(string(out), "test is successful") {
|
||||
return nil
|
||||
} else {
|
||||
return errors.New(fmt.Sprintf("nginx conf test error: %s", string(out)))
|
||||
}
|
||||
}
|
||||
|
||||
// NginxConfReload exec nginx -t and return stderr
|
||||
func NginxConfReload() error {
|
||||
out, err := exec.Command("nginx", "-s", "reload").CombinedOutput()
|
||||
logger.Debugf("nginx -s reload output: %v", string(out))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, string(out))
|
||||
}
|
||||
|
||||
if len(out) == 0 {
|
||||
return nil
|
||||
} else {
|
||||
return errors.New(fmt.Sprintf("nginx conf reload error: %s", string(out)))
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
syntax = "proto3";
|
||||
package website;
|
||||
option go_package = "proto/website";
|
||||
|
||||
service Website {
|
||||
rpc Subscribe(stream Response) returns (stream Event) {}
|
||||
}
|
||||
|
||||
// From client-side, may be "pong"
|
||||
message Response {
|
||||
string type = 1;
|
||||
bytes msg = 2;
|
||||
bool err = 3;
|
||||
}
|
||||
|
||||
// From server-side, may be "ping"
|
||||
message Event {
|
||||
string type = 1; // ping/website
|
||||
bytes msg = 2;
|
||||
}
|
|
@ -1,126 +0,0 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func EnsureDir(dir string) error {
|
||||
if _, err := os.Stat(dir); os.IsNotExist(err) {
|
||||
return os.MkdirAll(dir, os.FileMode(0755))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func EnsureFileDir(path string) error {
|
||||
return EnsureDir(filepath.Dir(path))
|
||||
}
|
||||
|
||||
func FileExist(path string) (bool, error) {
|
||||
stat, err := os.Stat(path)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return false, nil
|
||||
} else {
|
||||
return false, err
|
||||
}
|
||||
} else {
|
||||
if stat.IsDir() {
|
||||
return false, fmt.Errorf("%s is dir", path)
|
||||
} else {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func FilesExist(paths ...string) (bool, error) {
|
||||
for _, path := range paths {
|
||||
exist, err := FileExist(path)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if !exist {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func RenameWriteFile(filename string, data []byte, perm os.FileMode) error {
|
||||
randFileName := filename + ".tmp." + RandStr(8)
|
||||
if err := ioutil.WriteFile(randFileName, data, perm); err != nil {
|
||||
return err
|
||||
}
|
||||
return os.Rename(randFileName, filename)
|
||||
}
|
||||
|
||||
func EnsureRenameWriteFile(path string, data []byte, mode os.FileMode) error {
|
||||
err := EnsureFileDir(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return RenameWriteFile(path, data, mode)
|
||||
}
|
||||
|
||||
func EnsureWriteFile(path string, data []byte, mode os.FileMode) error {
|
||||
err := EnsureFileDir(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return ioutil.WriteFile(path, data, mode)
|
||||
}
|
||||
|
||||
func CopyFile(srcPath, dstPath string) error {
|
||||
srcFile, err := os.Open(srcPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func(srcFile *os.File) {
|
||||
err := srcFile.Close()
|
||||
if err != nil {
|
||||
|
||||
}
|
||||
}(srcFile)
|
||||
|
||||
fileInfo, err := srcFile.Stat()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return CopyFileFromIO(srcFile, dstPath, fileInfo.Mode())
|
||||
}
|
||||
|
||||
func CopyFileFromIO(src io.Reader, dstPath string, perm os.FileMode) error {
|
||||
if err := EnsureFileDir(dstPath); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dstFile, err := os.OpenFile(dstPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, perm)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func(dstFile *os.File) {
|
||||
err := dstFile.Close()
|
||||
if err != nil {
|
||||
|
||||
}
|
||||
}(dstFile)
|
||||
|
||||
_, err = io.Copy(dstFile, src)
|
||||
return err
|
||||
}
|
||||
|
||||
func CopyFileIfNotExist(srcPath, dstPath string) error {
|
||||
if exist, err := FileExist(dstPath); err != nil {
|
||||
return err
|
||||
} else if !exist {
|
||||
return CopyFile(srcPath, dstPath)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||
|
||||
func RandStr(n int) string {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
b := make([]rune, n)
|
||||
for i := range b {
|
||||
b[i] = letters[rand.Intn(len(letters))]
|
||||
}
|
||||
return string(b)
|
||||
}
|
3
management/webserver/.gitignore
vendored
|
@ -1,3 +0,0 @@
|
|||
tmp
|
||||
Taskfile.yml
|
||||
.air.toml
|
|
@ -1,63 +0,0 @@
|
|||
# Web Server
|
||||
|
||||
web server for mgt-api
|
||||
|
||||
## Requirements
|
||||
|
||||
Go 1.18+
|
||||
|
||||
## Development
|
||||
|
||||
### Init protobuf
|
||||
|
||||
```shell
|
||||
# Refer: https://grpc.io/docs/languages/go/quickstart/
|
||||
# 1. Install protoc
|
||||
# https://grpc.io/docs/protoc-installation/
|
||||
|
||||
# 2. Install Go plugins
|
||||
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30.0
|
||||
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0
|
||||
|
||||
# 3. Update your PATH so that the protoc compiler can find the plugins
|
||||
# export PATH="$PATH:$(go env GOPATH)/bin"
|
||||
|
||||
# 4. Generate proto go code
|
||||
# cd /path/to/management
|
||||
./scripts/genproto.sh
|
||||
```
|
||||
|
||||
### Init fvm libs
|
||||
|
||||
```shell
|
||||
# Due to the fvm c header files
|
||||
mkdir -p management/webserver/submodule/fvm/
|
||||
mkdir -p management/webserver/submodule/libct/
|
||||
|
||||
cd management/webserver/submodule/fvm/
|
||||
# Download https://chaitin.cn/patronus/fvm/-/tags 1.8.21 release:release, https://chaitin.cn/patronus/fvm/-/jobs/6716645
|
||||
unzip artifacts.zip
|
||||
rm artifacts.zip
|
||||
|
||||
cd management/webserver/submodule/libct/
|
||||
# Download https://chaitin.cn/patronus/libct/-/tags 1.1.1.0 release, https://chaitin.cn/patronus/libct/-/jobs/7229201
|
||||
# rename
|
||||
rm artifacts.zip
|
||||
|
||||
cd management/webserver/submodule/
|
||||
# Download https://chaitin.cn/patronus/fusion-2/-/tags 5.3.9-r1 build:release, https://chaitin.cn/patronus/fusion-2/-/jobs/7326007
|
||||
# rename
|
||||
unzip artifacts.zip
|
||||
mv artifacts/lib/libfusion.so libfvm.so
|
||||
rm artifacts.zip
|
||||
rm -r artifacts/
|
||||
```
|
||||
|
||||
### Build
|
||||
|
||||
```shell
|
||||
cd management/
|
||||
docker run -it --rm -w="/mnt" --mount type=bind,source="$(pwd)",target=/mnt chaitin.cn/ci/golang:1.18 bash
|
||||
cp webserver/submodule/libfvm.so /usr/lib/
|
||||
make build-webserver
|
||||
```
|
|
@ -1,131 +0,0 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"math"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/pquerna/otp"
|
||||
"github.com/pquerna/otp/totp"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/api/response"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/model"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/constants"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/database"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/log"
|
||||
)
|
||||
|
||||
var logger = log.GetLogger("api")
|
||||
|
||||
var OtpOpts = totp.GenerateOpts{
|
||||
Issuer: constants.ProductName,
|
||||
AccountName: constants.SuperUser,
|
||||
Period: 30, // seconds
|
||||
Digits: otp.DigitsSix,
|
||||
Algorithm: otp.AlgorithmSHA1,
|
||||
}
|
||||
|
||||
type PostLoginRequest struct {
|
||||
Passcode string `json:"passcode"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
}
|
||||
|
||||
func PostLogin(c *gin.Context) {
|
||||
var params PostLoginRequest
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(c, response.ErrorParamNotOK, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
db := database.GetDB()
|
||||
|
||||
// only SuperUser in v0.9
|
||||
var user model.User
|
||||
db.Where(&model.User{Username: constants.SuperUser}).First(&user)
|
||||
|
||||
valid := totp.Validate(params.Passcode, user.TFASecret)
|
||||
if !valid {
|
||||
millisecondTimestamp := params.Timestamp
|
||||
localTimeStamp := time.Now()
|
||||
if millisecondTimestamp > 0 {
|
||||
logger.Debugf("will valid otp frontend timestamp:%v, local timestamp:%v", millisecondTimestamp, localTimeStamp)
|
||||
otpTime := time.Unix(millisecondTimestamp/1000, (millisecondTimestamp%1000)*int64(time.Millisecond))
|
||||
timeSub := localTimeStamp.Sub(otpTime)
|
||||
seconds := math.Abs(timeSub.Seconds())
|
||||
if seconds >= 60 {
|
||||
logger.Errorf("otp timestamp gap is more than a minute")
|
||||
response.Error(c, response.JSONBody{Err: response.ErrWrongTimeGap, Msg: "otp timestamp gap is more than a minute"}, http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
}
|
||||
response.Error(c, response.JSONBody{Err: response.ErrWrongPasscode, Msg: "Failed to verify your passcode"}, http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
user.LastLoginTime = time.Now().Unix()
|
||||
user.IsEnabled = true
|
||||
db.Save(&user)
|
||||
|
||||
session := sessions.Default(c)
|
||||
session.Options(sessions.Options{
|
||||
Path: "/",
|
||||
MaxAge: 3600 * 24 * 7,
|
||||
//Domain: options.Domain,
|
||||
//HttpOnly: true,
|
||||
//SameSite: http.SameSiteLaxMode,
|
||||
//Secure: false,
|
||||
})
|
||||
session.Set(constants.DefaultSessionUserKey, user.ID)
|
||||
if err := session.Save(); err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(c, response.JSONBody{Err: response.ErrInternalError, Msg: "Error occurred when creating sessions"}, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
response.Success(c, nil)
|
||||
}
|
||||
|
||||
func PostLogout(c *gin.Context) {
|
||||
session := sessions.Default(c)
|
||||
session.Clear()
|
||||
|
||||
if err := session.Save(); err != nil {
|
||||
response.Error(c, response.JSONBody{Err: response.ErrInternalError, Msg: "Error occurred when creating sessions"}, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
response.Success(c, nil)
|
||||
}
|
||||
|
||||
func GetOTPUrl(c *gin.Context) {
|
||||
otpKey, err := totp.Generate(OtpOpts)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(c, response.JSONBody{Err: response.ErrInternalError, Msg: "Error occurred when generating otp qrcode"}, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
db := database.GetDB()
|
||||
|
||||
// only SuperUser in v0.9
|
||||
user := model.User{Username: constants.SuperUser}
|
||||
db.First(&user)
|
||||
if user.LastLoginTime > 0 {
|
||||
// already bind tfa, because tfa binding is mandatory when login.
|
||||
response.Success(c, gin.H{"url": ""})
|
||||
return
|
||||
}
|
||||
|
||||
user.TFASecret = otpKey.Secret()
|
||||
db.Save(&user)
|
||||
response.Success(c, gin.H{"url": otpKey.URL()})
|
||||
}
|
||||
|
||||
func GetUser(c *gin.Context) {
|
||||
db := database.GetDB()
|
||||
user := model.User{Username: constants.SuperUser}
|
||||
db.First(&user)
|
||||
response.Success(c, gin.H{"id": user.ID, "username": user.Username})
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/api/response"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/model"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/database"
|
||||
)
|
||||
|
||||
type PostBehaviourRequest struct {
|
||||
model.Behaviour
|
||||
}
|
||||
|
||||
func PostBehaviour(c *gin.Context) {
|
||||
var params PostBehaviourRequest
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(c, response.ErrorParamNotOK, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
db := database.GetDB()
|
||||
db.Create(&model.Behaviour{SrcRouter: params.SrcRouter, DstRouter: params.DstRouter})
|
||||
response.Success(c, nil)
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"crypto/x509/pkix"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/api/response"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/config"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/utils"
|
||||
)
|
||||
|
||||
type postSSLCertRequest struct {
|
||||
Hostname string `json:"hostname"`
|
||||
}
|
||||
|
||||
// SSLCertDir is the dir of tengine conf, not mgt-api nginx certs dir defined by constants.CertsPath
|
||||
const (
|
||||
CRT = ".crt"
|
||||
PEM = ".pem"
|
||||
KEY = ".key"
|
||||
|
||||
SSLCertDir = "certs"
|
||||
)
|
||||
|
||||
func PostUploadSSLCert(c *gin.Context) {
|
||||
file, err := c.FormFile("file")
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(c, response.ErrorParamNotOK, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
switch filepath.Ext(file.Filename) {
|
||||
case CRT, PEM, KEY:
|
||||
logger.Debugf("File: %v is valid", file.Filename)
|
||||
default:
|
||||
logger.Errorf("Filename: %s, ext: %s", file.Filename, filepath.Ext(file.Filename))
|
||||
response.Error(c, response.JSONBody{Err: response.ErrWrongFileType, Msg: "Wrong file type, please upload a file of .crt or .key"}, http.StatusUnsupportedMediaType)
|
||||
return
|
||||
}
|
||||
|
||||
var dstPath string
|
||||
filename := fmt.Sprintf("%s_%s", utils.RandStr(16), file.Filename)
|
||||
if config.GlobalConfig.Server.DevMode {
|
||||
dstPath = filepath.Join("./nginx", SSLCertDir, filename)
|
||||
} else {
|
||||
dstPath = filepath.Join(config.GlobalConfig.NgxResDir, SSLCertDir, filename)
|
||||
}
|
||||
if err = c.SaveUploadedFile(file, dstPath); err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(c, response.JSONBody{Err: response.ErrInternalError, Msg: "Error occurred when saving file"}, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
response.Success(c, gin.H{"filename": filename})
|
||||
}
|
||||
|
||||
func PostSSLCert(c *gin.Context) {
|
||||
var params postSSLCertRequest
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(c, response.ErrorParamNotOK, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
filePrefix := utils.RandStr(16)
|
||||
certFilename := fmt.Sprintf("%s_backend.crt", filePrefix)
|
||||
keyFilename := fmt.Sprintf("%s_backend.key", filePrefix)
|
||||
|
||||
var certPath, keyPath string
|
||||
if config.GlobalConfig.Server.DevMode {
|
||||
certPath = filepath.Join("./management", SSLCertDir, certFilename)
|
||||
keyPath = filepath.Join("./management", SSLCertDir, keyFilename)
|
||||
} else {
|
||||
certPath = filepath.Join(config.GlobalConfig.NgxResDir, SSLCertDir, certFilename)
|
||||
keyPath = filepath.Join(config.GlobalConfig.NgxResDir, SSLCertDir, keyFilename)
|
||||
}
|
||||
if err := utils.WriteCertIfNotExist(
|
||||
certPath,
|
||||
keyPath,
|
||||
func() ([]byte, []byte, error) {
|
||||
return utils.GenerateCert(
|
||||
[]string{params.Hostname},
|
||||
3650,
|
||||
4096,
|
||||
&pkix.Name{
|
||||
Country: []string{},
|
||||
Province: []string{},
|
||||
Locality: []string{},
|
||||
Organization: []string{},
|
||||
OrganizationalUnit: []string{},
|
||||
CommonName: "",
|
||||
},
|
||||
false,
|
||||
)
|
||||
}); err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(c, response.JSONBody{Err: response.ErrInternalError, Msg: "Error occurred when generating certs"}, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
response.Success(c, gin.H{"crt": certFilename, "key": keyFilename})
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/rogpeppe/go-internal/semver"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/api/response"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/config"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/constants"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/utils"
|
||||
)
|
||||
|
||||
const VersionInfoEntrypoint = "/release/latest/version.json"
|
||||
|
||||
type idsRequest struct {
|
||||
IDs []uint `json:"ids" form:"ids"`
|
||||
}
|
||||
|
||||
type pageRequest struct {
|
||||
Page int `json:"page" form:"page,default=1" binding:"min=1"`
|
||||
PageSize int `json:"page_size" form:"page_size,default=10" binding:"min=1"`
|
||||
}
|
||||
|
||||
type versionInfoResponse struct {
|
||||
LatestVersion string `json:"latest_version"`
|
||||
RecVersion string `json:"rec_version"`
|
||||
}
|
||||
|
||||
func GetVersion(c *gin.Context) {
|
||||
response.Success(c, gin.H{"version": strings.TrimPrefix(constants.Version, "ce-")})
|
||||
}
|
||||
|
||||
func GetUpgradeTips(ctx *gin.Context) {
|
||||
client := utils.GetHTTPClient()
|
||||
logger.Debugf("GetUpgradeTips: %s", config.GlobalConfig.PlatformAddr+VersionInfoEntrypoint)
|
||||
versionInfoReq, err := http.NewRequest(http.MethodGet, config.GlobalConfig.PlatformAddr+VersionInfoEntrypoint, nil)
|
||||
if err != nil {
|
||||
logger.Warn(err)
|
||||
response.Success(ctx, gin.H{"upgrade_tips": constants.NotUpgrade})
|
||||
return
|
||||
}
|
||||
|
||||
versionInfoRsp, err := client.Do(versionInfoReq)
|
||||
if err != nil {
|
||||
logger.Warn(err)
|
||||
response.Success(ctx, gin.H{"upgrade_tips": constants.NotUpgrade})
|
||||
return
|
||||
}
|
||||
body, err := ioutil.ReadAll(versionInfoRsp.Body)
|
||||
if err != nil {
|
||||
logger.Warn(err)
|
||||
response.Success(ctx, gin.H{"upgrade_tips": constants.NotUpgrade})
|
||||
return
|
||||
}
|
||||
|
||||
versionInfo := &versionInfoResponse{}
|
||||
err = json.Unmarshal(body, versionInfo)
|
||||
if err != nil {
|
||||
logger.Warnf("err: %v, body: %s", err, body)
|
||||
response.Success(ctx, gin.H{"upgrade_tips": constants.NotUpgrade})
|
||||
return
|
||||
}
|
||||
|
||||
currentVersion := fmt.Sprintf("v%s", constants.Version)
|
||||
latestVersionCmp := semver.Compare(currentVersion, versionInfo.LatestVersion)
|
||||
recVersionCmp := semver.Compare(currentVersion, versionInfo.RecVersion)
|
||||
if semver.Compare(versionInfo.LatestVersion, versionInfo.RecVersion) == -1 || latestVersionCmp == 1 {
|
||||
logger.Warnf("The version number is invalid, current version: %s, latest version: %s, rec version: %s",
|
||||
currentVersion, versionInfo.LatestVersion, versionInfo.RecVersion)
|
||||
response.Success(ctx, gin.H{"upgrade_tips": constants.NotUpgrade})
|
||||
return
|
||||
}
|
||||
|
||||
var upgradeTips int
|
||||
if recVersionCmp == -1 {
|
||||
upgradeTips = constants.MustUpgrade
|
||||
} else if recVersionCmp == 0 {
|
||||
if latestVersionCmp == 0 {
|
||||
upgradeTips = constants.NotUpgrade
|
||||
} else {
|
||||
upgradeTips = constants.RecommendedUpgrade
|
||||
}
|
||||
} else {
|
||||
if latestVersionCmp < 0 {
|
||||
upgradeTips = constants.RecommendedUpgrade
|
||||
} else {
|
||||
upgradeTips = constants.NotUpgrade
|
||||
}
|
||||
}
|
||||
|
||||
response.Success(ctx, gin.H{"upgrade_tips": upgradeTips})
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/api/response"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/model"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/database"
|
||||
)
|
||||
|
||||
func GetDashboardCounts(c *gin.Context) {
|
||||
var requested int64 = 0
|
||||
var intercepted int64 = 0
|
||||
db := database.GetDB()
|
||||
|
||||
var statisticTotalReq model.SystemStatistics
|
||||
r := db.Where("type = 'total-req'").Where("created_at >= date_trunc('day',now())").First(&statisticTotalReq)
|
||||
if r.RowsAffected > 0 {
|
||||
requested = statisticTotalReq.Value
|
||||
}
|
||||
|
||||
var statisticTotalDenied model.SystemStatistics
|
||||
r = db.Where("type = 'total-denied'").Where("created_at >= date_trunc('day',now())").First(&statisticTotalDenied)
|
||||
if r.RowsAffected > 0 {
|
||||
intercepted = statisticTotalDenied.Value
|
||||
}
|
||||
response.Success(c, gin.H{"requested": requested, "intercepted": intercepted})
|
||||
}
|
||||
|
||||
func GetDashboardSites(c *gin.Context) {
|
||||
response.Success(c, gin.H{"normal": 0, "abnormal": 0})
|
||||
}
|
||||
|
||||
func GetDashboardQps(c *gin.Context) {
|
||||
|
||||
var statistics []model.SystemStatistics
|
||||
|
||||
db := database.GetDB()
|
||||
db.Where("type = 'req'").Order("created_at desc").Limit(75).Find(&statistics)
|
||||
|
||||
type Node struct {
|
||||
Label string `json:"label"`
|
||||
Value int64 `json:"value"`
|
||||
}
|
||||
var nodes = make([]Node, 0)
|
||||
|
||||
for i := len(statistics) - 1; i >= 0; i-- {
|
||||
nodes = append(nodes, Node{
|
||||
Label: statistics[i].CreatedAt.Format("2006-01-02 15:04:05"),
|
||||
Value: int64(math.Ceil(float64(statistics[i].Value) / 5)),
|
||||
})
|
||||
}
|
||||
|
||||
response.Success(c, gin.H{"nodes": nodes, "total": len(nodes)})
|
||||
}
|
||||
|
||||
func GetDashboardRequests(c *gin.Context) {
|
||||
|
||||
var statistics []model.SystemStatistics
|
||||
|
||||
db := database.GetDB()
|
||||
db.Where("type = 'total-req'").Order("created_at desc").Limit(30).Find(&statistics)
|
||||
|
||||
type Node struct {
|
||||
Label string `json:"label"`
|
||||
Value int64 `json:"value"`
|
||||
}
|
||||
var nodes = make([]Node, 0)
|
||||
|
||||
for i := 30; i > len(statistics); i-- {
|
||||
nodes = append(nodes, Node{
|
||||
Label: time.Now().Add(-time.Duration(i-1) * time.Hour * 24).Format("2006-01-02"),
|
||||
Value: 0,
|
||||
})
|
||||
}
|
||||
|
||||
for i := len(statistics) - 1; i >= 0; i-- {
|
||||
nodes = append(nodes, Node{
|
||||
Label: statistics[i].CreatedAt.Format("2006-01-02"),
|
||||
Value: statistics[i].Value,
|
||||
})
|
||||
}
|
||||
|
||||
response.Success(c, gin.H{"nodes": nodes, "total": len(nodes)})
|
||||
}
|
||||
|
||||
func GetDashboardIntercepts(c *gin.Context) {
|
||||
var statistics []model.SystemStatistics
|
||||
|
||||
db := database.GetDB()
|
||||
db.Where("type = 'total-denied'").Order("created_at desc").Limit(30).Find(&statistics)
|
||||
|
||||
type Node struct {
|
||||
Label string `json:"label"`
|
||||
Value int64 `json:"value"`
|
||||
}
|
||||
var nodes = make([]Node, 0)
|
||||
|
||||
for i := 30; i > len(statistics); i-- {
|
||||
nodes = append(nodes, Node{
|
||||
Label: time.Now().Add(-time.Duration(i-1) * time.Hour * 24).Format("2006-01-02"),
|
||||
Value: 0,
|
||||
})
|
||||
}
|
||||
|
||||
for i := len(statistics) - 1; i >= 0; i-- {
|
||||
nodes = append(nodes, Node{
|
||||
Label: statistics[i].CreatedAt.Format("2006-01-02"),
|
||||
Value: statistics[i].Value,
|
||||
})
|
||||
}
|
||||
|
||||
response.Success(c, gin.H{"nodes": nodes, "total": len(nodes)})
|
||||
}
|
|
@ -1,183 +0,0 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"chaitin.cn/dev/go/errors"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"chaitin.cn/dev/go/log"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/api/response"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/model"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/config"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/constants"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/database"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/utils"
|
||||
)
|
||||
|
||||
type (
|
||||
GetDetectLogDetailRequest struct {
|
||||
EventId string `json:"event_id" form:"event_id"`
|
||||
}
|
||||
|
||||
PostFalsePositivesRequest struct {
|
||||
EventId string `json:"event_id"`
|
||||
}
|
||||
|
||||
telemetryFalsePositives struct {
|
||||
Telemetry struct {
|
||||
Id string `json:"id"`
|
||||
} `json:"telemetry"`
|
||||
|
||||
Safeline struct {
|
||||
Id string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
DetectLog model.DetectLog `json:"detect_log"`
|
||||
} `json:"safeline"`
|
||||
}
|
||||
)
|
||||
|
||||
func getDetectLog(eventId string) (*model.DetectLog, error) {
|
||||
db := database.GetDB()
|
||||
var detectLogBasic model.DetectLogBasic
|
||||
res := db.Where(&model.DetectLogBasic{EventId: eventId}).First(&detectLogBasic)
|
||||
if res.RowsAffected == 0 {
|
||||
return nil, errors.New("Data queried does not exist")
|
||||
}
|
||||
|
||||
var detectLogDetail model.DetectLogDetail
|
||||
db.Where(&model.DetectLogDetail{EventId: eventId}).First(&detectLogDetail)
|
||||
|
||||
detectLog, err := model.TransformDetectLog(&detectLogBasic, &detectLogDetail)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return detectLog, nil
|
||||
}
|
||||
|
||||
func GetDetectLogList(c *gin.Context) {
|
||||
var params pageRequest
|
||||
if err := c.BindQuery(¶ms); err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(c, response.ErrorParamNotOK, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
db := database.GetDB()
|
||||
|
||||
tx := db.Where("")
|
||||
// 按 ip 搜索条件
|
||||
if ip := c.Query("ip"); ip != "" {
|
||||
tx = tx.Where("src_ip = ?", ip)
|
||||
}
|
||||
// 按 url 搜索条件
|
||||
if url := c.Query("url"); url != "" {
|
||||
tx = tx.Where("url_path like ?", "%"+url+"%")
|
||||
}
|
||||
// 按 type 搜索条件
|
||||
if at := c.Query("attack_type"); at != "" {
|
||||
ns := make([]int, 0)
|
||||
for _, s := range strings.Split(at, ",") {
|
||||
n, err := strconv.Atoi(s)
|
||||
if err == nil {
|
||||
ns = append(ns, n)
|
||||
}
|
||||
}
|
||||
tx = tx.Where("attack_type in (?)", ns)
|
||||
}
|
||||
|
||||
var total int64
|
||||
tx.Model(&model.DetectLogBasic{}).Count(&total)
|
||||
|
||||
var basicList []model.DetectLogBasic
|
||||
tx.Limit(params.PageSize).Offset(params.PageSize * (params.Page - 1)).Order("id desc").Find(&basicList)
|
||||
var dLogList []*model.DetectLog
|
||||
for _, basic := range basicList {
|
||||
dLog, err := model.TransformDetectLog(&basic, nil)
|
||||
if err != nil {
|
||||
logger.Warn(err)
|
||||
continue
|
||||
}
|
||||
dLogList = append(dLogList, dLog)
|
||||
}
|
||||
response.Success(c, gin.H{"data": dLogList, "total": total})
|
||||
}
|
||||
|
||||
func GetDetectLogDetail(c *gin.Context) {
|
||||
var params GetDetectLogDetailRequest
|
||||
if err := c.BindQuery(¶ms); err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(c, response.ErrorParamNotOK, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
detectLog, err := getDetectLog(params.EventId)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(c, response.ErrorDataNotExist, http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
response.Success(c, detectLog)
|
||||
}
|
||||
|
||||
func PostFalsePositives(c *gin.Context) {
|
||||
var params PostFalsePositivesRequest
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(c, response.ErrorParamNotOK, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
detectLog, err := getDetectLog(params.EventId)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(c, response.ErrorDataNotExist, http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
db := database.GetDB()
|
||||
var option model.Options
|
||||
db.Where(&model.Options{Key: constants.MachineID}).First(&option)
|
||||
|
||||
var jsonData telemetryFalsePositives
|
||||
jsonData.Telemetry.Id = constants.TelemetryId
|
||||
jsonData.Safeline.Id = option.Value
|
||||
jsonData.Safeline.Type = constants.FalsePositives
|
||||
jsonData.Safeline.DetectLog = *detectLog
|
||||
|
||||
data, err := json.Marshal(jsonData)
|
||||
if err != nil {
|
||||
log.Warn(err)
|
||||
response.Success(c, nil)
|
||||
return
|
||||
}
|
||||
reader := bytes.NewReader(data)
|
||||
|
||||
client := utils.GetHTTPClient()
|
||||
addr := config.GlobalConfig.Telemetry.Addr
|
||||
|
||||
rsp, err := pkg.DoPostTelemetry(client, addr, reader)
|
||||
if err != nil {
|
||||
log.Warn(err)
|
||||
response.Success(c, nil)
|
||||
return
|
||||
}
|
||||
|
||||
if rsp.StatusCode != http.StatusOK && rsp.StatusCode != http.StatusCreated {
|
||||
log.Warn(fmt.Sprintf("Transfer telemetry failed, status code = %d", rsp.StatusCode), err)
|
||||
response.Success(c, nil)
|
||||
return
|
||||
}
|
||||
|
||||
response.Success(c, nil)
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package api
|
||||
|
||||
const (
|
||||
Version = "/Version"
|
||||
UpgradeTips = "/UpgradeTips"
|
||||
Login = "/Login"
|
||||
Logout = "/Logout"
|
||||
OTPUrl = "/OTPUrl"
|
||||
User = "/User"
|
||||
DetectLogList = "/DetectLogList"
|
||||
DetectLogDetail = "/DetectLogDetail"
|
||||
Behaviour = "/Behaviour"
|
||||
FalsePositives = "/FalsePositives"
|
||||
Website = "/Website"
|
||||
UploadSSLCert = "/UploadSSLCert"
|
||||
SSLCert = "/SSLCert"
|
||||
PolicyRule = "/PolicyRule"
|
||||
SwitchPolicyRule = "/SwitchPolicyRule"
|
||||
DashboardCounts = "/dashboard/counts"
|
||||
DashboardSites = "/dashboard/sites"
|
||||
DashboardQps = "/dashboard/qps"
|
||||
DashboardRequests = "/dashboard/requests"
|
||||
DashboardIntercepts = "/dashboard/intercepts"
|
||||
PolicyGroupGlobal = "/PolicyGroupGlobal"
|
||||
SrcIPConfig = "/SrcIPConfig"
|
||||
)
|
|
@ -1,128 +0,0 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"chaitin.cn/dev/go/errors"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/api/response"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/model"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/constants"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/database"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/fvm"
|
||||
)
|
||||
|
||||
func PutPolicyGroupGlobal(ctx *gin.Context) {
|
||||
var params model.PolicyGroup
|
||||
if err := ctx.BindJSON(¶ms); err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.ErrorParamNotOK, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
db := database.GetDB()
|
||||
err := db.Transaction(func(tx *gorm.DB) error {
|
||||
var pggOption model.Options
|
||||
res := tx.Where(&model.Options{Key: constants.PolicyGroupGlobal}).First(&pggOption)
|
||||
if res.Error != nil {
|
||||
return res.Error
|
||||
}
|
||||
if res.RowsAffected == 0 {
|
||||
return errors.New("Data queried does not exist")
|
||||
}
|
||||
|
||||
pggStr, err := json.Marshal(params)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.JSONBody{Err: response.ErrInternalError, Msg: err.Error()}, http.StatusInternalServerError)
|
||||
return err
|
||||
}
|
||||
|
||||
pggOption.Value = string(pggStr)
|
||||
tx.Save(&pggOption)
|
||||
|
||||
if err := fvm.PushFSL(tx); err != nil {
|
||||
return errors.New("Rules compile error, please check your params.")
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.JSONBody{Err: response.ErrInternalError, Msg: err.Error()}, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
response.Success(ctx, nil)
|
||||
}
|
||||
|
||||
func GetPolicyGroupGlobal(ctx *gin.Context) {
|
||||
var pggOption model.Options
|
||||
database.GetDB().Where(&model.Options{Key: constants.PolicyGroupGlobal}).First(&pggOption)
|
||||
|
||||
var pgg model.PolicyGroup
|
||||
err := json.Unmarshal([]byte(pggOption.Value), &pgg)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.JSONBody{Err: response.ErrInternalError, Msg: err.Error()}, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
response.Success(ctx, gin.H{"data": pgg})
|
||||
}
|
||||
|
||||
func PutSrcIPConfig(ctx *gin.Context) {
|
||||
var params model.SrcIPConfig
|
||||
if err := ctx.BindJSON(¶ms); err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.ErrorParamNotOK, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
db := database.GetDB()
|
||||
err := db.Transaction(func(tx *gorm.DB) error {
|
||||
var scOption model.Options
|
||||
res := tx.Where(&model.Options{Key: constants.SrcIPConfig}).First(&scOption)
|
||||
if res.Error != nil {
|
||||
return res.Error
|
||||
}
|
||||
if res.RowsAffected == 0 {
|
||||
return errors.New("Data queried does not exist")
|
||||
}
|
||||
|
||||
scStr, err := json.Marshal(params)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.JSONBody{Err: response.ErrInternalError, Msg: err.Error()}, http.StatusInternalServerError)
|
||||
return err
|
||||
}
|
||||
|
||||
scOption.Value = string(scStr)
|
||||
tx.Save(&scOption)
|
||||
|
||||
if err := fvm.PushFSL(tx); err != nil {
|
||||
return errors.New("Rules compile error, please check your params.")
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.JSONBody{Err: response.ErrInternalError, Msg: err.Error()}, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
response.Success(ctx, nil)
|
||||
}
|
||||
|
||||
func GetSrcIPConfig(ctx *gin.Context) {
|
||||
srcIPConfig, err := model.GetSrcIPConfig(database.GetDB().DB)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
response.Success(ctx, gin.H{"data": srcIPConfig})
|
||||
}
|
|
@ -1,174 +0,0 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/fvm"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"chaitin.cn/dev/go/errors"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/api/response"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/model"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/database"
|
||||
)
|
||||
|
||||
type putSwitchRequest struct {
|
||||
IDs []uint `json:"ids"`
|
||||
IsEnabled bool `json:"is_enabled"`
|
||||
}
|
||||
|
||||
func PostPolicyRule(ctx *gin.Context) {
|
||||
var params model.PolicyRule
|
||||
if err := ctx.BindJSON(¶ms); err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.ErrorParamNotOK, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
db := database.GetDB()
|
||||
err := db.Transaction(func(tx *gorm.DB) error {
|
||||
policyRule := &model.PolicyRule{Action: params.Action, Comment: params.Comment, IsEnabled: params.IsEnabled, Pattern: params.Pattern}
|
||||
res := tx.Create(policyRule)
|
||||
if res.Error != nil {
|
||||
return res.Error
|
||||
}
|
||||
|
||||
if err := fvm.PushFSL(tx); err != nil {
|
||||
return errors.New("Rules compile error, please check your params.")
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.JSONBody{Err: response.ErrInternalError, Msg: err.Error()}, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
response.Success(ctx, nil)
|
||||
}
|
||||
|
||||
func PutSwitchPolicyRule(ctx *gin.Context) {
|
||||
var params putSwitchRequest
|
||||
if err := ctx.BindJSON(¶ms); err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.ErrorParamNotOK, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
db := database.GetDB()
|
||||
err := db.Transaction(func(tx *gorm.DB) error {
|
||||
res := tx.Model(&model.PolicyRule{}).Where(params.IDs).Updates(model.PolicyRule{IsEnabled: params.IsEnabled})
|
||||
if res.Error != nil {
|
||||
return res.Error
|
||||
}
|
||||
if res.RowsAffected == 0 {
|
||||
return errors.New("Data queried does not exist")
|
||||
}
|
||||
|
||||
if err := fvm.PushFSL(tx); err != nil {
|
||||
return errors.New("Rules compile error, please check your params.")
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.JSONBody{Err: response.ErrInternalError, Msg: err.Error()}, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func PutPolicyRule(ctx *gin.Context) {
|
||||
var params model.PolicyRule
|
||||
if err := ctx.BindJSON(¶ms); err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.ErrorParamNotOK, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
db := database.GetDB()
|
||||
err := db.Transaction(func(tx *gorm.DB) error {
|
||||
var policyRule model.PolicyRule
|
||||
res := tx.Where(params.ID).First(&policyRule)
|
||||
if res.Error != nil {
|
||||
return res.Error
|
||||
}
|
||||
if res.RowsAffected == 0 {
|
||||
return errors.New("Data queried does not exist")
|
||||
}
|
||||
|
||||
policyRule.Action = params.Action
|
||||
policyRule.Comment = params.Comment
|
||||
policyRule.IsEnabled = params.IsEnabled
|
||||
policyRule.Pattern = params.Pattern
|
||||
tx.Save(&policyRule)
|
||||
|
||||
if err := fvm.PushFSL(tx); err != nil {
|
||||
return errors.New("Rules compile error, please check your params.")
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.JSONBody{Err: response.ErrInternalError, Msg: err.Error()}, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
response.Success(ctx, nil)
|
||||
}
|
||||
|
||||
func DeletePolicyRule(ctx *gin.Context) {
|
||||
var params idsRequest
|
||||
if err := ctx.BindJSON(¶ms); err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.ErrorParamNotOK, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
db := database.GetDB()
|
||||
err := db.Transaction(func(tx *gorm.DB) error {
|
||||
res := tx.Where(params.IDs).Delete(&model.PolicyRule{})
|
||||
if res.Error != nil {
|
||||
return res.Error
|
||||
}
|
||||
if res.RowsAffected == 0 {
|
||||
return errors.New("Data queried does not exist")
|
||||
}
|
||||
|
||||
if err := fvm.PushFSL(tx); err != nil {
|
||||
return errors.New("Rules compile error, please check your params.")
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.JSONBody{Err: response.ErrInternalError, Msg: err.Error()}, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
response.Success(ctx, nil)
|
||||
}
|
||||
|
||||
func GetPolicyRule(ctx *gin.Context) {
|
||||
var params pageRequest
|
||||
if err := ctx.BindQuery(¶ms); err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.ErrorParamNotOK, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
db := database.GetDB()
|
||||
var policyRuleList []model.PolicyRule
|
||||
db.Limit(params.PageSize).Offset(params.PageSize * (params.Page - 1)).Order("id desc").Find(&policyRuleList)
|
||||
|
||||
var total int64
|
||||
db.Model(&model.PolicyRule{}).Count(&total)
|
||||
|
||||
response.Success(ctx, gin.H{"data": policyRuleList, "total": total})
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package response
|
||||
|
||||
const (
|
||||
ErrLoginRequired = "login-required"
|
||||
ErrWrongPasscode = "wrong-passcode"
|
||||
ErrWrongTimeGap = "wrong-time-gap"
|
||||
ErrInternalError = "internal-error"
|
||||
ErrDataNotExist = "data-not-exist"
|
||||
ErrWrongFileType = "wrong-filetype"
|
||||
ErrReadOnly = "read-only"
|
||||
)
|
|
@ -1,56 +0,0 @@
|
|||
package response
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type JSONBody struct {
|
||||
Err string
|
||||
Msg string
|
||||
Data interface{}
|
||||
}
|
||||
|
||||
var (
|
||||
ErrorLoginRequired = JSONBody{ErrLoginRequired, "Login required", nil}
|
||||
ErrorParamNotOK = JSONBody{ErrInternalError, "Error occurred when extracting params", nil}
|
||||
ErrorDataNotExist = JSONBody{ErrDataNotExist, "Data queried does not exist", nil}
|
||||
ErrorReadOnly = JSONBody{ErrReadOnly, "This environment is read only", nil}
|
||||
)
|
||||
|
||||
func Success(c *gin.Context, data interface{}) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": data,
|
||||
"msg": "",
|
||||
"err": nil,
|
||||
})
|
||||
//c.Abort()
|
||||
}
|
||||
|
||||
func SuccessWithList(c *gin.Context, data interface{}) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": data,
|
||||
"msg": "",
|
||||
"err": nil,
|
||||
})
|
||||
//c.Abort()
|
||||
}
|
||||
|
||||
func SuccessWithMsg(c *gin.Context, data interface{}, msg string) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": data,
|
||||
"msg": msg,
|
||||
"err": nil,
|
||||
})
|
||||
//c.Abort()
|
||||
}
|
||||
|
||||
func Error(c *gin.Context, rsp JSONBody, status int) {
|
||||
c.JSON(status, gin.H{
|
||||
"data": rsp.Data,
|
||||
"msg": rsp.Msg,
|
||||
"err": rsp.Err,
|
||||
})
|
||||
//c.Abort()
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package response
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
const StreamContentType = "application/octet-stream"
|
||||
|
||||
func PNG(c *gin.Context, bytes []byte) {
|
||||
c.Data(http.StatusOK, StreamContentType, bytes)
|
||||
}
|
|
@ -1,211 +0,0 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"chaitin.cn/dev/go/errors"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/api/response"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/model"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/config"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/database"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/rpc"
|
||||
)
|
||||
|
||||
func publishWebsiteConfig(website *model.Website) error {
|
||||
byteWebsite, err := json.Marshal(website)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = rpc.Publish(byteWebsite, rpc.EventTypeWebsite)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func publishDeleteWebsiteConfig(id []uint) error {
|
||||
byteId, err := json.Marshal(id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = rpc.Publish(byteId, rpc.EventTypeDeleteWebsite)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func PostWebsite(ctx *gin.Context) {
|
||||
var params model.Website
|
||||
if err := ctx.BindJSON(¶ms); err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.ErrorParamNotOK, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
db := database.GetDB()
|
||||
err := db.Transaction(func(tx *gorm.DB) error {
|
||||
website := &model.Website{Comment: params.Comment, ServerNames: params.ServerNames, Upstreams: params.Upstreams, Ports: params.Ports,
|
||||
CertFilename: params.CertFilename, KeyFilename: params.KeyFilename, IsEnabled: true}
|
||||
res := tx.Create(website)
|
||||
if res.Error != nil {
|
||||
return res.Error
|
||||
}
|
||||
|
||||
if config.GlobalConfig.Server.DevMode {
|
||||
return nil
|
||||
}
|
||||
|
||||
err := publishWebsiteConfig(website)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.JSONBody{Err: response.ErrInternalError, Msg: err.Error()}, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
response.Success(ctx, nil)
|
||||
}
|
||||
|
||||
func PutWebsite(ctx *gin.Context) {
|
||||
var params model.Website
|
||||
if err := ctx.BindJSON(¶ms); err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.ErrorParamNotOK, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
db := database.GetDB()
|
||||
err := db.Transaction(func(tx *gorm.DB) error {
|
||||
var website model.Website
|
||||
res := tx.Where(params.ID).First(&website)
|
||||
if res.Error != nil {
|
||||
return res.Error
|
||||
}
|
||||
if res.RowsAffected == 0 {
|
||||
return errors.New("Data queried does not exist")
|
||||
}
|
||||
|
||||
website.Comment = params.Comment
|
||||
website.ServerNames = params.ServerNames
|
||||
website.Upstreams = params.Upstreams
|
||||
website.Ports = params.Ports
|
||||
website.CertFilename = params.CertFilename
|
||||
website.KeyFilename = params.KeyFilename
|
||||
website.IsEnabled = true
|
||||
tx.Save(&website)
|
||||
|
||||
if config.GlobalConfig.Server.DevMode {
|
||||
return nil
|
||||
}
|
||||
|
||||
err := publishWebsiteConfig(¶ms)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.JSONBody{Err: response.ErrInternalError, Msg: err.Error()}, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
response.Success(ctx, nil)
|
||||
}
|
||||
|
||||
func DeleteWebsite(ctx *gin.Context) {
|
||||
var params idsRequest
|
||||
if err := ctx.BindJSON(¶ms); err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.ErrorParamNotOK, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
db := database.GetDB()
|
||||
err := db.Transaction(func(tx *gorm.DB) error {
|
||||
res := tx.Where(params.IDs).Delete(&model.Website{})
|
||||
if res.Error != nil {
|
||||
return res.Error
|
||||
}
|
||||
if res.RowsAffected == 0 {
|
||||
return errors.New("Data queried does not exist")
|
||||
}
|
||||
|
||||
if config.GlobalConfig.Server.DevMode {
|
||||
return nil
|
||||
}
|
||||
|
||||
err := publishDeleteWebsiteConfig(params.IDs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.JSONBody{Err: response.ErrInternalError, Msg: err.Error()}, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
response.Success(ctx, nil)
|
||||
}
|
||||
|
||||
func GetWebsite(ctx *gin.Context) {
|
||||
var params pageRequest
|
||||
if err := ctx.BindQuery(¶ms); err != nil {
|
||||
logger.Error(err)
|
||||
response.Error(ctx, response.ErrorParamNotOK, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
db := database.GetDB()
|
||||
type Website struct {
|
||||
model.Website
|
||||
ReqValue int64 `json:"req_value"`
|
||||
DeniedValue int64 `json:"denied_value"`
|
||||
}
|
||||
var websiteList []Website
|
||||
db.Limit(params.PageSize).Offset(params.PageSize * (params.Page - 1)).Order("id desc").Find(&websiteList)
|
||||
|
||||
var statistics []model.SystemStatistics
|
||||
var websiteIds []string
|
||||
for _, i := range websiteList {
|
||||
websiteIds = append(websiteIds, strconv.Itoa(int(i.ID)))
|
||||
}
|
||||
db.Where("created_at >= date_trunc('day',now())").Where("website in (?)", websiteIds).Find(&statistics)
|
||||
|
||||
for i, website := range websiteList {
|
||||
for _, j := range statistics {
|
||||
if strconv.Itoa(int(website.ID)) == j.Website {
|
||||
if j.Type == "website-req" {
|
||||
websiteList[i].ReqValue = j.Value
|
||||
} else if j.Type == "website-denied" {
|
||||
websiteList[i].DeniedValue = j.Value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var total int64
|
||||
db.Model(&model.Website{}).Count(&total)
|
||||
|
||||
response.Success(ctx, gin.H{"data": websiteList, "total": total})
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package cmd
|
||||
|
||||
import "chaitin.cn/patronus/safeline-2/management/webserver/model"
|
||||
|
||||
func FakeLogs() {
|
||||
model.InitDetectLogSamples()
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"crypto/x509/pkix"
|
||||
"path/filepath"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/config"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/constants"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/utils"
|
||||
)
|
||||
|
||||
func GenCerts() error {
|
||||
if err := genServerCert(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := genClientCACert(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func genServerCert() error {
|
||||
certPath := filepath.Join(config.GlobalConfig.MgtResDir, constants.CertsPath, "server.crt")
|
||||
keyPath := filepath.Join(config.GlobalConfig.MgtResDir, constants.CertsPath, "server.key")
|
||||
if err := utils.WriteCertIfNotExist(
|
||||
certPath,
|
||||
keyPath,
|
||||
func() ([]byte, []byte, error) {
|
||||
return utils.GenerateCert(
|
||||
[]string{},
|
||||
3650,
|
||||
4096,
|
||||
&pkix.Name{
|
||||
Country: []string{"CN"},
|
||||
Province: []string{"Beijing"},
|
||||
Locality: []string{"Beijing"},
|
||||
Organization: []string{"Beijing WAF Technology Co., Ltd."},
|
||||
OrganizationalUnit: []string{"Service Infrastructure Department"},
|
||||
CommonName: "WAF Management Server",
|
||||
},
|
||||
false,
|
||||
)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func genClientCACert() error {
|
||||
certPath := filepath.Join(config.GlobalConfig.MgtResDir, constants.CertsPath, "client_ca.crt")
|
||||
keyPath := filepath.Join(config.GlobalConfig.MgtResDir, constants.CertsPath, "client_ca.key")
|
||||
if err := utils.WriteCertIfNotExist(
|
||||
certPath,
|
||||
keyPath,
|
||||
func() ([]byte, []byte, error) {
|
||||
return utils.GenerateCert(
|
||||
[]string{},
|
||||
3650,
|
||||
4096,
|
||||
&pkix.Name{
|
||||
Country: []string{"CN"},
|
||||
Province: []string{"Beijing"},
|
||||
Locality: []string{"Beijing"},
|
||||
Organization: []string{"Beijing WAF Technology Co., Ltd."},
|
||||
OrganizationalUnit: []string{"Service Infrastructure Department"},
|
||||
CommonName: "WAF Client Certificate Authority",
|
||||
},
|
||||
true,
|
||||
)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/database"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/fvm"
|
||||
)
|
||||
|
||||
func PushFSL() error {
|
||||
return fvm.PushFSL(database.GetDB().DB)
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/model"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/database"
|
||||
)
|
||||
|
||||
func ResetUser(username string) {
|
||||
db := database.GetDB()
|
||||
var user model.User
|
||||
db.Where(&model.User{Username: username}).First(&user)
|
||||
user.LastLoginTime = 0
|
||||
db.Save(&user)
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/database"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/fvm"
|
||||
)
|
||||
|
||||
func ShowFSL() (string, error) {
|
||||
return fvm.GenerateFullFSL(database.GetDB().DB)
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
# develop use only. For production, refer to `package/build/mgt-api/webserver/config.yml`
|
||||
log:
|
||||
output: stdout # "stdout", "stderr" or file path
|
||||
level: debug # "debug", "info", "warn" or "error"
|
||||
server:
|
||||
listen_addr: :9001
|
||||
dev_mode: true
|
||||
db:
|
||||
url: postgres://safeline-ce:safeline-ce@127.0.0.1/safeline-ce
|
||||
log_sql: false
|
||||
detector:
|
||||
addr: ""
|
||||
fsl_bytecode: fvm/bytecode
|
||||
grpc_server:
|
||||
listen_addr: :9002
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
module chaitin.cn/patronus/safeline-2/management/webserver
|
||||
|
||||
go 1.21
|
||||
|
||||
toolchain go1.21.3
|
||||
|
||||
require (
|
||||
chaitin.cn/dev/go/errors v0.0.0-20210324055134-dc5247602af6
|
||||
chaitin.cn/dev/go/log v0.0.0-20221220104336-05125760b10c
|
||||
chaitin.cn/dev/go/settings v0.0.0-20221220104336-05125760b10c
|
||||
github.com/gin-contrib/sessions v0.0.5
|
||||
github.com/gin-gonic/gin v1.10.0
|
||||
github.com/pquerna/otp v1.4.0
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
github.com/rogpeppe/go-internal v1.10.0
|
||||
github.com/sirupsen/logrus v1.4.2
|
||||
google.golang.org/grpc v1.65.0
|
||||
gorm.io/datatypes v1.1.1
|
||||
gorm.io/driver/postgres v1.5.9
|
||||
gorm.io/gorm v1.25.10
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
|
||||
github.com/bytedance/sonic v1.11.6 // indirect
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.20.0 // indirect
|
||||
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/gorilla/context v1.1.1 // indirect
|
||||
github.com/gorilla/securecookie v1.1.1 // indirect
|
||||
github.com/gorilla/sessions v1.2.1 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
|
||||
github.com/jackc/pgx/v5 v5.5.5 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
golang.org/x/arch v0.8.0 // indirect
|
||||
golang.org/x/sys v0.20.0 // indirect
|
||||
golang.org/x/text v0.15.0 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gorm.io/driver/mysql v1.4.7 // indirect
|
||||
)
|
|
@ -1,223 +0,0 @@
|
|||
chaitin.cn/dev/go/errors v0.0.0-20200717101723-df6132d53dc8/go.mod h1:u+ZD0shdyUt0UG9XfCgD1R5mSqXpTVoO5rwQXQeo3Eo=
|
||||
chaitin.cn/dev/go/errors v0.0.0-20210324055134-dc5247602af6 h1:1Qa9ABk907/9ZrOLbbRcS8Fqq9VhjAF/mLjbSP1qAJY=
|
||||
chaitin.cn/dev/go/errors v0.0.0-20210324055134-dc5247602af6/go.mod h1:u+ZD0shdyUt0UG9XfCgD1R5mSqXpTVoO5rwQXQeo3Eo=
|
||||
chaitin.cn/dev/go/log v0.0.0-20221220104336-05125760b10c h1:Xn9IYkxmnpDcEpV+7JIR5ufEIexd1dhqKwpOLG1mYOE=
|
||||
chaitin.cn/dev/go/log v0.0.0-20221220104336-05125760b10c/go.mod h1:xJIYwUoA2TX5mNg/RBrEPyE251BPwj+70/mM7UIhoxg=
|
||||
chaitin.cn/dev/go/settings v0.0.0-20221220104336-05125760b10c h1:tXsraF7o9iUsQY6IwpDJusc6OFhB7iv/bBTfgR3MPUU=
|
||||
chaitin.cn/dev/go/settings v0.0.0-20221220104336-05125760b10c/go.mod h1:fUvtmpG8Z8Zf5aciadL9a/vn5SB3knG7pdNJixDplPg=
|
||||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc h1:biVzkmvwrH8WK8raXaxBx6fRVTlJILwEwQGL1I/ByEI=
|
||||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
|
||||
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
|
||||
github.com/bytedance/sonic v1.8.0 h1:ea0Xadu+sHlu7x5O3gKhRpQ1IKiMrSiHttPF0ybECuA=
|
||||
github.com/bytedance/sonic v1.8.0/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
|
||||
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
|
||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
|
||||
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gin-contrib/sessions v0.0.5 h1:CATtfHmLMQrMNpJRgzjWXD7worTh7g7ritsQfmF+0jE=
|
||||
github.com/gin-contrib/sessions v0.0.5/go.mod h1:vYAuaUPqie3WUSsft6HUlCjlwwoJQs97miaG2+7neKY=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.9.0 h1:OjyFBKICoexlu99ctXNR2gg+c5pKrKMuyjgARg9qeY8=
|
||||
github.com/gin-gonic/gin v1.9.0/go.mod h1:W1Me9+hsUSyj3CePGrd1/QrKJMSJ1Tu/0hFEH89961k=
|
||||
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.11.2 h1:q3SHpufmypg+erIExEKUmsgmhDTyhcJ38oeKGACXohU=
|
||||
github.com/go-playground/validator/v10 v10.11.2/go.mod h1:NieE624vt4SCTJtD87arVLvdmjPAeV8BQlHtMnw9D7s=
|
||||
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
|
||||
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
|
||||
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||
github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA=
|
||||
github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA=
|
||||
github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8=
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ=
|
||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
||||
github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7FsgI=
|
||||
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||
github.com/jackc/pgx/v5 v5.3.0 h1:/NQi8KHMpKWHInxXesC8yD4DhkXPrVhmnwYkjp9AmBA=
|
||||
github.com/jackc/pgx/v5 v5.3.0/go.mod h1:t3JDKnCBlYIc0ewLF0Q7B8MXmoIaBOZj/ic7iHozM/8=
|
||||
github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A=
|
||||
github.com/jackc/puddle/v2 v2.2.0/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
|
||||
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
|
||||
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
|
||||
github.com/microsoft/go-mssqldb v0.17.0 h1:Fto83dMZPnYv1Zwx5vHHxpNraeEaUlQ/hhHLgZiaenE=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
|
||||
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pquerna/otp v1.4.0 h1:wZvl1TIVxKRThZIBiwOOHOGP/1+nZyWBil9Y2XNEDzg=
|
||||
github.com/pquerna/otp v1.4.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1AEg=
|
||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
||||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.2.9 h1:rmenucSohSTiyL09Y+l2OCk+FrMxGMzho2+tjr5ticU=
|
||||
github.com/ugorji/go/codec v1.2.9/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU=
|
||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
|
||||
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
|
||||
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
|
||||
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
|
||||
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
|
||||
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w=
|
||||
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM=
|
||||
google.golang.org/grpc v1.54.0 h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag=
|
||||
google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g=
|
||||
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
|
||||
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/datatypes v1.1.1 h1:XAjO7NNfUKVUvnS3+BkqMrPXxCAcxDlpOYbjnizxNCw=
|
||||
gorm.io/datatypes v1.1.1/go.mod h1:u8GEgFjJ+GpsGfgHmBUcQqHm/937t3sj/SO9dvbndTg=
|
||||
gorm.io/driver/mysql v1.4.7 h1:rY46lkCspzGHn7+IYsNpSfEv9tA+SU4SkkB+GFX125Y=
|
||||
gorm.io/driver/mysql v1.4.7/go.mod h1:SxzItlnT1cb6e1e4ZRpgJN2VYtcqJgqnHxWr4wsP8oc=
|
||||
gorm.io/driver/postgres v1.5.0 h1:u2FXTy14l45qc3UeCJ7QaAXZmZfDDv0YrthvmRq1l0U=
|
||||
gorm.io/driver/postgres v1.5.0/go.mod h1:FUZXzO+5Uqg5zzwzv4KK49R8lvGIyscBOqYrtI1Ce9A=
|
||||
gorm.io/driver/postgres v1.5.9/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSkweRGI=
|
||||
gorm.io/driver/sqlite v1.4.3 h1:HBBcZSDnWi5BW3B3rwvVTc510KGkBkexlOg0QrmLUuU=
|
||||
gorm.io/driver/sqlserver v1.4.1 h1:t4r4r6Jam5E6ejqP7N82qAJIJAht27EGT41HyPfXRw0=
|
||||
gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
|
||||
gorm.io/gorm v1.24.7-0.20230306060331-85eaf9eeda11 h1:9qNbmu21nNThCNnF5i2R3kw2aL27U8ZwbzccNjOmW0g=
|
||||
gorm.io/gorm v1.24.7-0.20230306060331-85eaf9eeda11/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
|
||||
gorm.io/gorm v1.25.10/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
|
@ -1,210 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-contrib/sessions/cookie"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/api"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/cmd"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/middleware"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/model"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/config"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/constants"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/cron"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/database"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/fvm"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/log"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/rpc"
|
||||
)
|
||||
|
||||
var (
|
||||
logger = log.GetLogger("main")
|
||||
|
||||
version = "undefined"
|
||||
githash = "undefined"
|
||||
buildstamp = "undefined"
|
||||
goVersion = "undefined"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// do something that do not raise error
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.SetLogFormatter()
|
||||
|
||||
fs := flag.NewFlagSet("webserver", flag.ExitOnError)
|
||||
showVersion := fs.Bool("v", false, "show version")
|
||||
cfgFile := fs.String("c", constants.ConfigFilePath, "config file path")
|
||||
genCerts := fs.Bool("gen_certs", false, "generate certs")
|
||||
showFSL := fs.Bool("show_fsl", false, "show full selectors")
|
||||
push_fsl := fs.Bool("push_fsl", false, "compile and push fsl")
|
||||
fakeLogs := fs.Bool("fake_logs", false, "fake logs")
|
||||
resetUsername := fs.String("reset_user", "", "reset user")
|
||||
if err := fs.Parse(os.Args[1:]); err != nil {
|
||||
logger.Fatalln("Failed to parse args: ", err)
|
||||
}
|
||||
|
||||
if *showVersion {
|
||||
i, _ := strconv.Atoi(buildstamp)
|
||||
t := time.Unix(int64(i), 0).Format("2006-01-02 15:04:05")
|
||||
fmt.Println("Version: ", version)
|
||||
fmt.Println("Githash: ", githash)
|
||||
fmt.Println("Build: ", t)
|
||||
fmt.Println("Go version: ", goVersion)
|
||||
return
|
||||
}
|
||||
|
||||
constants.Version = strings.TrimPrefix(version, "ce-")
|
||||
// init configs
|
||||
if err := config.InitConfigs(*cfgFile); err != nil {
|
||||
logger.Fatalln("Failed to init configs: ", err)
|
||||
}
|
||||
|
||||
if err := log.InitLogger(); err != nil {
|
||||
logger.Fatalln("Failed to init db: ", err)
|
||||
}
|
||||
|
||||
if *genCerts {
|
||||
if err := cmd.GenCerts(); err != nil {
|
||||
logger.Fatalln("Failed to generate certs: ", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
logger.Info("Init database")
|
||||
if err := database.InitDB(); err != nil {
|
||||
logger.Fatalln("Failed to init db: ", err)
|
||||
}
|
||||
|
||||
if *showFSL {
|
||||
if fullFSL, err := cmd.ShowFSL(); err != nil {
|
||||
logger.Fatalln("Failed to generate fsl: ", err)
|
||||
} else {
|
||||
logger.Info(strings.ReplaceAll(strings.ReplaceAll(fullFSL, ";", ";\n"), "CREATE", "\nCREATE"))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
logger.Info("Init models")
|
||||
if err := model.InitModels(); err != nil {
|
||||
logger.Fatalln("Failed to init models: ", err)
|
||||
}
|
||||
|
||||
if len(*resetUsername) > 0 {
|
||||
logger.Infoln("reset user:", *resetUsername)
|
||||
cmd.ResetUser(*resetUsername)
|
||||
logger.Infoln("success!")
|
||||
return
|
||||
}
|
||||
|
||||
if *fakeLogs {
|
||||
logger.Infoln("faking logs...")
|
||||
cmd.FakeLogs()
|
||||
logger.Infoln("success!")
|
||||
return
|
||||
}
|
||||
|
||||
if *push_fsl {
|
||||
logger.Infoln("push fsl...")
|
||||
if err := cmd.PushFSL(); err != nil {
|
||||
logger.Fatalln("Failed to generate fsl: ", err)
|
||||
}
|
||||
logger.Infoln("success!")
|
||||
return
|
||||
}
|
||||
|
||||
logger.Info("Init FVM bytecode")
|
||||
fvm.InitFVMBytecode()
|
||||
|
||||
if err := cron.StartCron(); err != nil {
|
||||
logger.Fatalln("Failed to start cron: ", err)
|
||||
}
|
||||
|
||||
if err := rpc.StartGRPCSever(); err != nil {
|
||||
logger.Fatalln("Failed to start gRPC server: ", err)
|
||||
}
|
||||
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
r := gin.Default()
|
||||
|
||||
var option model.Options
|
||||
database.GetDB().Where(&model.Options{Key: constants.SecretKey}).First(&option)
|
||||
logger.Debugf("Secret: %s", option.Value)
|
||||
store := cookie.NewStore([]byte(option.Value))
|
||||
r.Use(sessions.Sessions("session", store))
|
||||
|
||||
publicRouters := r.Group("/api")
|
||||
publicRouters.POST(api.Login, api.PostLogin)
|
||||
publicRouters.POST(api.Logout, api.PostLogout)
|
||||
publicRouters.POST(api.Behaviour, api.PostBehaviour)
|
||||
publicRouters.POST(api.FalsePositives, api.PostFalsePositives)
|
||||
publicRouters.GET(api.OTPUrl, api.GetOTPUrl)
|
||||
publicRouters.GET(api.Version, api.GetVersion)
|
||||
publicRouters.GET(api.UpgradeTips, api.GetUpgradeTips)
|
||||
// test use
|
||||
publicRouters.GET("/Ping", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "pong",
|
||||
})
|
||||
})
|
||||
|
||||
limitedRouters := r.Group("/api")
|
||||
noAuth, existed := os.LookupEnv("NO_AUTH")
|
||||
if existed && len(noAuth) >= 0 {
|
||||
logger.Warn("No auth")
|
||||
} else {
|
||||
limitedRouters.Use(middleware.AuthRequired)
|
||||
}
|
||||
readOnly, existed := os.LookupEnv("READ_ONLY")
|
||||
if existed && len(readOnly) >= 0 {
|
||||
logger.Warn("Read only")
|
||||
limitedRouters.Use(middleware.ReadOnly)
|
||||
}
|
||||
|
||||
limitedRouters.GET(api.User, api.GetUser)
|
||||
|
||||
limitedRouters.GET(api.DetectLogList, api.GetDetectLogList)
|
||||
limitedRouters.GET(api.DetectLogDetail, api.GetDetectLogDetail)
|
||||
|
||||
limitedRouters.POST(api.Website, api.PostWebsite)
|
||||
limitedRouters.PUT(api.Website, api.PutWebsite)
|
||||
limitedRouters.DELETE(api.Website, api.DeleteWebsite)
|
||||
limitedRouters.GET(api.Website, api.GetWebsite)
|
||||
|
||||
limitedRouters.POST(api.UploadSSLCert, api.PostUploadSSLCert)
|
||||
limitedRouters.POST(api.SSLCert, api.PostSSLCert)
|
||||
|
||||
limitedRouters.POST(api.PolicyRule, api.PostPolicyRule)
|
||||
limitedRouters.PUT(api.PolicyRule, api.PutPolicyRule)
|
||||
limitedRouters.DELETE(api.PolicyRule, api.DeletePolicyRule)
|
||||
limitedRouters.GET(api.PolicyRule, api.GetPolicyRule)
|
||||
limitedRouters.PUT(api.SwitchPolicyRule, api.PutSwitchPolicyRule)
|
||||
|
||||
// 仪表盘接口
|
||||
limitedRouters.GET(api.DashboardCounts, api.GetDashboardCounts)
|
||||
limitedRouters.GET(api.DashboardSites, api.GetDashboardSites)
|
||||
limitedRouters.GET(api.DashboardQps, api.GetDashboardQps)
|
||||
limitedRouters.GET(api.DashboardRequests, api.GetDashboardRequests)
|
||||
limitedRouters.GET(api.DashboardIntercepts, api.GetDashboardIntercepts)
|
||||
|
||||
limitedRouters.GET(api.PolicyGroupGlobal, api.GetPolicyGroupGlobal)
|
||||
limitedRouters.PUT(api.PolicyGroupGlobal, api.PutPolicyGroupGlobal)
|
||||
|
||||
limitedRouters.GET(api.SrcIPConfig, api.GetSrcIPConfig)
|
||||
limitedRouters.PUT(api.SrcIPConfig, api.PutSrcIPConfig)
|
||||
|
||||
logger.Info("Staring...")
|
||||
if err := r.Run(config.GlobalConfig.Server.ListenAddr); err != nil {
|
||||
logger.Fatalln("Error occurred when running web server: ", err)
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package middleware
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/api/response"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/constants"
|
||||
)
|
||||
|
||||
func AuthRequired(c *gin.Context) {
|
||||
session := sessions.Default(c)
|
||||
|
||||
user := session.Get(constants.DefaultSessionUserKey)
|
||||
if user == nil {
|
||||
response.Error(c, response.ErrorLoginRequired, http.StatusUnauthorized)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
// extend session expired time
|
||||
session.Options(sessions.Options{
|
||||
Path: "/",
|
||||
MaxAge: 3600 * 24 * 7,
|
||||
//Domain: options.Domain,
|
||||
//HttpOnly: true,
|
||||
//SameSite: http.SameSiteLaxMode,
|
||||
//Secure: false,
|
||||
})
|
||||
|
||||
if err := session.Save(); err != nil {
|
||||
response.Error(c, response.JSONBody{Err: response.ErrInternalError, Msg: "Error occurred when creating sessions"}, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
c.Next()
|
||||
}
|
||||
|
||||
func ReadOnly(c *gin.Context) {
|
||||
if c.Request.Method != "GET" && c.Request.Method != "HEAD" && c.Request.Method != "OPTIONS" {
|
||||
response.Error(c, response.ErrorReadOnly, http.StatusBadRequest)
|
||||
c.Abort()
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/log"
|
||||
)
|
||||
|
||||
// Base is a replacement for gorm.Model without DeletedAt, which is considered to be not good.
|
||||
type Base struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
CreatedAt time.Time ` json:"created_at"`
|
||||
UpdatedAt time.Time ` json:"updated_at"`
|
||||
}
|
||||
|
||||
var logger = log.GetLogger("model")
|
|
@ -1,7 +0,0 @@
|
|||
package model
|
||||
|
||||
type Behaviour struct {
|
||||
Base
|
||||
SrcRouter string `json:"src_router"`
|
||||
DstRouter string `json:"dst_router"`
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"chaitin.cn/dev/go/errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type sqlResult struct {
|
||||
Ids string `json:"ids"`
|
||||
}
|
||||
|
||||
func DBPatch140(tx *gorm.DB) error {
|
||||
if !tx.Migrator().HasTable(&SystemStatistics{}) {
|
||||
return nil
|
||||
}
|
||||
|
||||
var result []sqlResult
|
||||
//SELECT string_agg(id::text, ',') as ids FROM mgt_system_statistics GROUP BY (type, website, created_at) HAVING COUNT(*) > 1) as tmp
|
||||
res := tx.Model(&SystemStatistics{}).Select("string_agg(id::text, ',') as ids").Group("type, website, created_at").Having("COUNT(*) > 1").Find(&result)
|
||||
if res.Error != nil {
|
||||
return errors.Wrap(res.Error, "Failed to select data")
|
||||
}
|
||||
|
||||
if len(result) <= 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var deleteIds []string
|
||||
for _, s := range result {
|
||||
tmpIds := strings.Split(s.Ids, ",")
|
||||
deleteIds = append(deleteIds, tmpIds...)
|
||||
}
|
||||
deleteRes := tx.Delete(&SystemStatistics{}, deleteIds)
|
||||
|
||||
return errors.Wrap(deleteRes.Error, "Failed to delete")
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"chaitin.cn/dev/go/errors"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/constants"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/database"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/utils"
|
||||
)
|
||||
|
||||
// DetectLog is designed to be used in response, not a good naming.
|
||||
type DetectLog struct {
|
||||
DetectLogBasic
|
||||
DetectLogDetail
|
||||
EventId string `json:"event_id"` // to eliminate ambiguous
|
||||
Website string `json:"website"`
|
||||
AttackType string `json:"attack_type"`
|
||||
Module string `json:"module"`
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
func getRuleModule(ruleId string, attackType int) string {
|
||||
var module string
|
||||
if strings.HasPrefix(ruleId, "m_rule") { // `m_rule/65543`
|
||||
module = "m_rule"
|
||||
} else if strings.HasPrefix(ruleId, "/") {
|
||||
if attackType == -2 {
|
||||
module = "whitelist"
|
||||
} else { // if attackType == -3
|
||||
module = "blacklist"
|
||||
}
|
||||
} else {
|
||||
module = ruleId
|
||||
}
|
||||
return constants.RuleModule[module]
|
||||
}
|
||||
|
||||
func getRuleReason(ruleId string, attackType int) string {
|
||||
var reason string
|
||||
if strings.HasPrefix(ruleId, "m_rule") { // `m_rule/65543`
|
||||
reason = constants.RuleReason[strings.ReplaceAll(ruleId, "m_rule/", "")]
|
||||
} else if strings.HasPrefix(ruleId, "/") {
|
||||
reason = ruleId[1:]
|
||||
} else {
|
||||
reason = fmt.Sprintf("检测到 %s 攻击", getAttackType(attackType))
|
||||
}
|
||||
return reason
|
||||
}
|
||||
|
||||
func getAttackType(at int) string {
|
||||
atStr, ok := constants.AttackType[at]
|
||||
if !ok {
|
||||
atStr = constants.AttackType[62] // unknown
|
||||
}
|
||||
return atStr
|
||||
}
|
||||
|
||||
func getCountry(country string) string {
|
||||
countryStr, ok := constants.CountryCode[country]
|
||||
if !ok {
|
||||
countryStr = ""
|
||||
}
|
||||
return countryStr
|
||||
}
|
||||
|
||||
func TransformDetectLog(basic *DetectLogBasic, detail *DetectLogDetail) (*DetectLog, error) {
|
||||
if basic == nil {
|
||||
return nil, errors.New("basic *DetectLogBasic cannot be nil")
|
||||
}
|
||||
if detail != nil && basic.EventId != detail.EventId {
|
||||
return nil, errors.New("EventId field should be the same for basic and detail")
|
||||
}
|
||||
|
||||
basic.Country = getCountry(basic.Country)
|
||||
dLog := DetectLog{
|
||||
DetectLogBasic: *basic,
|
||||
EventId: basic.EventId,
|
||||
Website: utils.BuildUrl(basic.Protocol, basic.Host, basic.DstPort, basic.UrlPath),
|
||||
AttackType: getAttackType(basic.AttackType),
|
||||
Module: getRuleModule(basic.RuleId, basic.AttackType),
|
||||
Reason: getRuleReason(basic.RuleId, basic.AttackType),
|
||||
}
|
||||
if detail != nil {
|
||||
dLog.DetectLogDetail = *detail
|
||||
}
|
||||
|
||||
return &dLog, nil
|
||||
}
|
||||
|
||||
type DetectLogBasic struct {
|
||||
ID uint `json:"id" gorm:"primarykey"`
|
||||
EventId string `json:"event_id" gorm:"uniqueIndex;not null"`
|
||||
|
||||
SiteUUID string `json:"site_uuid" gorm:"column:site_uuid"`
|
||||
SrcIp string `json:"src_ip" gorm:"index"`
|
||||
SocketIp string `json:"socket_ip" gorm:"index"`
|
||||
|
||||
Protocol int `json:"protocol"`
|
||||
Host string `json:"host"`
|
||||
UrlPath string `json:"url_path"`
|
||||
DstPort uint `json:"dst_port"`
|
||||
|
||||
Country string `json:"country"`
|
||||
Province string `json:"province"`
|
||||
City string `json:"city"`
|
||||
|
||||
AttackType int `json:"attack_type" gorm:"index"`
|
||||
RiskLevel int `json:"risk_level" gorm:"index"`
|
||||
Action int `json:"action" gorm:"index"`
|
||||
RuleId string `json:"rule_id"`
|
||||
|
||||
Timestamp int64 `json:"timestamp" gorm:"index"`
|
||||
}
|
||||
|
||||
type DetectLogDetail struct {
|
||||
ID uint ` gorm:"primarykey"`
|
||||
EventId string ` gorm:"uniqueIndex;not null"`
|
||||
|
||||
SrcPort uint `json:"src_port"`
|
||||
DstIp string `json:"dst_ip"`
|
||||
|
||||
Method string `json:"method"`
|
||||
QueryString string `json:"query_string"`
|
||||
StatusCode uint `json:"status_code"`
|
||||
|
||||
ReqHeader string `json:"req_header"`
|
||||
ReqBody string `json:"req_body"`
|
||||
RspHeader string `json:"rsp_header"`
|
||||
RspBody string `json:"rsp_body"`
|
||||
|
||||
Payload string `json:"payload"`
|
||||
Location string `json:"location"`
|
||||
DecodePath string `json:"decode_path"`
|
||||
}
|
||||
|
||||
func InitDetectLogSamples() {
|
||||
db := database.GetDB()
|
||||
var detectLogBasicList []DetectLogBasic
|
||||
var detectLogDetailList []DetectLogDetail
|
||||
|
||||
timestamp := time.Now().Unix()
|
||||
detail := DetectLogDetail{
|
||||
SrcPort: 58694,
|
||||
DstIp: "10.2.35.143",
|
||||
Method: "GET",
|
||||
QueryString: "",
|
||||
ReqHeader: "GET /webshell.php HTTP/1.1\nUser-Agent: curl/7.77.0\nAccept: */*\n\n\"",
|
||||
ReqBody: "",
|
||||
RspHeader: "",
|
||||
RspBody: "",
|
||||
Payload: "",
|
||||
Location: "urlpath",
|
||||
DecodePath: "",
|
||||
}
|
||||
|
||||
protocolList := []int{constants.ProtocolHTTP, constants.ProtocolHTTPS}
|
||||
portList := []uint{80, 443}
|
||||
provinceList := []string{}
|
||||
cityList := []string{}
|
||||
ipList := []string{}
|
||||
ruleIdList := []string{}
|
||||
|
||||
for i := 0; i < 100; i++ {
|
||||
randInt := rand.Intn(1000)
|
||||
eventId := utils.RandStr(32)
|
||||
|
||||
basic := DetectLogBasic{}
|
||||
basic.EventId = eventId
|
||||
basic.SrcIp = ipList[randInt%len(ipList)]
|
||||
basic.SocketIp = ipList[randInt%len(ipList)]
|
||||
basic.Protocol = protocolList[randInt%len(protocolList)]
|
||||
basic.DstPort = portList[randInt%len(portList)]
|
||||
basic.Host = fmt.Sprintf("%s.com", utils.RandStr(5))
|
||||
basic.UrlPath = fmt.Sprintf("/%s", utils.RandStr(10))
|
||||
basic.Country = "CN"
|
||||
basic.Province = provinceList[randInt%len(provinceList)]
|
||||
basic.City = cityList[randInt%len(cityList)]
|
||||
basic.AttackType = randInt % 32
|
||||
basic.RiskLevel = randInt % 4
|
||||
basic.Action = randInt % 2
|
||||
basic.RuleId = ruleIdList[randInt%len(ruleIdList)]
|
||||
basic.Timestamp = timestamp - int64(randInt*100)
|
||||
|
||||
detailCopy := detail
|
||||
detailCopy.EventId = eventId
|
||||
detectLogBasicList = append(detectLogBasicList, basic)
|
||||
detectLogDetailList = append(detectLogDetailList, detailCopy)
|
||||
}
|
||||
db.CreateInBatches(detectLogBasicList, 100)
|
||||
db.CreateInBatches(detectLogDetailList, 100)
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/database"
|
||||
)
|
||||
|
||||
func InitModels() error {
|
||||
db := database.GetDB()
|
||||
err := db.Transaction(func(tx *gorm.DB) error {
|
||||
//
|
||||
if err := DBPatch140(tx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := db.AutoMigrate(&User{}, &DetectLogBasic{}, &DetectLogDetail{}, &Behaviour{}, &Options{}, &Website{}, &PolicyRule{}, &SystemStatistics{}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := initAdminUser(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := initOptions(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := initPolicyGroupGlobal(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := initSrcIPConfig(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//InitDetectLogSamples()
|
||||
|
||||
return nil
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"gorm.io/gorm/clause"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/config"
|
||||
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/constants"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/pkg/database"
|
||||
"chaitin.cn/patronus/safeline-2/management/webserver/utils"
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
Base
|
||||
Key string `gorm:"column:key;uniqueIndex"`
|
||||
Value string `gorm:"column:value;"`
|
||||
}
|
||||
|
||||
func initOptions() error {
|
||||
db := database.GetDB()
|
||||
|
||||
secretKey := Options{Key: constants.SecretKey, Value: utils.RandStr(32)}
|
||||
db.Clauses(clause.OnConflict{DoNothing: true}).Create(&secretKey)
|
||||
|
||||
machineId := Options{Key: constants.MachineID, Value: utils.RandStr(32)}
|
||||
_ = db.Clauses(clause.OnConflict{DoNothing: true}).Create(&machineId)
|
||||
go NotifyInstallation(machineId.Value)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func NotifyInstallation(machineId string) {
|
||||
logger.Info("Notify installation")
|
||||
tr := pkg.TelemetryRequest{
|
||||
Telemetry: pkg.TelemetryInfo{
|
||||
Id: constants.TelemetryId,
|
||||
},
|
||||
Safeline: pkg.SafelineInfo{
|
||||
Id: machineId,
|
||||
Type: constants.Installation,
|
||||
Version: constants.Version,
|
||||
},
|
||||
}
|
||||
data, err := json.Marshal(tr)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
reader := bytes.NewReader(data)
|
||||
rsp, err := pkg.DoPostTelemetry(utils.GetHTTPClient(), config.GlobalConfig.Telemetry.Addr, reader)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
if rsp.StatusCode != http.StatusOK && rsp.StatusCode != http.StatusCreated {
|
||||
logger.Errorf("transfer telemetry %s failed, status code = %d", constants.Installation, rsp.StatusCode)
|
||||
return
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package model
|
||||
|
||||
import "gorm.io/datatypes"
|
||||
|
||||
type PolicyRule struct {
|
||||
Base
|
||||
Action int `gorm:"action" json:"action"`
|
||||
Comment string `gorm:"comment" json:"comment"`
|
||||
Pattern datatypes.JSON `gorm:"pattern" json:"pattern"`
|
||||
IsEnabled bool `gorm:"is_enabled;default=true" json:"is_enabled"`
|
||||
}
|
||||
|
||||
type PolicyRulePattern struct {
|
||||
K string `json:"k"`
|
||||
Op string `json:"op"`
|
||||
V string `json:"v"`
|
||||
}
|
||||
|
||||
const (
|
||||
KeySrcIP = "src_ip"
|
||||
KeyURI = "uri"
|
||||
KeyHost = "host"
|
||||
|
||||
OpEq = "eq" // 完全相等
|
||||
OpMatch = "match" // 模糊匹配
|
||||
OpCIDR = "cidr" // CIDR
|
||||
OpHas = "has" // 关键字
|
||||
OpPrefix = "prefix" // 前缀关键字
|
||||
OpRe = "re" // 正则
|
||||
)
|
|
@ -1,11 +0,0 @@
|
|||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
type SystemStatistics struct {
|
||||
ID uint `json:"id" gorm:"primarykey"`
|
||||
Type string `json:"type" gorm:"index;uniqueIndex:type_website_createdat"`
|
||||
Value int64 `json:"value"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"index;uniqueIndex:type_website_createdat"`
|
||||
Website string `json:"website" gorm:"index;uniqueIndex:type_website_createdat"`
|
||||
}
|