2016-10-12 16:46:02 +02:00
|
|
|
package core
|
2015-10-06 23:11:08 +02:00
|
|
|
|
2015-11-21 21:43:40 +01:00
|
|
|
import (
|
2016-10-16 00:46:08 +02:00
|
|
|
"v2ray.com/core/common"
|
2017-01-14 00:27:45 +01:00
|
|
|
"v2ray.com/core/common/net"
|
2015-11-21 21:43:40 +01:00
|
|
|
)
|
|
|
|
|
2016-12-23 12:42:25 +01:00
|
|
|
func (v *AllocationStrategy) GetConcurrencyValue() uint32 {
|
|
|
|
if v == nil || v.Concurrency == nil {
|
2016-10-14 22:21:45 +02:00
|
|
|
return 3
|
|
|
|
}
|
2016-12-23 12:42:25 +01:00
|
|
|
return v.Concurrency.Value
|
2015-12-28 23:17:38 +01:00
|
|
|
}
|
|
|
|
|
2016-12-23 12:42:25 +01:00
|
|
|
func (v *AllocationStrategy) GetRefreshValue() uint32 {
|
|
|
|
if v == nil || v.Refresh == nil {
|
2016-10-14 22:21:45 +02:00
|
|
|
return 5
|
|
|
|
}
|
2016-12-23 12:42:25 +01:00
|
|
|
return v.Refresh.Value
|
2015-10-31 14:08:13 +01:00
|
|
|
}
|
|
|
|
|
2016-11-27 21:39:09 +01:00
|
|
|
func (v *InboundConnectionConfig) GetAllocationStrategyValue() *AllocationStrategy {
|
|
|
|
if v.AllocationStrategy == nil {
|
2016-10-14 22:21:45 +02:00
|
|
|
return &AllocationStrategy{}
|
|
|
|
}
|
2016-11-27 21:39:09 +01:00
|
|
|
return v.AllocationStrategy
|
2015-11-13 23:43:58 +01:00
|
|
|
}
|
|
|
|
|
2017-01-14 00:27:45 +01:00
|
|
|
func (v *InboundConnectionConfig) GetListenOnValue() net.Address {
|
2016-11-27 21:39:09 +01:00
|
|
|
if v.GetListenOn() == nil {
|
2017-01-14 00:27:45 +01:00
|
|
|
return net.AnyIP
|
2016-10-17 14:35:13 +02:00
|
|
|
}
|
2016-11-27 21:39:09 +01:00
|
|
|
return v.ListenOn.AsAddress()
|
2016-10-17 14:35:13 +02:00
|
|
|
}
|
|
|
|
|
2016-11-27 21:39:09 +01:00
|
|
|
func (v *InboundConnectionConfig) GetTypedSettings() (interface{}, error) {
|
|
|
|
if v.GetSettings() == nil {
|
2016-10-16 00:46:08 +02:00
|
|
|
return nil, common.ErrBadConfiguration
|
|
|
|
}
|
2016-11-27 21:39:09 +01:00
|
|
|
return v.GetSettings().GetInstance()
|
2016-10-16 00:46:08 +02:00
|
|
|
}
|
|
|
|
|
2016-11-27 21:39:09 +01:00
|
|
|
func (v *OutboundConnectionConfig) GetTypedSettings() (interface{}, error) {
|
|
|
|
if v.GetSettings() == nil {
|
2016-10-16 00:46:08 +02:00
|
|
|
return nil, common.ErrBadConfiguration
|
|
|
|
}
|
2016-11-27 21:39:09 +01:00
|
|
|
return v.GetSettings().GetInstance()
|
2016-01-17 21:43:10 +01:00
|
|
|
}
|
2016-10-18 00:02:41 +02:00
|
|
|
|
2017-01-14 00:27:45 +01:00
|
|
|
func (v *OutboundConnectionConfig) GetSendThroughValue() net.Address {
|
2016-11-27 21:39:09 +01:00
|
|
|
if v.GetSendThrough() == nil {
|
2017-01-14 00:27:45 +01:00
|
|
|
return net.AnyIP
|
2016-10-18 00:02:41 +02:00
|
|
|
}
|
2016-11-27 21:39:09 +01:00
|
|
|
return v.SendThrough.AsAddress()
|
2016-10-18 00:02:41 +02:00
|
|
|
}
|