diff --git a/adapter/outbound/mieru.go b/adapter/outbound/mieru.go index 0d32ca412..7aab2f58d 100644 --- a/adapter/outbound/mieru.go +++ b/adapter/outbound/mieru.go @@ -8,12 +8,13 @@ import ( "strconv" "sync" - mieruclient "github.com/enfein/mieru/v3/apis/client" - mierumodel "github.com/enfein/mieru/v3/apis/model" - mierupb "github.com/enfein/mieru/v3/pkg/appctl/appctlpb" "github.com/metacubex/mihomo/component/dialer" "github.com/metacubex/mihomo/component/proxydialer" C "github.com/metacubex/mihomo/constant" + + mieruclient "github.com/enfein/mieru/v3/apis/client" + mierumodel "github.com/enfein/mieru/v3/apis/model" + mierupb "github.com/enfein/mieru/v3/pkg/appctl/appctlpb" "google.golang.org/protobuf/proto" ) @@ -26,13 +27,14 @@ type Mieru struct { type MieruOption struct { BasicOption - Name string `proxy:"name"` - Server string `proxy:"server"` - Port int `proxy:"port,omitempty"` - PortRange string `proxy:"port-range,omitempty"` - Transport string `proxy:"transport"` - UserName string `proxy:"username"` - Password string `proxy:"password"` + Name string `proxy:"name"` + Server string `proxy:"server"` + Port int `proxy:"port,omitempty"` + PortRange string `proxy:"port-range,omitempty"` + Transport string `proxy:"transport"` + UserName string `proxy:"username"` + Password string `proxy:"password"` + Multiplexing string `proxy:"multiplexing,omitempty"` } // DialContext implements C.ProxyAdapter @@ -205,7 +207,7 @@ func buildMieruClientConfig(option MieruOption) (*mieruclient.ClientConfig, erro } } } - return &mieruclient.ClientConfig{ + config := &mieruclient.ClientConfig{ Profile: &mierupb.ClientProfile{ ProfileName: proto.String(option.Name), User: &mierupb.User{ @@ -214,7 +216,13 @@ func buildMieruClientConfig(option MieruOption) (*mieruclient.ClientConfig, erro }, Servers: []*mierupb.ServerEndpoint{server}, }, - }, nil + } + if multiplexing, ok := mierupb.MultiplexingLevel_value[option.Multiplexing]; ok { + config.Profile.Multiplexing = &mierupb.MultiplexingConfig{ + Level: mierupb.MultiplexingLevel(multiplexing).Enum(), + } + } + return config, nil } func validateMieruOption(option MieruOption) error { @@ -258,6 +266,11 @@ func validateMieruOption(option MieruOption) error { if option.Password == "" { return fmt.Errorf("password is empty") } + if option.Multiplexing != "" { + if _, ok := mierupb.MultiplexingLevel_value[option.Multiplexing]; !ok { + return fmt.Errorf("invalid multiplexing level: %s", option.Multiplexing) + } + } return nil } diff --git a/docs/config.yaml b/docs/config.yaml index 23acb78fd..fda14820b 100644 --- a/docs/config.yaml +++ b/docs/config.yaml @@ -855,6 +855,8 @@ proxies: # socks5 transport: TCP # 只支持 TCP username: user password: password + # 可以使用的值包括 MULTIPLEXING_OFF, MULTIPLEXING_LOW, MULTIPLEXING_MIDDLE, MULTIPLEXING_HIGH。其中 MULTIPLEXING_OFF 会关闭多路复用功能。默认值为 MULTIPLEXING_LOW。 + # multiplexing: MULTIPLEXING_LOW # dns 出站会将请求劫持到内部 dns 模块,所有请求均在内部处理 - name: "dns-out"