inbound_detour.go 1.4 KB

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