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

36 lines
1.1 KiB
Go
Raw Normal View History

2020-10-06 21:02:21 +08:00
package firewallconfigs
import (
"regexp"
"strings"
)
var namedParamReg = regexp.MustCompile(`^\${\s*(.+)\s*}$`)
2020-10-06 21:02:21 +08:00
type HTTPFirewallRule struct {
Id int64 `yaml:"id" json:"id"`
IsOn bool `yaml:"isOn" json:"isOn"`
Param string `yaml:"param" json:"param"`
ParamFilters []*ParamFilter `yaml:"paramFilters" json:"paramFilters"`
2020-10-06 21:02:21 +08:00
Operator string `yaml:"operator" json:"operator"`
Value string `yaml:"value" json:"value"`
IsCaseInsensitive bool `yaml:"isCaseInsensitive" json:"isCaseInsensitive"`
CheckpointOptions map[string]interface{} `yaml:"checkpointOptions" json:"checkpointOptions"`
Description string `yaml:"description" json:"description"`
}
func (this *HTTPFirewallRule) Init() error {
2020-10-08 11:11:29 +08:00
// TODO 执行更严谨的校验
2020-10-06 21:02:21 +08:00
return nil
}
func (this *HTTPFirewallRule) Prefix() string {
result := namedParamReg.FindStringSubmatch(this.Param)
if len(result) > 0 {
param := result[1]
pieces := strings.Split(param, ".")
return pieces[0]
}
return this.Param
}