v2ray-core/shell/point/config.go

90 lines
2.2 KiB
Go
Raw Normal View History

2015-12-06 16:41:41 +01:00
package point
2015-10-06 23:11:08 +02:00
2015-11-21 21:43:40 +01:00
import (
2016-08-20 20:55:45 +02:00
"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"
2015-11-21 21:43:40 +01:00
)
2016-06-04 00:38:22 +02:00
type InboundConnectionConfig struct {
2016-08-12 23:37:21 +02:00
Port v2net.Port
ListenOn v2net.Address
2016-10-02 23:43:58 +02:00
StreamSettings *internet.StreamConfig
2016-08-12 23:37:21 +02:00
Protocol string
Settings []byte
AllowPassiveConnection bool
2015-09-12 22:11:54 +02:00
}
2016-06-04 00:38:22 +02:00
type OutboundConnectionConfig struct {
2016-06-14 22:54:08 +02:00
Protocol string
SendThrough v2net.Address
2016-10-02 23:43:58 +02:00
StreamSettings *internet.StreamConfig
2016-06-14 22:54:08 +02:00
Settings []byte
2016-06-04 00:38:22 +02:00
}
2016-01-17 21:43:10 +01:00
type LogConfig struct {
AccessLog string
ErrorLog string
LogLevel log.LogLevel
2015-10-09 17:43:27 +02:00
}
2015-12-28 23:17:38 +01:00
const (
AllocationStrategyAlways = "always"
AllocationStrategyRandom = "random"
AllocationStrategyExternal = "external"
)
2016-01-17 21:43:10 +01:00
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.
2015-12-28 23:17:38 +01:00
}
2016-01-17 21:43:10 +01:00
type InboundDetourConfig struct {
2016-08-12 23:37:21 +02:00
Protocol string
PortRange v2net.PortRange
ListenOn v2net.Address
Tag string
Allocation *InboundDetourAllocationConfig
2016-10-02 23:43:58 +02:00
StreamSettings *internet.StreamConfig
2016-08-12 23:37:21 +02:00
Settings []byte
AllowPassiveConnection bool
2015-10-31 14:08:13 +01:00
}
2016-01-17 21:43:10 +01:00
type OutboundDetourConfig struct {
2016-06-14 22:54:08 +02:00
Protocol string
SendThrough v2net.Address
2016-10-02 23:43:58 +02:00
StreamSettings *internet.StreamConfig
2016-06-14 22:54:08 +02:00
Tag string
Settings []byte
2015-11-13 23:43:58 +01:00
}
2016-01-17 21:43:10 +01:00
type Config struct {
Port v2net.Port
LogConfig *LogConfig
RouterConfig *router.Config
2016-05-16 00:25:34 -07:00
DNSConfig *dns.Config
2016-06-04 00:38:22 +02:00
InboundConfig *InboundConnectionConfig
OutboundConfig *OutboundConnectionConfig
2016-01-17 21:43:10 +01:00
InboundDetours []*InboundDetourConfig
OutboundDetours []*OutboundDetourConfig
2016-06-02 01:49:25 +02:00
TransportConfig *transport.Config
2016-01-17 21:43:10 +01:00
}
type ConfigLoader func(init string) (*Config, error)
var (
configLoader ConfigLoader
)
func LoadConfig(init string) (*Config, error) {
if configLoader == nil {
2016-08-18 08:24:47 +02:00
return nil, common.ErrBadConfiguration
2016-01-17 21:43:10 +01:00
}
return configLoader(init)
2015-09-12 22:11:54 +02:00
}