Browse Source

Fix Simplified Router Bug in Processing Rules

Shelikhoo 3 years ago
parent
commit
dae391fa41
1 changed files with 12 additions and 3 deletions
  1. 12 3
      app/router/router.go

+ 12 - 3
app/router/router.go

@@ -223,7 +223,7 @@ func init() {
 					rule.Domain = append(rule.Domain, geo.Domain...)
 					rule.Domain = append(rule.Domain, geo.Domain...)
 				}
 				}
 			}
 			}
-			{
+			if v.PortList != "" {
 				portList := &cfgcommon.PortList{}
 				portList := &cfgcommon.PortList{}
 				err := portList.UnmarshalText(v.PortList)
 				err := portList.UnmarshalText(v.PortList)
 				if err != nil {
 				if err != nil {
@@ -231,7 +231,7 @@ func init() {
 				}
 				}
 				rule.PortList = portList.Build()
 				rule.PortList = portList.Build()
 			}
 			}
-			{
+			if v.SourcePortList != "" {
 				portList := &cfgcommon.PortList{}
 				portList := &cfgcommon.PortList{}
 				err := portList.UnmarshalText(v.SourcePortList)
 				err := portList.UnmarshalText(v.SourcePortList)
 				if err != nil {
 				if err != nil {
@@ -240,12 +240,21 @@ func init() {
 				rule.SourcePortList = portList.Build()
 				rule.SourcePortList = portList.Build()
 			}
 			}
 			rule.Domain = v.Domain
 			rule.Domain = v.Domain
-			rule.Networks = net.ParseNetworks(v.Networks)
+			if v.Networks != "" {
+				rule.Networks = net.ParseNetworks(v.Networks)
+			}
 			rule.Protocol = v.Protocol
 			rule.Protocol = v.Protocol
 			rule.Attributes = v.Attributes
 			rule.Attributes = v.Attributes
 			rule.UserEmail = v.UserEmail
 			rule.UserEmail = v.UserEmail
 			rule.InboundTag = v.InboundTag
 			rule.InboundTag = v.InboundTag
 			rule.DomainMatcher = v.DomainMatcher
 			rule.DomainMatcher = v.DomainMatcher
+			switch s := v.TargetTag.(type) {
+			case *SimplifiedRoutingRule_Tag:
+				rule.TargetTag = &RoutingRule_Tag{s.Tag}
+			case *SimplifiedRoutingRule_BalancingTag:
+				rule.TargetTag = &RoutingRule_BalancingTag{s.BalancingTag}
+			}
+			routingRules = append(routingRules, rule)
 		}
 		}
 
 
 		fullConfig := &Config{
 		fullConfig := &Config{