Add subscription.process.rewrite_multiplex

This commit is contained in:
世界 2024-04-22 21:07:39 +08:00
parent 5a3996dad9
commit 7dffc3de5f
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
3 changed files with 20 additions and 1 deletions

View File

@ -12,7 +12,8 @@
"filter_outbound_type": [], "filter_outbound_type": [],
"exclude_outbound_type": [], "exclude_outbound_type": [],
"rename": {}, "rename": {},
"remove_emoji": false "remove_emoji": false,
"rewrite_multiplex": {}
} }
], ],
"deduplication": false, "deduplication": false,
@ -77,6 +78,10 @@ Regexp rename rules, matching outbounds will be renamed.
Remove emojis in outbound tags. Remove emojis in outbound tags.
#### process.rewrite_multiplex
Rewrite [Multiplex](https://sing-box.sagernet.org/configuration/shared/multiplex) options.
#### deduplication #### deduplication
Remove outbounds with duplicate server destinations (Domain will be resolved to compare). Remove outbounds with duplicate server destinations (Domain will be resolved to compare).

View File

@ -68,6 +68,7 @@ type OutboundProcessOptions struct {
ExcludeOutboundType option.Listable[string] `json:"exclude_outbound_type,omitempty"` ExcludeOutboundType option.Listable[string] `json:"exclude_outbound_type,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"`
} }
type Profile struct { type Profile struct {

View File

@ -5,6 +5,7 @@ import (
"strings" "strings"
"github.com/sagernet/serenity/option" "github.com/sagernet/serenity/option"
C "github.com/sagernet/sing-box/constant"
boxOption "github.com/sagernet/sing-box/option" boxOption "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common" "github.com/sagernet/sing/common"
E "github.com/sagernet/sing/common/exceptions" E "github.com/sagernet/sing/common/exceptions"
@ -103,6 +104,18 @@ func (o *ProcessOptions) Process(outbounds []boxOption.Outbound) []boxOption.Out
if originTag != outbound.Tag { if originTag != outbound.Tag {
renameResult[originTag] = outbound.Tag renameResult[originTag] = outbound.Tag
} }
if o.RewriteMultiplex != nil {
switch outbound.Type {
case C.TypeShadowsocks:
outbound.ShadowsocksOptions.Multiplex = o.RewriteMultiplex
case C.TypeTrojan:
outbound.TrojanOptions.Multiplex = o.RewriteMultiplex
case C.TypeVMess:
outbound.VMessOptions.Multiplex = o.RewriteMultiplex
case C.TypeVLESS:
outbound.VLESSOptions.Multiplex = o.RewriteMultiplex
}
}
newOutbounds = append(newOutbounds, outbound) newOutbounds = append(newOutbounds, outbound)
} }
if len(renameResult) > 0 { if len(renameResult) > 0 {