config.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package mocks
  2. import (
  3. routerconfig "github.com/v2ray/v2ray-core/app/router/config"
  4. v2net "github.com/v2ray/v2ray-core/common/net"
  5. "github.com/v2ray/v2ray-core/shell/point/config"
  6. )
  7. type ConnectionConfig struct {
  8. ProtocolValue string
  9. SettingsValue interface{}
  10. }
  11. func (config *ConnectionConfig) Protocol() string {
  12. return config.ProtocolValue
  13. }
  14. func (config *ConnectionConfig) Settings() interface{} {
  15. return config.SettingsValue
  16. }
  17. type LogConfig struct {
  18. AccessLogValue string
  19. }
  20. type PortRange struct {
  21. FromValue v2net.Port
  22. ToValue v2net.Port
  23. }
  24. func (this *PortRange) From() v2net.Port {
  25. return this.FromValue
  26. }
  27. func (this *PortRange) To() v2net.Port {
  28. return this.ToValue
  29. }
  30. type InboundDetourConfig struct {
  31. ConnectionConfig
  32. PortRangeValue *PortRange
  33. }
  34. func (this *InboundDetourConfig) PortRange() v2net.PortRange {
  35. return this.PortRangeValue
  36. }
  37. type OutboundDetourConfig struct {
  38. ConnectionConfig
  39. TagValue string
  40. }
  41. func (this *OutboundDetourConfig) Tag() string {
  42. return this.TagValue
  43. }
  44. func (config *LogConfig) AccessLog() string {
  45. return config.AccessLogValue
  46. }
  47. type Config struct {
  48. PortValue uint16
  49. LogConfigValue *LogConfig
  50. RouterConfigValue routerconfig.RouterConfig
  51. InboundConfigValue *ConnectionConfig
  52. OutboundConfigValue *ConnectionConfig
  53. InboundDetoursValue []*InboundDetourConfig
  54. OutboundDetoursValue []*OutboundDetourConfig
  55. }
  56. func (config *Config) Port() uint16 {
  57. return config.PortValue
  58. }
  59. func (config *Config) LogConfig() config.LogConfig {
  60. return config.LogConfigValue
  61. }
  62. func (this *Config) RouterConfig() routerconfig.RouterConfig {
  63. return this.RouterConfigValue
  64. }
  65. func (config *Config) InboundConfig() config.ConnectionConfig {
  66. return config.InboundConfigValue
  67. }
  68. func (config *Config) OutboundConfig() config.ConnectionConfig {
  69. return config.OutboundConfigValue
  70. }
  71. func (this *Config) InboundDetours() []config.InboundDetourConfig {
  72. detours := make([]config.InboundDetourConfig, len(this.InboundDetoursValue))
  73. for idx, detour := range this.InboundDetoursValue {
  74. detours[idx] = detour
  75. }
  76. return detours
  77. }
  78. func (this *Config) OutboundDetours() []config.OutboundDetourConfig {
  79. detours := make([]config.OutboundDetourConfig, len(this.OutboundDetoursValue))
  80. for idx, detour := range this.OutboundDetoursValue {
  81. detours[idx] = detour
  82. }
  83. return detours
  84. }