Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sing mux config support #30

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions conf/sing.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type SingOptions struct {
DomainStrategy option.DomainStrategy `json:"DomainStrategy"`
SniffOverrideDestination bool `json:"SniffOverrideDestination"`
FallBackConfigs *FallBackConfigForSing `json:"FallBackConfigs"`
Multiplex *MultiplexConfig `json:"MultiplexConfig"`
}

type SingNtpConfig struct {
Expand All @@ -59,6 +60,18 @@ type FallBack struct {
ServerPort string `json:"ServerPort"`
}

type MultiplexConfig struct {
Enabled bool `json:"Enable"`
Padding bool `json:"Padding"`
Brutal BrutalOptions `json:"Brutal"`
}

type BrutalOptions struct {
Enabled bool `json:"Enable"`
UpMbps int `json:"UpMbps"`
DownMbps int `json:"DownMbps"`
}

func NewSingOptions() *SingOptions {
return &SingOptions{
EnableDNS: false,
Expand All @@ -67,5 +80,6 @@ func NewSingOptions() *SingOptions {
SniffEnabled: true,
SniffOverrideDestination: true,
FallBackConfigs: &FallBackConfigForSing{},
Multiplex: &MultiplexConfig{},
}
}
17 changes: 17 additions & 0 deletions core/sing/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio
DomainStrategy: domainStrategy,
},
}
var multiplex *option.InboundMultiplexOptions
if c.SingOptions.Multiplex != nil {
multiplexOption := option.InboundMultiplexOptions{
Enabled: c.SingOptions.Multiplex.Enabled,
Padding: c.SingOptions.Multiplex.Padding,
Brutal: &option.BrutalOptions{
Enabled: c.SingOptions.Multiplex.Brutal.Enabled,
UpMbps: c.SingOptions.Multiplex.Brutal.UpMbps,
DownMbps: c.SingOptions.Multiplex.Brutal.DownMbps,
},
}
multiplex = &multiplexOption
}
var tls option.InboundTLSOptions
switch info.Security {
case panel.Tls:
Expand Down Expand Up @@ -210,6 +223,7 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio
TLS: &tls,
},
Transport: &t,
Multiplex: multiplex,
}
} else {
in.Type = "vmess"
Expand All @@ -219,6 +233,7 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio
TLS: &tls,
},
Transport: &t,
Multiplex: multiplex,
}
}
case "shadowsocks":
Expand All @@ -236,6 +251,7 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio
in.ShadowsocksOptions = option.ShadowsocksInboundOptions{
ListenOptions: listen,
Method: n.Cipher,
Multiplex: multiplex,
}
p := make([]byte, keyLength)
_, _ = rand.Read(p)
Expand Down Expand Up @@ -308,6 +324,7 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio
TLS: &tls,
},
Transport: &t,
Multiplex: multiplex,
}
if c.SingOptions.FallBackConfigs != nil {
// fallback handling
Expand Down
Loading