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 (this *AllocationStrategyConcurrency) GetValue() uint32 {
  7. if this == nil {
  8. return 3
  9. }
  10. return this.Value
  11. }
  12. func (this *AllocationStrategyRefresh) GetValue() uint32 {
  13. if this == nil {
  14. return 5
  15. }
  16. return this.Value
  17. }
  18. func (this *InboundConnectionConfig) GetAllocationStrategyValue() *AllocationStrategy {
  19. if this.AllocationStrategy == nil {
  20. return &AllocationStrategy{}
  21. }
  22. return this.AllocationStrategy
  23. }
  24. func (this *InboundConnectionConfig) GetListenOnValue() v2net.Address {
  25. if this.GetListenOn() == nil {
  26. return v2net.AnyIP
  27. }
  28. return this.ListenOn.AsAddress()
  29. }
  30. func (this *InboundConnectionConfig) GetTypedSettings() (interface{}, error) {
  31. if this.GetSettings() == nil {
  32. return nil, common.ErrBadConfiguration
  33. }
  34. return this.GetSettings().GetInstance()
  35. }
  36. func (this *OutboundConnectionConfig) GetTypedSettings() (interface{}, error) {
  37. if this.GetSettings() == nil {
  38. return nil, common.ErrBadConfiguration
  39. }
  40. return this.GetSettings().GetInstance()
  41. }
  42. func (this *OutboundConnectionConfig) GetSendThroughValue() v2net.Address {
  43. if this.GetSendThrough() == nil {
  44. return v2net.AnyIP
  45. }
  46. return this.SendThrough.AsAddress()
  47. }