config for on demand inbound detour

This commit is contained in:
v2ray committed 2015-12-28 23:17:38 +01:00
1 parent 96053d9e12
commit 71c70416f5
3 files changed
+55 -6

No files matched your search

+12
View File
@@ -23,10 +23,22 @@ type DnsConfig interface {
Settings() dns.CacheConfig Settings() dns.CacheConfig
} }
const (
AllocationStrategyAlways = "always"
AllocationStrategyRandom = "random"
AllocationStrategyExternal = "external"
)
type InboundDetourAllocationConfig interface {
Strategy() string
Concurrency() int
}
type InboundDetourConfig interface { type InboundDetourConfig interface {
Protocol() string Protocol() string
PortRange() v2net.PortRange PortRange() v2net.PortRange
Tag() string Tag() string
Allocation() InboundDetourAllocationConfig
Settings() interface{} Settings() interface{}
} }
+23 -4
View File
@@ -6,13 +6,32 @@ import (
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
v2netjson "github.com/v2ray/v2ray-core/common/net/json" v2netjson "github.com/v2ray/v2ray-core/common/net/json"
proxyconfig "github.com/v2ray/v2ray-core/proxy/common/config" proxyconfig "github.com/v2ray/v2ray-core/proxy/common/config"
"github.com/v2ray/v2ray-core/shell/point"
) )
type InboundDetourAllocationConfig struct {
StrategyValue string `json:"strategy"`
ConcurrencyValue int `json:"concurrency"`
}
func (this *InboundDetourAllocationConfig) Strategy() string {
return this.StrategyValue
}
func (this *InboundDetourAllocationConfig) Concurrency() int {
return this.ConcurrencyValue
}
type InboundDetourConfig struct { type InboundDetourConfig struct {
ProtocolValue string `json:"protocol"` ProtocolValue string `json:"protocol"`
PortRangeValue *v2netjson.PortRange `json:"port"` PortRangeValue *v2netjson.PortRange `json:"port"`
SettingsValue json.RawMessage `json:"settings"` SettingsValue json.RawMessage `json:"settings"`
TagValue string `json:"tag"` TagValue string `json:"tag"`
AllocationValue *InboundDetourAllocationConfig `json:"allocate"`
}
func (this *InboundDetourConfig) Allocation() point.InboundDetourAllocationConfig {
return this.AllocationValue
} }
func (this *InboundDetourConfig) Protocol() string { func (this *InboundDetourConfig) Protocol() string {
+20 -2
View File
@@ -52,10 +52,28 @@ func (this *PortRange) To() v2net.Port {
return this.ToValue return this.ToValue
} }
type InboundDetourAllocationConfig struct {
StrategyValue string
ConcurrencyValue int
}
func (this *InboundDetourAllocationConfig) Strategy() string {
return this.StrategyValue
}
func (this *InboundDetourAllocationConfig) Concurrency() int {
return this.ConcurrencyValue
}
type InboundDetourConfig struct { type InboundDetourConfig struct {
*ConnectionConfig *ConnectionConfig
PortRangeValue *PortRange PortRangeValue *PortRange
TagValue string TagValue string
AllocationStrategy *InboundDetourAllocationConfig
}
func (this *InboundDetourConfig) Allocation() point.InboundDetourAllocationConfig {
return this.AllocationStrategy
} }
func (this *InboundDetourConfig) Tag() string { func (this *InboundDetourConfig) Tag() string {