1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-07-01 03:25:23 +00:00
v2fly/shell/point/config.go

89 lines
2.2 KiB
Go
Raw Normal View History

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