Add multiplexer

This commit is contained in:
世界
2022-07-30 00:29:22 +08:00
parent 8e8b1b974e
commit 10531c9f9a
47 changed files with 1244 additions and 174 deletions

View File

@@ -98,3 +98,10 @@ type ServerOptions struct {
func (o ServerOptions) Build() M.Socksaddr {
return M.ParseSocksaddrHostPort(o.Server, o.ServerPort)
}
type MultiplexOptions struct {
Enabled bool `json:"enabled,omitempty"`
MaxConnections int `json:"max_connections,omitempty"`
MinStreams int `json:"min_streams,omitempty"`
MaxStreams int `json:"max_streams,omitempty"`
}

View File

@@ -24,7 +24,8 @@ type ShadowsocksDestination struct {
type ShadowsocksOutboundOptions struct {
OutboundDialerOptions
ServerOptions
Method string `json:"method"`
Password string `json:"password"`
Network NetworkList `json:"network,omitempty"`
Method string `json:"method"`
Password string `json:"password"`
Network NetworkList `json:"network,omitempty"`
Multiplex *MultiplexOptions `json:"multiplex,omitempty"`
}

View File

@@ -6,9 +6,9 @@ import (
"time"
"github.com/sagernet/sing-box/common/json"
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-dns"
E "github.com/sagernet/sing/common/exceptions"
N "github.com/sagernet/sing/common/network"
)
type ListenAddress netip.Addr
@@ -50,7 +50,7 @@ func (v *NetworkList) UnmarshalJSON(content []byte) error {
}
for _, networkName := range networkList {
switch networkName {
case C.NetworkTCP, C.NetworkUDP:
case N.NetworkTCP, N.NetworkUDP:
break
default:
return E.New("unknown network: " + networkName)
@@ -62,7 +62,7 @@ func (v *NetworkList) UnmarshalJSON(content []byte) error {
func (v NetworkList) Build() []string {
if v == "" {
return []string{C.NetworkTCP, C.NetworkUDP}
return []string{N.NetworkTCP, N.NetworkUDP}
}
return strings.Split(string(v), "\n")
}