mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-04-21 13:09:11 -04:00
protobuf for v2ray config
This commit is contained in:
75
config.go
75
config.go
@@ -3,72 +3,33 @@ package core
|
||||
import (
|
||||
"io"
|
||||
|
||||
"v2ray.com/core/app/dns"
|
||||
"v2ray.com/core/app/router"
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/log"
|
||||
v2net "v2ray.com/core/common/net"
|
||||
"v2ray.com/core/transport"
|
||||
"v2ray.com/core/transport/internet"
|
||||
"v2ray.com/core/proxy/registry"
|
||||
)
|
||||
|
||||
type InboundConnectionConfig struct {
|
||||
Port v2net.Port
|
||||
ListenOn v2net.Address
|
||||
StreamSettings *internet.StreamConfig
|
||||
Protocol string
|
||||
Settings []byte
|
||||
AllowPassiveConnection bool
|
||||
func (this *AllocationStrategyConcurrency) GetValue() uint32 {
|
||||
if this == nil {
|
||||
return 3
|
||||
}
|
||||
return this.Value
|
||||
}
|
||||
|
||||
type OutboundConnectionConfig struct {
|
||||
Protocol string
|
||||
SendThrough v2net.Address
|
||||
StreamSettings *internet.StreamConfig
|
||||
Settings []byte
|
||||
func (this *AllocationStrategyRefresh) GetValue() uint32 {
|
||||
if this == nil {
|
||||
return 5
|
||||
}
|
||||
return this.Value
|
||||
}
|
||||
|
||||
const (
|
||||
AllocationStrategyAlways = "always"
|
||||
AllocationStrategyRandom = "random"
|
||||
AllocationStrategyExternal = "external"
|
||||
)
|
||||
|
||||
type InboundDetourAllocationConfig struct {
|
||||
Strategy string // Allocation strategy of this inbound detour.
|
||||
Concurrency int // Number of handlers (ports) running in parallel.
|
||||
Refresh int // Number of minutes before a handler is regenerated.
|
||||
func (this *InboundConnectionConfig) GetAllocationStrategyValue() *AllocationStrategy {
|
||||
if this.AllocationStrategy == nil {
|
||||
return &AllocationStrategy{}
|
||||
}
|
||||
return this.AllocationStrategy
|
||||
}
|
||||
|
||||
type InboundDetourConfig struct {
|
||||
Protocol string
|
||||
PortRange v2net.PortRange
|
||||
ListenOn v2net.Address
|
||||
Tag string
|
||||
Allocation *InboundDetourAllocationConfig
|
||||
StreamSettings *internet.StreamConfig
|
||||
Settings []byte
|
||||
AllowPassiveConnection bool
|
||||
}
|
||||
|
||||
type OutboundDetourConfig struct {
|
||||
Protocol string
|
||||
SendThrough v2net.Address
|
||||
StreamSettings *internet.StreamConfig
|
||||
Tag string
|
||||
Settings []byte
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Port v2net.Port
|
||||
LogConfig *log.Config
|
||||
RouterConfig *router.Config
|
||||
DNSConfig *dns.Config
|
||||
InboundConfig *InboundConnectionConfig
|
||||
OutboundConfig *OutboundConnectionConfig
|
||||
InboundDetours []*InboundDetourConfig
|
||||
OutboundDetours []*OutboundDetourConfig
|
||||
TransportConfig *transport.Config
|
||||
func (this *InboundConnectionConfig) GetTypedSettings() (interface{}, error) {
|
||||
return registry.MarshalInboundConfig(this.Protocol, this.Settings)
|
||||
}
|
||||
|
||||
type ConfigLoader func(input io.Reader) (*Config, error)
|
||||
|
||||
Reference in New Issue
Block a user