|
|
@ -104,10 +104,12 @@ func parseIP(s string) *router.CIDR {
|
|
|
|
func parseFieldRule(msg json.RawMessage) (*router.RoutingRule, error) {
|
|
|
|
func parseFieldRule(msg json.RawMessage) (*router.RoutingRule, error) {
|
|
|
|
type RawFieldRule struct {
|
|
|
|
type RawFieldRule struct {
|
|
|
|
RouterRule
|
|
|
|
RouterRule
|
|
|
|
Domain *StringList `json:"domain"`
|
|
|
|
Domain *StringList `json:"domain"`
|
|
|
|
IP *StringList `json:"ip"`
|
|
|
|
IP *StringList `json:"ip"`
|
|
|
|
Port *PortRange `json:"port"`
|
|
|
|
Port *PortRange `json:"port"`
|
|
|
|
Network *NetworkList `json:"network"`
|
|
|
|
Network *NetworkList `json:"network"`
|
|
|
|
|
|
|
|
SourceIP *StringList `json:"source"`
|
|
|
|
|
|
|
|
User *StringList `json:"user"`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rawFieldRule := new(RawFieldRule)
|
|
|
|
rawFieldRule := new(RawFieldRule)
|
|
|
|
err := json.Unmarshal(msg, rawFieldRule)
|
|
|
|
err := json.Unmarshal(msg, rawFieldRule)
|
|
|
@ -149,6 +151,21 @@ func parseFieldRule(msg json.RawMessage) (*router.RoutingRule, error) {
|
|
|
|
rule.NetworkList = rawFieldRule.Network.Build()
|
|
|
|
rule.NetworkList = rawFieldRule.Network.Build()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if rawFieldRule.SourceIP != nil {
|
|
|
|
|
|
|
|
for _, ip := range *rawFieldRule.IP {
|
|
|
|
|
|
|
|
ipRule := parseIP(ip)
|
|
|
|
|
|
|
|
if ipRule != nil {
|
|
|
|
|
|
|
|
rule.SourceCidr = append(rule.SourceCidr, ipRule)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if rawFieldRule.User != nil {
|
|
|
|
|
|
|
|
for _, s := range *rawFieldRule.User {
|
|
|
|
|
|
|
|
rule.UserEmail = append(rule.UserEmail, s)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return rule, nil
|
|
|
|
return rule, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|