forked from v2ray/v2ray-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
85 lines (73 loc) · 2.09 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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"
)
type InboundConnectionConfig struct {
Port v2net.Port
ListenOn v2net.Address
StreamSettings *internet.StreamConfig
Protocol string
Settings []byte
AllowPassiveConnection bool
}
type OutboundConnectionConfig struct {
Protocol string
SendThrough v2net.Address
StreamSettings *internet.StreamConfig
Settings []byte
}
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.
}
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
}
type ConfigLoader func(input io.Reader) (*Config, error)
var (
configLoader ConfigLoader
)
func LoadConfig(input io.Reader) (*Config, error) {
if configLoader == nil {
return nil, common.ErrBadConfiguration
}
return configLoader(input)
}