config.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package core
  2. import (
  3. "v2ray.com/core/common"
  4. v2net "v2ray.com/core/common/net"
  5. )
  6. func (v *AllocationStrategy) GetConcurrencyValue() uint32 {
  7. if v == nil || v.Concurrency == nil {
  8. return 3
  9. }
  10. return v.Concurrency.Value
  11. }
  12. func (v *AllocationStrategy) GetRefreshValue() uint32 {
  13. if v == nil || v.Refresh == nil {
  14. return 5
  15. }
  16. return v.Refresh.Value
  17. }
  18. func (v *InboundConnectionConfig) GetAllocationStrategyValue() *AllocationStrategy {
  19. if v.AllocationStrategy == nil {
  20. return &AllocationStrategy{}
  21. }
  22. return v.AllocationStrategy
  23. }
  24. func (v *InboundConnectionConfig) GetListenOnValue() v2net.Address {
  25. if v.GetListenOn() == nil {
  26. return v2net.AnyIP
  27. }
  28. return v.ListenOn.AsAddress()
  29. }
  30. func (v *InboundConnectionConfig) GetTypedSettings() (interface{}, error) {
  31. if v.GetSettings() == nil {
  32. return nil, common.ErrBadConfiguration
  33. }
  34. return v.GetSettings().GetInstance()
  35. }
  36. func (v *OutboundConnectionConfig) GetTypedSettings() (interface{}, error) {
  37. if v.GetSettings() == nil {
  38. return nil, common.ErrBadConfiguration
  39. }
  40. return v.GetSettings().GetInstance()
  41. }
  42. func (v *OutboundConnectionConfig) GetSendThroughValue() v2net.Address {
  43. if v.GetSendThrough() == nil {
  44. return v2net.AnyIP
  45. }
  46. return v.SendThrough.AsAddress()
  47. }