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:
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
|
||||
}
|
||||
|
||||
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 (
|
||||
"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.
|
||||
|
Loading…
Reference in New Issue
Block a user