1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-29 23:36:25 -04:00
v2fly/shell/point/config.go

86 lines
2.1 KiB
Go
Raw Normal View History

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