inbound_detour.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package json
  2. import (
  3. "encoding/json"
  4. v2net "github.com/v2ray/v2ray-core/common/net"
  5. v2netjson "github.com/v2ray/v2ray-core/common/net/json"
  6. proxyconfig "github.com/v2ray/v2ray-core/proxy/common/config"
  7. "github.com/v2ray/v2ray-core/shell/point"
  8. )
  9. type InboundDetourAllocationConfig struct {
  10. StrategyValue string `json:"strategy"`
  11. ConcurrencyValue int `json:"concurrency"`
  12. }
  13. func (this *InboundDetourAllocationConfig) Strategy() string {
  14. return this.StrategyValue
  15. }
  16. func (this *InboundDetourAllocationConfig) Concurrency() int {
  17. return this.ConcurrencyValue
  18. }
  19. type InboundDetourConfig struct {
  20. ProtocolValue string `json:"protocol"`
  21. PortRangeValue *v2netjson.PortRange `json:"port"`
  22. SettingsValue json.RawMessage `json:"settings"`
  23. TagValue string `json:"tag"`
  24. AllocationValue *InboundDetourAllocationConfig `json:"allocate"`
  25. }
  26. func (this *InboundDetourConfig) Allocation() point.InboundDetourAllocationConfig {
  27. return this.AllocationValue
  28. }
  29. func (this *InboundDetourConfig) Protocol() string {
  30. return this.ProtocolValue
  31. }
  32. func (this *InboundDetourConfig) PortRange() v2net.PortRange {
  33. return this.PortRangeValue
  34. }
  35. func (this *InboundDetourConfig) Settings() interface{} {
  36. return loadConnectionConfig(this.SettingsValue, this.ProtocolValue, proxyconfig.TypeInbound)
  37. }
  38. func (this *InboundDetourConfig) Tag() string {
  39. return this.TagValue
  40. }