inbound_detour.go 1.4 KB

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