mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-04-22 02:42:49 -04:00
isolate mux,proxy settings
This commit is contained in:
parent
436aaca6ab
commit
663e6028c3
25
infra/conf/cfgcommon/muxcfg/mux.go
Normal file
25
infra/conf/cfgcommon/muxcfg/mux.go
Normal 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,
|
||||||
|
}
|
||||||
|
}
|
21
infra/conf/cfgcommon/proxycfg/proxy.go
Normal file
21
infra/conf/cfgcommon/proxycfg/proxy.go
Normal 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
|
||||||
|
}
|
@ -406,19 +406,3 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) {
|
|||||||
}
|
}
|
||||||
return config, nil
|
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
|
|
||||||
}
|
|
||||||
|
@ -3,6 +3,8 @@ package v4
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon/loader"
|
"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/cfgcommon/sniffer"
|
||||||
"github.com/v2fly/v2ray-core/v4/infra/conf/synthetic/dns"
|
"github.com/v2fly/v2ray-core/v4/infra/conf/synthetic/dns"
|
||||||
"github.com/v2fly/v2ray-core/v4/infra/conf/synthetic/log"
|
"github.com/v2fly/v2ray-core/v4/infra/conf/synthetic/log"
|
||||||
@ -58,28 +60,6 @@ func toProtocolList(s []string) ([]proxyman.KnownProtocols, error) {
|
|||||||
return kp, nil
|
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 {
|
type InboundDetourAllocationConfig struct {
|
||||||
Strategy string `json:"strategy"`
|
Strategy string `json:"strategy"`
|
||||||
Concurrency *uint32 `json:"concurrency"`
|
Concurrency *uint32 `json:"concurrency"`
|
||||||
@ -221,13 +201,13 @@ func (c *InboundDetourConfig) Build() (*core.InboundHandlerConfig, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type OutboundDetourConfig struct {
|
type OutboundDetourConfig struct {
|
||||||
Protocol string `json:"protocol"`
|
Protocol string `json:"protocol"`
|
||||||
SendThrough *cfgcommon.Address `json:"sendThrough"`
|
SendThrough *cfgcommon.Address `json:"sendThrough"`
|
||||||
Tag string `json:"tag"`
|
Tag string `json:"tag"`
|
||||||
Settings *json.RawMessage `json:"settings"`
|
Settings *json.RawMessage `json:"settings"`
|
||||||
StreamSetting *StreamConfig `json:"streamSettings"`
|
StreamSetting *StreamConfig `json:"streamSettings"`
|
||||||
ProxySettings *ProxyConfig `json:"proxySettings"`
|
ProxySettings *proxycfg.ProxyConfig `json:"proxySettings"`
|
||||||
MuxSettings *MuxConfig `json:"mux"`
|
MuxSettings *muxcfg.MuxConfig `json:"mux"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build implements Buildable.
|
// Build implements Buildable.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user