Fix rules

This commit is contained in:
世界 2024-06-06 22:57:02 +08:00
parent 3d81f1ad61
commit 3d4147f776
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4

View File

@ -44,34 +44,6 @@ func (t *Template) renderRoute(metadata M.Metadata, options *option.Options) err
},
},
}
if !t.DisableTrafficBypass && !t.DisableDefaultRules {
blockTag := t.BlockTag
if blockTag == "" {
blockTag = DefaultBlockTag
}
options.Route.Rules = append(options.Route.Rules, option.Rule{
Type: C.RuleTypeLogical,
LogicalOptions: option.LogicalRule{
Mode: C.LogicalTypeOr,
Rules: []option.Rule{
{
Type: C.RuleTypeDefault,
DefaultOptions: option.DefaultRule{
Network: []string{N.NetworkUDP},
Port: []uint16{443},
},
},
{
Type: C.RuleTypeDefault,
DefaultOptions: option.DefaultRule{
Protocol: []string{C.ProtocolSTUN},
},
},
},
Outbound: blockTag,
},
})
}
directTag := t.DirectTag
defaultTag := t.DefaultTag
if directTag == "" {
@ -145,5 +117,27 @@ func (t *Template) renderRoute(metadata M.Metadata, options *option.Options) err
} else {
options.Route.Rules = append(options.Route.Rules, t.CustomRules...)
}
if !t.DisableTrafficBypass && !t.DisableDefaultRules {
blockTag := t.BlockTag
if blockTag == "" {
blockTag = DefaultBlockTag
}
options.Route.Rules = append(options.Route.Rules, option.Rule{
Type: C.RuleTypeLogical,
LogicalOptions: option.LogicalRule{
Mode: C.LogicalTypeOr,
Rules: []option.Rule{
{
Type: C.RuleTypeDefault,
DefaultOptions: option.DefaultRule{
Network: []string{N.NetworkUDP},
Port: []uint16{443},
},
},
},
Outbound: blockTag,
},
})
}
return nil
}