2015-12-06 10:41:41 -05:00
|
|
|
package point
|
2015-10-06 17:11:08 -04:00
|
|
|
|
2015-11-21 15:43:40 -05:00
|
|
|
import (
|
2016-05-16 03:25:34 -04:00
|
|
|
"github.com/v2ray/v2ray-core/app/dns"
|
2015-12-07 16:47:47 -05:00
|
|
|
"github.com/v2ray/v2ray-core/app/router"
|
2015-12-05 15:10:14 -05:00
|
|
|
"github.com/v2ray/v2ray-core/common/log"
|
2015-11-21 15:43:40 -05:00
|
|
|
v2net "github.com/v2ray/v2ray-core/common/net"
|
|
|
|
)
|
|
|
|
|
2016-01-17 15:43:10 -05:00
|
|
|
type ConnectionConfig struct {
|
|
|
|
Protocol string
|
|
|
|
Settings []byte
|
2015-09-12 16:11:54 -04:00
|
|
|
}
|
|
|
|
|
2016-01-17 15:43:10 -05:00
|
|
|
type LogConfig struct {
|
|
|
|
AccessLog string
|
|
|
|
ErrorLog string
|
|
|
|
LogLevel log.LogLevel
|
2015-10-09 11:43:27 -04:00
|
|
|
}
|
|
|
|
|
2015-12-28 17:17:38 -05:00
|
|
|
const (
|
|
|
|
AllocationStrategyAlways = "always"
|
|
|
|
AllocationStrategyRandom = "random"
|
|
|
|
AllocationStrategyExternal = "external"
|
|
|
|
)
|
|
|
|
|
2016-01-17 15:43:10 -05:00
|
|
|
type InboundDetourAllocationConfig struct {
|
|
|
|
Strategy string // Allocation strategy of this inbound detour.
|
|
|
|
Concurrency int // Number of handlers (ports) running in parallel.
|
2016-01-20 19:40:52 -05:00
|
|
|
Refresh int // Number of minutes before a handler is regenerated.
|
2015-12-28 17:17:38 -05:00
|
|
|
}
|
|
|
|
|
2016-01-17 15:43:10 -05:00
|
|
|
type InboundDetourConfig struct {
|
|
|
|
Protocol string
|
|
|
|
PortRange v2net.PortRange
|
2016-05-29 10:37:52 -04:00
|
|
|
ListenOn v2net.Address
|
2016-01-17 15:43:10 -05:00
|
|
|
Tag string
|
|
|
|
Allocation *InboundDetourAllocationConfig
|
|
|
|
Settings []byte
|
2015-10-31 09:08:13 -04:00
|
|
|
}
|
|
|
|
|
2016-01-17 15:43:10 -05:00
|
|
|
type OutboundDetourConfig struct {
|
|
|
|
Protocol string
|
|
|
|
Tag string
|
|
|
|
Settings []byte
|
2015-11-13 17:43:58 -05:00
|
|
|
}
|
|
|
|
|
2016-01-17 15:43:10 -05:00
|
|
|
type Config struct {
|
|
|
|
Port v2net.Port
|
2016-05-29 10:37:52 -04:00
|
|
|
ListenOn v2net.Address
|
2016-01-17 15:43:10 -05:00
|
|
|
LogConfig *LogConfig
|
|
|
|
RouterConfig *router.Config
|
2016-05-16 03:25:34 -04:00
|
|
|
DNSConfig *dns.Config
|
2016-01-17 15:43:10 -05:00
|
|
|
InboundConfig *ConnectionConfig
|
|
|
|
OutboundConfig *ConnectionConfig
|
|
|
|
InboundDetours []*InboundDetourConfig
|
|
|
|
OutboundDetours []*OutboundDetourConfig
|
|
|
|
}
|
|
|
|
|
|
|
|
type ConfigLoader func(init string) (*Config, error)
|
|
|
|
|
|
|
|
var (
|
|
|
|
configLoader ConfigLoader
|
|
|
|
)
|
|
|
|
|
|
|
|
func LoadConfig(init string) (*Config, error) {
|
|
|
|
if configLoader == nil {
|
2016-01-30 06:12:57 -05:00
|
|
|
return nil, ErrorBadConfiguration
|
2016-01-17 15:43:10 -05:00
|
|
|
}
|
|
|
|
return configLoader(init)
|
2015-09-12 16:11:54 -04:00
|
|
|
}
|