config.go 1.6 KB

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