1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-21 16:56:27 -05:00

isolate mux,proxy settings

This commit is contained in:
Shelikhoo 2021-09-04 13:19:43 +01:00
parent 436aaca6ab
commit 663e6028c3
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316
4 changed files with 55 additions and 45 deletions

View File

@ -0,0 +1,25 @@
package muxcfg
import "github.com/v2fly/v2ray-core/v4/app/proxyman"
type MuxConfig struct {
Enabled bool `json:"enabled"`
Concurrency int16 `json:"concurrency"`
}
// Build creates MultiplexingConfig, Concurrency < 0 completely disables mux.
func (m *MuxConfig) Build() *proxyman.MultiplexingConfig {
if m.Concurrency < 0 {
return nil
}
var con uint32 = 8
if m.Concurrency > 0 {
con = uint32(m.Concurrency)
}
return &proxyman.MultiplexingConfig{
Enabled: m.Enabled,
Concurrency: con,
}
}

View File

@ -0,0 +1,21 @@
package proxycfg
import "github.com/v2fly/v2ray-core/v4/transport/internet"
type ProxyConfig struct {
Tag string `json:"tag"`
TransportLayerProxy bool `json:"transportLayer"`
}
//go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen
// Build implements Buildable.
func (v *ProxyConfig) Build() (*internet.ProxyConfig, error) {
if v.Tag == "" {
return nil, newError("Proxy tag is not set.")
}
return &internet.ProxyConfig{
Tag: v.Tag,
TransportLayerProxy: v.TransportLayerProxy,
}, nil
}

View File

@ -406,19 +406,3 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) {
}
return config, nil
}
type ProxyConfig struct {
Tag string `json:"tag"`
TransportLayerProxy bool `json:"transportLayer"`
}
// Build implements Buildable.
func (v *ProxyConfig) Build() (*internet.ProxyConfig, error) {
if v.Tag == "" {
return nil, newError("Proxy tag is not set.")
}
return &internet.ProxyConfig{
Tag: v.Tag,
TransportLayerProxy: v.TransportLayerProxy,
}, nil
}

View File

@ -3,6 +3,8 @@ package v4
import (
"encoding/json"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/loader"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/muxcfg"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/proxycfg"
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/sniffer"
"github.com/v2fly/v2ray-core/v4/infra/conf/synthetic/dns"
"github.com/v2fly/v2ray-core/v4/infra/conf/synthetic/log"
@ -58,28 +60,6 @@ func toProtocolList(s []string) ([]proxyman.KnownProtocols, error) {
return kp, nil
}
type MuxConfig struct {
Enabled bool `json:"enabled"`
Concurrency int16 `json:"concurrency"`
}
// Build creates MultiplexingConfig, Concurrency < 0 completely disables mux.
func (m *MuxConfig) Build() *proxyman.MultiplexingConfig {
if m.Concurrency < 0 {
return nil
}
var con uint32 = 8
if m.Concurrency > 0 {
con = uint32(m.Concurrency)
}
return &proxyman.MultiplexingConfig{
Enabled: m.Enabled,
Concurrency: con,
}
}
type InboundDetourAllocationConfig struct {
Strategy string `json:"strategy"`
Concurrency *uint32 `json:"concurrency"`
@ -221,13 +201,13 @@ func (c *InboundDetourConfig) Build() (*core.InboundHandlerConfig, error) {
}
type OutboundDetourConfig struct {
Protocol string `json:"protocol"`
SendThrough *cfgcommon.Address `json:"sendThrough"`
Tag string `json:"tag"`
Settings *json.RawMessage `json:"settings"`
StreamSetting *StreamConfig `json:"streamSettings"`
ProxySettings *ProxyConfig `json:"proxySettings"`
MuxSettings *MuxConfig `json:"mux"`
Protocol string `json:"protocol"`
SendThrough *cfgcommon.Address `json:"sendThrough"`
Tag string `json:"tag"`
Settings *json.RawMessage `json:"settings"`
StreamSetting *StreamConfig `json:"streamSettings"`
ProxySettings *proxycfg.ProxyConfig `json:"proxySettings"`
MuxSettings *muxcfg.MuxConfig `json:"mux"`
}
// Build implements Buildable.