2016-10-12 14:46:02 +00:00
|
|
|
package core
|
2015-10-06 21:11:08 +00:00
|
|
|
|
2015-11-21 20:43:40 +00:00
|
|
|
import (
|
2016-10-03 09:18:24 +00:00
|
|
|
"io"
|
|
|
|
|
2016-08-20 18:55:45 +00:00
|
|
|
"v2ray.com/core/common"
|
2016-10-14 20:21:45 +00:00
|
|
|
"v2ray.com/core/proxy/registry"
|
2015-11-21 20:43:40 +00:00
|
|
|
)
|
|
|
|
|
2016-10-14 20:21:45 +00:00
|
|
|
func (this *AllocationStrategyConcurrency) GetValue() uint32 {
|
|
|
|
if this == nil {
|
|
|
|
return 3
|
|
|
|
}
|
|
|
|
return this.Value
|
2015-12-28 22:17:38 +00:00
|
|
|
}
|
|
|
|
|
2016-10-14 20:21:45 +00:00
|
|
|
func (this *AllocationStrategyRefresh) GetValue() uint32 {
|
|
|
|
if this == nil {
|
|
|
|
return 5
|
|
|
|
}
|
|
|
|
return this.Value
|
2015-10-31 13:08:13 +00:00
|
|
|
}
|
|
|
|
|
2016-10-14 20:21:45 +00:00
|
|
|
func (this *InboundConnectionConfig) GetAllocationStrategyValue() *AllocationStrategy {
|
|
|
|
if this.AllocationStrategy == nil {
|
|
|
|
return &AllocationStrategy{}
|
|
|
|
}
|
|
|
|
return this.AllocationStrategy
|
2015-11-13 22:43:58 +00:00
|
|
|
}
|
|
|
|
|
2016-10-14 20:21:45 +00:00
|
|
|
func (this *InboundConnectionConfig) GetTypedSettings() (interface{}, error) {
|
|
|
|
return registry.MarshalInboundConfig(this.Protocol, this.Settings)
|
2016-01-17 20:43:10 +00:00
|
|
|
}
|
|
|
|
|
2016-10-03 09:18:24 +00:00
|
|
|
type ConfigLoader func(input io.Reader) (*Config, error)
|
2016-01-17 20:43:10 +00:00
|
|
|
|
|
|
|
var (
|
|
|
|
configLoader ConfigLoader
|
|
|
|
)
|
|
|
|
|
2016-10-03 09:18:24 +00:00
|
|
|
func LoadConfig(input io.Reader) (*Config, error) {
|
2016-01-17 20:43:10 +00:00
|
|
|
if configLoader == nil {
|
2016-08-18 06:24:47 +00:00
|
|
|
return nil, common.ErrBadConfiguration
|
2016-01-17 20:43:10 +00:00
|
|
|
}
|
2016-10-03 09:18:24 +00:00
|
|
|
return configLoader(input)
|
2015-09-12 20:11:54 +00:00
|
|
|
}
|