config.go 911 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package core
  2. import (
  3. "io"
  4. "v2ray.com/core/common"
  5. "v2ray.com/core/proxy/registry"
  6. )
  7. func (this *AllocationStrategyConcurrency) GetValue() uint32 {
  8. if this == nil {
  9. return 3
  10. }
  11. return this.Value
  12. }
  13. func (this *AllocationStrategyRefresh) GetValue() uint32 {
  14. if this == nil {
  15. return 5
  16. }
  17. return this.Value
  18. }
  19. func (this *InboundConnectionConfig) GetAllocationStrategyValue() *AllocationStrategy {
  20. if this.AllocationStrategy == nil {
  21. return &AllocationStrategy{}
  22. }
  23. return this.AllocationStrategy
  24. }
  25. func (this *InboundConnectionConfig) GetTypedSettings() (interface{}, error) {
  26. return registry.MarshalInboundConfig(this.Protocol, this.Settings)
  27. }
  28. type ConfigLoader func(input io.Reader) (*Config, error)
  29. var (
  30. configLoader ConfigLoader
  31. )
  32. func LoadConfig(input io.Reader) (*Config, error) {
  33. if configLoader == nil {
  34. return nil, common.ErrBadConfiguration
  35. }
  36. return configLoader(input)
  37. }