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": [],
"exclude_outbound_type": [],
"rename": {},
"remove_emoji": false
"remove_emoji": false,
"rewrite_multiplex": {}
}
],
"deduplication": false,
@ -77,6 +78,10 @@ Regexp rename rules, matching outbounds will be renamed.
Remove emojis in outbound tags.
#### process.rewrite_multiplex
Rewrite [Multiplex](https://sing-box.sagernet.org/configuration/shared/multiplex) options.
#### deduplication
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"`
Rename *badjson.TypedMap[string, string] `json:"rename,omitempty"`
RemoveEmoji bool `json:"remove_emoji,omitempty"`
RewriteMultiplex *option.OutboundMultiplexOptions `json:"rewrite_multiplex,omitempty"`
}
type Profile struct {

View File

@ -5,6 +5,7 @@ import (
"strings"
"github.com/sagernet/serenity/option"
C "github.com/sagernet/sing-box/constant"
boxOption "github.com/sagernet/sing-box/option"
"github.com/sagernet/sing/common"
E "github.com/sagernet/sing/common/exceptions"
@ -103,6 +104,18 @@ func (o *ProcessOptions) Process(outbounds []boxOption.Outbound) []boxOption.Out
if 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)
}
if len(renameResult) > 0 {