1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-10-27 22:20:56 -04:00
v2fly/shell/point/config/testing/mocks/config.go

130 lines
2.8 KiB
Go
Raw Normal View History

2015-09-19 09:35:20 -04:00
package mocks
import (
2015-11-22 11:41:52 -05:00
routerconfig "github.com/v2ray/v2ray-core/app/router/config"
2015-12-02 18:41:34 -05:00
routertestingconfig "github.com/v2ray/v2ray-core/app/router/config/testing"
2015-12-05 15:10:14 -05:00
"github.com/v2ray/v2ray-core/common/log"
2015-11-21 15:43:40 -05:00
v2net "github.com/v2ray/v2ray-core/common/net"
2015-11-29 08:45:32 -05:00
"github.com/v2ray/v2ray-core/shell/point/config"
2015-09-19 09:35:20 -04:00
)
type ConnectionConfig struct {
ProtocolValue string
2015-10-06 17:11:08 -04:00
SettingsValue interface{}
2015-09-19 09:35:20 -04:00
}
func (config *ConnectionConfig) Protocol() string {
return config.ProtocolValue
}
func (config *ConnectionConfig) Settings() interface{} {
2015-10-06 17:11:08 -04:00
return config.SettingsValue
2015-09-19 09:35:20 -04:00
}
2015-10-09 11:58:35 -04:00
type LogConfig struct {
AccessLogValue string
2015-12-05 15:10:14 -05:00
ErrorLogValue string
LogLevelValue log.LogLevel
}
func (config *LogConfig) AccessLog() string {
return config.AccessLogValue
}
func (this *LogConfig) ErrorLog() string {
return this.ErrorLogValue
}
func (this *LogConfig) LogLevel() log.LogLevel {
return this.LogLevelValue
2015-10-09 11:58:35 -04:00
}
2015-10-31 17:22:43 -04:00
type PortRange struct {
2015-12-02 06:47:54 -05:00
FromValue v2net.Port
ToValue v2net.Port
2015-10-31 17:22:43 -04:00
}
2015-12-02 06:47:54 -05:00
func (this *PortRange) From() v2net.Port {
2015-10-31 17:22:43 -04:00
return this.FromValue
}
2015-12-02 06:47:54 -05:00
func (this *PortRange) To() v2net.Port {
2015-10-31 17:22:43 -04:00
return this.ToValue
}
type InboundDetourConfig struct {
2015-12-02 18:41:34 -05:00
*ConnectionConfig
2015-10-31 17:22:43 -04:00
PortRangeValue *PortRange
}
2015-11-21 15:43:40 -05:00
func (this *InboundDetourConfig) PortRange() v2net.PortRange {
2015-10-31 17:22:43 -04:00
return this.PortRangeValue
}
2015-11-22 11:41:52 -05:00
type OutboundDetourConfig struct {
2015-12-02 18:41:34 -05:00
*ConnectionConfig
TagValue string
2015-11-22 11:41:52 -05:00
}
func (this *OutboundDetourConfig) Tag() string {
2015-11-22 11:41:52 -05:00
return this.TagValue
}
2015-09-19 09:35:20 -04:00
type Config struct {
2015-12-02 15:44:01 -05:00
PortValue v2net.Port
2015-11-22 11:41:52 -05:00
LogConfigValue *LogConfig
2015-12-02 18:41:34 -05:00
RouterConfigValue *routertestingconfig.RouterConfig
2015-11-22 11:41:52 -05:00
InboundConfigValue *ConnectionConfig
OutboundConfigValue *ConnectionConfig
InboundDetoursValue []*InboundDetourConfig
OutboundDetoursValue []*OutboundDetourConfig
2015-09-19 09:35:20 -04:00
}
2015-12-02 15:44:01 -05:00
func (config *Config) Port() v2net.Port {
2015-09-19 09:35:20 -04:00
return config.PortValue
}
2015-10-09 11:58:35 -04:00
func (config *Config) LogConfig() config.LogConfig {
2015-12-02 18:41:34 -05:00
if config.LogConfigValue == nil {
return nil
}
2015-10-09 11:58:35 -04:00
return config.LogConfigValue
}
2015-11-22 11:41:52 -05:00
func (this *Config) RouterConfig() routerconfig.RouterConfig {
2015-12-02 18:41:34 -05:00
if this.RouterConfigValue == nil {
return nil
}
2015-11-22 11:41:52 -05:00
return this.RouterConfigValue
}
2015-12-02 18:41:34 -05:00
func (this *Config) InboundConfig() config.ConnectionConfig {
if this.InboundConfigValue == nil {
return nil
}
return this.InboundConfigValue
2015-09-19 09:35:20 -04:00
}
2015-12-02 18:41:34 -05:00
func (this *Config) OutboundConfig() config.ConnectionConfig {
if this.OutboundConfigValue == nil {
return nil
}
return this.OutboundConfigValue
2015-09-19 09:35:20 -04:00
}
2015-10-31 17:22:43 -04:00
func (this *Config) InboundDetours() []config.InboundDetourConfig {
detours := make([]config.InboundDetourConfig, len(this.InboundDetoursValue))
for idx, detour := range this.InboundDetoursValue {
detours[idx] = detour
}
return detours
}
2015-11-22 11:41:52 -05:00
func (this *Config) OutboundDetours() []config.OutboundDetourConfig {
detours := make([]config.OutboundDetourConfig, len(this.OutboundDetoursValue))
for idx, detour := range this.OutboundDetoursValue {
detours[idx] = detour
}
return detours
}