Files
EdgeCommon/pkg/serverconfigs/firewallconfigs/http_firewall_rule_set.go

44 lines
1.4 KiB
Go
Raw Normal View History

2020-10-06 21:02:21 +08:00
package firewallconfigs
import "github.com/iwind/TeaGo/maps"
2021-07-14 22:46:31 +08:00
// HTTPFirewallActionConfig 单个动作配置
type HTTPFirewallActionConfig struct {
Code HTTPFirewallActionString `yaml:"code" json:"code"`
Options maps.Map `yaml:"options" json:"options"`
}
// HTTPFirewallRuleSet 规则集定义
2020-10-06 21:02:21 +08:00
type HTTPFirewallRuleSet struct {
2021-07-14 22:46:31 +08:00
Id int64 `yaml:"id" json:"id"`
IsOn bool `yaml:"isOn" json:"isOn"`
Name string `yaml:"name" json:"name"`
Code string `yaml:"code" json:"code"`
Description string `yaml:"description" json:"description"`
Connector string `yaml:"connector" json:"connector"`
RuleRefs []*HTTPFirewallRuleRef `yaml:"ruleRefs" json:"ruleRefs"`
Rules []*HTTPFirewallRule `yaml:"rules" json:"rules"`
Actions []*HTTPFirewallActionConfig `yaml:"actions" json:"actions"`
//Action string `yaml:"action" json:"action"` // deprecated, v0.2.5
//ActionOptions maps.Map `yaml:"actionOptions" json:"actionOptions"` // deprecated, v0.2.5
2020-10-06 21:02:21 +08:00
}
2021-07-14 22:46:31 +08:00
// Init 初始化
2020-10-06 21:02:21 +08:00
func (this *HTTPFirewallRuleSet) Init() error {
for _, rule := range this.Rules {
err := rule.Init()
if err != nil {
return err
}
}
2021-07-14 22:46:31 +08:00
2020-10-06 21:02:21 +08:00
return nil
}
2021-07-14 22:46:31 +08:00
// AddRule 添加规则
2020-10-06 21:02:21 +08:00
func (this *HTTPFirewallRuleSet) AddRule(rule *HTTPFirewallRule) {
this.Rules = append(this.Rules, rule)
}