WAF策略增加显示页面动作默认设置

This commit is contained in:
GoEdgeLab
2024-01-20 16:18:49 +08:00
parent d83476d31f
commit ab829b9156
10 changed files with 310 additions and 249 deletions

View File

@@ -2,7 +2,7 @@ package firewallconfigs
import "net/http"
// HTTPFirewallBlockAction url client configure
// HTTPFirewallBlockAction default block action
type HTTPFirewallBlockAction struct {
IsPrior bool `yaml:"isPrior" json:"isPrior"`

View File

@@ -5,6 +5,12 @@ import (
)
var AllActions = []*HTTPFirewallActionDefinition{
{
Name: "显示网页",
Code: HTTPFirewallActionPage,
Description: "显示请求被拦截的网页。",
Category: HTTPFirewallActionCategoryBlock,
},
{
Name: "阻止",
Code: HTTPFirewallActionBlock,
@@ -29,12 +35,6 @@ var AllActions = []*HTTPFirewallActionDefinition{
Description: "将此IP记录到某个IP名单中。",
Category: HTTPFirewallActionCategoryBlock,
},
{
Name: "显示网页",
Code: HTTPFirewallActionPage,
Description: "在网页中显示提示文字。",
Category: HTTPFirewallActionCategoryBlock,
},
{
Name: "跳转",
Code: HTTPFirewallActionRedirect,

View File

@@ -0,0 +1,34 @@
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
package firewallconfigs
import "net/http"
// HTTPFirewallPageAction default page action
type HTTPFirewallPageAction struct {
IsPrior bool `yaml:"isPrior" json:"isPrior"`
Status int `yaml:"status" json:"status"`
Body string `yaml:"body" json:"body"`
}
func DefaultHTTPFirewallPageAction() *HTTPFirewallPageAction {
return &HTTPFirewallPageAction{
Status: http.StatusForbidden,
Body: `<!DOCTYPE html>
<html lang="en">
<head>
<title>403 Forbidden</title>
<style>
address { line-height: 1.8; }
</style>
</head>
<body>
<h1>403 Forbidden By WAF</h1>
<address>Connection: ${remoteAddr} (Client) -&gt; ${serverAddr} (Server)</address>
<address>Request ID: ${requestId}</address>
</body>
</html>`,
}
}

View File

@@ -15,6 +15,7 @@ type HTTPFirewallPolicy struct {
Outbound *HTTPFirewallOutboundConfig `yaml:"outbound" json:"outbound"`
BlockOptions *HTTPFirewallBlockAction `yaml:"blockOptions" json:"blockOptions"`
CaptchaOptions *HTTPFirewallCaptchaAction `yaml:"captchaOptions" json:"captchaOptions"`
PageOptions *HTTPFirewallPageAction `yaml:"pageOptions" json:"pageOptions"`
Mode FirewallMode `yaml:"mode" json:"mode"`
UseLocalFirewall bool `yaml:"useLocalFirewall" json:"useLocalFirewall"`
SYNFlood *SYNFloodConfig `yaml:"synFlood" json:"synFlood"`