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

56 lines
1.2 KiB
Go
Raw Normal View History

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