Initial commit (code only without large binaries)
This commit is contained in:
56
EdgeCommon/pkg/nodeconfigs/http_cc_policy_plus.go
Normal file
56
EdgeCommon/pkg/nodeconfigs/http_cc_policy_plus.go
Normal file
@@ -0,0 +1,56 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build plus
|
||||
|
||||
package nodeconfigs
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
|
||||
)
|
||||
|
||||
const (
|
||||
HTTPCCPolicyMaxConnectionsPerIP = 30
|
||||
HTTPCCPolicyRedirectsCheckingValidatePath = "/GE/CC/VALIDATOR"
|
||||
HTTPCCPolicyRedirectsCheckingDurationSeconds = 120
|
||||
HTTPCCPolicyRedirectsCheckingMaxRedirects = 30
|
||||
HTTPCCPolicyRedirectsCheckingBlockSeconds = 3600
|
||||
)
|
||||
|
||||
// HTTPCCPolicy CC策略
|
||||
type HTTPCCPolicy struct {
|
||||
IsOn bool `json:"isOn" yaml:"isOn"`
|
||||
Thresholds []*serverconfigs.HTTPCCThreshold `json:"thresholds" yaml:"thresholds"` // 阈值
|
||||
MaxConnectionsPerIP int `json:"maxConnectionsPerIP" yaml:"maxConnectionsPerIP"` // 单IP最大并发连接数
|
||||
|
||||
// 跳转校验
|
||||
RedirectsChecking struct {
|
||||
ValidatePath string `json:"validatePath" yaml:"validatePath"` // 校验路径
|
||||
DurationSeconds int `json:"durationSeconds" yaml:"durationSeconds"` // 无效跳转检测周期
|
||||
MaxRedirects int `json:"maxRedirects" yaml:"maxRedirects"` // 最大跳转次数
|
||||
BlockSeconds int `json:"blockSeconds" yaml:"blockSeconds"` // 拦截时间
|
||||
} `json:"redirectsChecking" yaml:"redirectsChecking"`
|
||||
|
||||
// 防火墙策略
|
||||
Firewall struct {
|
||||
Scope firewallconfigs.FirewallScope `json:"scope" yaml:"scope"`
|
||||
} `json:"firewall" yaml:"firewall"`
|
||||
}
|
||||
|
||||
func NewHTTPCCPolicy() *HTTPCCPolicy {
|
||||
var policy = &HTTPCCPolicy{
|
||||
IsOn: true,
|
||||
}
|
||||
policy.Firewall.Scope = firewallconfigs.FirewallScopeGlobal
|
||||
return policy
|
||||
}
|
||||
|
||||
func (this *HTTPCCPolicy) Init() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *HTTPCCPolicy) FirewallScope() firewallconfigs.FirewallScope {
|
||||
if len(this.Firewall.Scope) == 0 {
|
||||
return firewallconfigs.FirewallScopeGlobal
|
||||
}
|
||||
return this.Firewall.Scope
|
||||
}
|
||||
Reference in New Issue
Block a user