inbound_detour.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. RefreshSec int `json:"refresh"`
  13. }
  14. func (this *InboundDetourAllocationConfig) Refresh() int {
  15. return this.RefreshSec
  16. }
  17. func (this *InboundDetourAllocationConfig) Strategy() string {
  18. return this.StrategyValue
  19. }
  20. func (this *InboundDetourAllocationConfig) Concurrency() int {
  21. return this.ConcurrencyValue
  22. }
  23. type InboundDetourConfig struct {
  24. ProtocolValue string `json:"protocol"`
  25. PortRangeValue *v2netjson.PortRange `json:"port"`
  26. SettingsValue json.RawMessage `json:"settings"`
  27. TagValue string `json:"tag"`
  28. AllocationValue *InboundDetourAllocationConfig `json:"allocate"`
  29. }
  30. func (this *InboundDetourConfig) Allocation() point.InboundDetourAllocationConfig {
  31. return this.AllocationValue
  32. }
  33. func (this *InboundDetourConfig) Protocol() string {
  34. return this.ProtocolValue
  35. }
  36. func (this *InboundDetourConfig) PortRange() v2net.PortRange {
  37. return this.PortRangeValue
  38. }
  39. func (this *InboundDetourConfig) Settings() interface{} {
  40. return loadConnectionConfig(this.SettingsValue, this.ProtocolValue, proxyconfig.TypeInbound)
  41. }
  42. func (this *InboundDetourConfig) Tag() string {
  43. return this.TagValue
  44. }