config.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package mocks
  2. import (
  3. "github.com/v2ray/v2ray-core/app/point/config"
  4. )
  5. type ConnectionConfig struct {
  6. ProtocolValue string
  7. SettingsValue interface{}
  8. }
  9. func (config *ConnectionConfig) Protocol() string {
  10. return config.ProtocolValue
  11. }
  12. func (config *ConnectionConfig) Settings() interface{} {
  13. return config.SettingsValue
  14. }
  15. type LogConfig struct {
  16. AccessLogValue string
  17. }
  18. type PortRange struct {
  19. FromValue uint16
  20. ToValue uint16
  21. }
  22. func (this *PortRange) From() uint16 {
  23. return this.FromValue
  24. }
  25. func (this *PortRange) To() uint16 {
  26. return this.ToValue
  27. }
  28. type InboundDetourConfig struct {
  29. ConnectionConfig
  30. PortRangeValue *PortRange
  31. }
  32. func (this *InboundDetourConfig) PortRange() config.PortRange {
  33. return this.PortRangeValue
  34. }
  35. func (config *LogConfig) AccessLog() string {
  36. return config.AccessLogValue
  37. }
  38. type Config struct {
  39. PortValue uint16
  40. LogConfigValue *LogConfig
  41. InboundConfigValue *ConnectionConfig
  42. OutboundConfigValue *ConnectionConfig
  43. InboundDetoursValue []*InboundDetourConfig
  44. }
  45. func (config *Config) Port() uint16 {
  46. return config.PortValue
  47. }
  48. func (config *Config) LogConfig() config.LogConfig {
  49. return config.LogConfigValue
  50. }
  51. func (config *Config) InboundConfig() config.ConnectionConfig {
  52. return config.InboundConfigValue
  53. }
  54. func (config *Config) OutboundConfig() config.ConnectionConfig {
  55. return config.OutboundConfigValue
  56. }
  57. func (this *Config) InboundDetours() []config.InboundDetourConfig {
  58. detours := make([]config.InboundDetourConfig, len(this.InboundDetoursValue))
  59. for idx, detour := range this.InboundDetoursValue {
  60. detours[idx] = detour
  61. }
  62. return detours
  63. }