Fix update route address set

This commit is contained in:
世界 2025-05-20 18:17:20 +08:00
parent e2bfbdd389
commit 82b096185f
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4

View File

@ -214,7 +214,6 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo
if !loaded { if !loaded {
return nil, E.New("parse route_address_set: rule-set not found: ", routeAddressSet) return nil, E.New("parse route_address_set: rule-set not found: ", routeAddressSet)
} }
ruleSet.IncRef()
inbound.routeRuleSet = append(inbound.routeRuleSet, ruleSet) inbound.routeRuleSet = append(inbound.routeRuleSet, ruleSet)
} }
for _, routeExcludeAddressSet := range options.RouteExcludeAddressSet { for _, routeExcludeAddressSet := range options.RouteExcludeAddressSet {
@ -222,7 +221,6 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo
if !loaded { if !loaded {
return nil, E.New("parse route_exclude_address_set: rule-set not found: ", routeExcludeAddressSet) return nil, E.New("parse route_exclude_address_set: rule-set not found: ", routeExcludeAddressSet)
} }
ruleSet.IncRef()
inbound.routeExcludeRuleSet = append(inbound.routeExcludeRuleSet, ruleSet) inbound.routeExcludeRuleSet = append(inbound.routeExcludeRuleSet, ruleSet)
} }
if options.AutoRedirect { if options.AutoRedirect {
@ -312,7 +310,7 @@ func (t *Inbound) Start(stage adapter.StartStage) error {
if len(ipSets) == 0 { if len(ipSets) == 0 {
t.logger.Warn("route_address_set: no destination IP CIDR rules found in rule-set: ", routeRuleSet.Name()) t.logger.Warn("route_address_set: no destination IP CIDR rules found in rule-set: ", routeRuleSet.Name())
} }
routeRuleSet.DecRef() routeRuleSet.IncRef()
t.routeAddressSet = append(t.routeAddressSet, ipSets...) t.routeAddressSet = append(t.routeAddressSet, ipSets...)
if t.autoRedirect != nil { if t.autoRedirect != nil {
t.routeRuleSetCallback = append(t.routeRuleSetCallback, routeRuleSet.RegisterCallback(t.updateRouteAddressSet)) t.routeRuleSetCallback = append(t.routeRuleSetCallback, routeRuleSet.RegisterCallback(t.updateRouteAddressSet))
@ -324,7 +322,7 @@ func (t *Inbound) Start(stage adapter.StartStage) error {
if len(ipSets) == 0 { if len(ipSets) == 0 {
t.logger.Warn("route_address_set: no destination IP CIDR rules found in rule-set: ", routeExcludeRuleSet.Name()) t.logger.Warn("route_address_set: no destination IP CIDR rules found in rule-set: ", routeExcludeRuleSet.Name())
} }
routeExcludeRuleSet.DecRef() routeExcludeRuleSet.IncRef()
t.routeExcludeAddressSet = append(t.routeExcludeAddressSet, ipSets...) t.routeExcludeAddressSet = append(t.routeExcludeAddressSet, ipSets...)
if t.autoRedirect != nil { if t.autoRedirect != nil {
t.routeExcludeRuleSetCallback = append(t.routeExcludeRuleSetCallback, routeExcludeRuleSet.RegisterCallback(t.updateRouteAddressSet)) t.routeExcludeRuleSetCallback = append(t.routeExcludeRuleSetCallback, routeExcludeRuleSet.RegisterCallback(t.updateRouteAddressSet))