forked from mirror/serenity
Rewrite subscription.process
This commit is contained in:
parent
cf6908fdf8
commit
56920ed988
@ -11,6 +11,8 @@
|
|||||||
"exclude": [],
|
"exclude": [],
|
||||||
"filter_type": [],
|
"filter_type": [],
|
||||||
"exclude_type": [],
|
"exclude_type": [],
|
||||||
|
"invert": false,
|
||||||
|
"remove": false,
|
||||||
"rename": {},
|
"rename": {},
|
||||||
"remove_emoji": false,
|
"remove_emoji": false,
|
||||||
"rewrite_multiplex": {}
|
"rewrite_multiplex": {}
|
||||||
@ -56,19 +58,27 @@ Process rules.
|
|||||||
|
|
||||||
#### process.filter
|
#### process.filter
|
||||||
|
|
||||||
Regexp filter rules, non-matching outbounds will be removed.
|
Regexp filter rules, match outbound tag name.
|
||||||
|
|
||||||
#### process.exclude
|
#### process.exclude
|
||||||
|
|
||||||
Regexp exclude rules, matching outbounds will be removed.
|
Regexp exclude rules, match outbound tag name.
|
||||||
|
|
||||||
#### process.filter_type
|
#### process.filter_type
|
||||||
|
|
||||||
Outbound type filter rules, non-matching outbounds will be removed.
|
Filter rules, match outbound type.
|
||||||
|
|
||||||
#### process.exclude_type
|
#### process.exclude_type
|
||||||
|
|
||||||
Outbound type exclude rules, matching outbounds will be removed.
|
Exclude rules, match outbound type.
|
||||||
|
|
||||||
|
#### process.invert
|
||||||
|
|
||||||
|
Invert filter results.
|
||||||
|
|
||||||
|
#### process.remove
|
||||||
|
|
||||||
|
Remove outbounds that match the rules.
|
||||||
|
|
||||||
#### process.rename
|
#### process.rename
|
||||||
|
|
||||||
|
@ -66,6 +66,8 @@ type OutboundProcessOptions struct {
|
|||||||
Exclude option.Listable[string] `json:"exclude,omitempty"`
|
Exclude option.Listable[string] `json:"exclude,omitempty"`
|
||||||
FilterType option.Listable[string] `json:"filter_type,omitempty"`
|
FilterType option.Listable[string] `json:"filter_type,omitempty"`
|
||||||
ExcludeType option.Listable[string] `json:"exclude_type,omitempty"`
|
ExcludeType option.Listable[string] `json:"exclude_type,omitempty"`
|
||||||
|
Invert bool `json:"invert,omitempty"`
|
||||||
|
Remove bool `json:"remove,omitempty"`
|
||||||
Rename *badjson.TypedMap[string, string] `json:"rename,omitempty"`
|
Rename *badjson.TypedMap[string, string] `json:"rename,omitempty"`
|
||||||
RemoveEmoji bool `json:"remove_emoji,omitempty"`
|
RemoveEmoji bool `json:"remove_emoji,omitempty"`
|
||||||
RewriteMultiplex *option.OutboundMultiplexOptions `json:"rewrite_multiplex,omitempty"`
|
RewriteMultiplex *option.OutboundMultiplexOptions `json:"rewrite_multiplex,omitempty"`
|
||||||
|
@ -67,29 +67,44 @@ func (o *ProcessOptions) Process(outbounds []boxOption.Outbound) []boxOption.Out
|
|||||||
newOutbounds := make([]boxOption.Outbound, 0, len(outbounds))
|
newOutbounds := make([]boxOption.Outbound, 0, len(outbounds))
|
||||||
renameResult := make(map[string]string)
|
renameResult := make(map[string]string)
|
||||||
for _, outbound := range outbounds {
|
for _, outbound := range outbounds {
|
||||||
if len(o.filter) > 0 {
|
var inProcess bool
|
||||||
if !common.Any(o.filter, func(it *regexp.Regexp) bool {
|
if len(o.filter) == 0 && len(o.FilterType) == 0 && len(o.exclude) == 0 && len(o.ExcludeType) == 0 {
|
||||||
return it.MatchString(outbound.Tag)
|
inProcess = true
|
||||||
}) {
|
} else {
|
||||||
continue
|
if len(o.filter) > 0 {
|
||||||
|
if !common.Any(o.filter, func(it *regexp.Regexp) bool {
|
||||||
|
return it.MatchString(outbound.Tag)
|
||||||
|
}) {
|
||||||
|
inProcess = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !inProcess && len(o.FilterType) > 0 {
|
||||||
|
if !common.Contains(o.FilterType, outbound.Type) {
|
||||||
|
inProcess = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !inProcess && len(o.exclude) > 0 {
|
||||||
|
if common.Any(o.exclude, func(it *regexp.Regexp) bool {
|
||||||
|
return it.MatchString(outbound.Tag)
|
||||||
|
}) {
|
||||||
|
inProcess = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !inProcess && len(o.ExcludeType) > 0 {
|
||||||
|
if common.Contains(o.ExcludeType, outbound.Type) {
|
||||||
|
inProcess = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(o.FilterType) > 0 {
|
if o.Invert {
|
||||||
if !common.Contains(o.FilterType, outbound.Type) {
|
inProcess = !inProcess
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if len(o.exclude) > 0 {
|
if !inProcess {
|
||||||
if common.Any(o.exclude, func(it *regexp.Regexp) bool {
|
newOutbounds = append(newOutbounds, outbound)
|
||||||
return it.MatchString(outbound.Tag)
|
continue
|
||||||
}) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if len(o.ExcludeType) > 0 {
|
if o.Remove {
|
||||||
if common.Contains(o.ExcludeType, outbound.Type) {
|
continue
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
originTag := outbound.Tag
|
originTag := outbound.Tag
|
||||||
if len(o.rename) > 0 {
|
if len(o.rename) > 0 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user