1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-02-20 23:47:21 -05:00
v2fly/shell/point/config.go

68 lines
1.4 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 (
2015-12-07 22:47:47 +01:00
"github.com/v2ray/v2ray-core/app/router"
2015-12-05 21:10:14 +01:00
"github.com/v2ray/v2ray-core/common/log"
2015-11-21 21:43:40 +01:00
v2net "github.com/v2ray/v2ray-core/common/net"
)
2016-01-17 21:43:10 +01:00
type ConnectionConfig struct {
Protocol string
Settings []byte
2015-09-12 22:11:54 +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 {
Protocol string
PortRange v2net.PortRange
Tag string
Allocation *InboundDetourAllocationConfig
Settings []byte
2015-10-31 14:08:13 +01:00
}
2016-01-17 21:43:10 +01:00
type OutboundDetourConfig struct {
Protocol string
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
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 {
return nil, ErrorBadConfiguration
2016-01-17 21:43:10 +01:00
}
return configLoader(init)
2015-09-12 22:11:54 +02:00
}