2015-09-19 15:35:20 +02:00
|
|
|
package mocks
|
|
|
|
|
|
|
|
import (
|
2015-12-07 22:47:47 +01:00
|
|
|
"github.com/v2ray/v2ray-core/app/router"
|
2015-12-05 21:10:14 +01:00
|
|
|
"github.com/v2ray/v2ray-core/common/log"
|
2015-11-21 21:43:40 +01:00
|
|
|
v2net "github.com/v2ray/v2ray-core/common/net"
|
2015-12-06 16:41:41 +01:00
|
|
|
"github.com/v2ray/v2ray-core/shell/point"
|
2015-09-19 15:35:20 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type ConnectionConfig struct {
|
|
|
|
ProtocolValue string
|
2016-01-02 17:40:51 +01:00
|
|
|
SettingsValue []byte
|
2015-09-19 15:35:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (config *ConnectionConfig) Protocol() string {
|
|
|
|
return config.ProtocolValue
|
|
|
|
}
|
|
|
|
|
2016-01-02 17:40:51 +01:00
|
|
|
func (config *ConnectionConfig) Settings() []byte {
|
2015-10-06 23:11:08 +02:00
|
|
|
return config.SettingsValue
|
2015-09-19 15:35:20 +02:00
|
|
|
}
|
|
|
|
|
2015-10-09 17:58:35 +02:00
|
|
|
type LogConfig struct {
|
|
|
|
AccessLogValue string
|
2015-12-05 21:10:14 +01: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 17:58:35 +02:00
|
|
|
}
|
|
|
|
|
2015-12-28 23:17:38 +01:00
|
|
|
type InboundDetourAllocationConfig struct {
|
|
|
|
StrategyValue string
|
|
|
|
ConcurrencyValue int
|
2015-12-29 20:52:35 +01:00
|
|
|
RefreshSec int
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *InboundDetourAllocationConfig) Refresh() int {
|
|
|
|
return this.RefreshSec
|
2015-12-28 23:17:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *InboundDetourAllocationConfig) Strategy() string {
|
|
|
|
return this.StrategyValue
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *InboundDetourAllocationConfig) Concurrency() int {
|
|
|
|
return this.ConcurrencyValue
|
|
|
|
}
|
|
|
|
|
2015-10-31 22:22:43 +01:00
|
|
|
type InboundDetourConfig struct {
|
2015-12-02 23:41:34 +00:00
|
|
|
*ConnectionConfig
|
2016-01-15 13:39:36 +01:00
|
|
|
PortRangeValue *v2net.PortRange
|
2015-12-28 23:17:38 +01:00
|
|
|
TagValue string
|
|
|
|
AllocationStrategy *InboundDetourAllocationConfig
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *InboundDetourConfig) Allocation() point.InboundDetourAllocationConfig {
|
|
|
|
return this.AllocationStrategy
|
2015-12-08 00:54:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *InboundDetourConfig) Tag() string {
|
|
|
|
return this.TagValue
|
2015-10-31 22:22:43 +01:00
|
|
|
}
|
|
|
|
|
2015-11-21 21:43:40 +01:00
|
|
|
func (this *InboundDetourConfig) PortRange() v2net.PortRange {
|
2016-01-15 13:39:36 +01:00
|
|
|
return *this.PortRangeValue
|
2015-10-31 22:22:43 +01:00
|
|
|
}
|
|
|
|
|
2015-11-22 17:41:52 +01:00
|
|
|
type OutboundDetourConfig struct {
|
2015-12-02 23:41:34 +00:00
|
|
|
*ConnectionConfig
|
2015-11-30 15:14:38 +00:00
|
|
|
TagValue string
|
2015-11-22 17:41:52 +01:00
|
|
|
}
|
|
|
|
|
2015-11-30 15:14:38 +00:00
|
|
|
func (this *OutboundDetourConfig) Tag() string {
|
2015-11-22 17:41:52 +01:00
|
|
|
return this.TagValue
|
|
|
|
}
|
|
|
|
|
2015-09-19 15:35:20 +02:00
|
|
|
type Config struct {
|
2015-12-02 20:44:01 +00:00
|
|
|
PortValue v2net.Port
|
2015-11-22 17:41:52 +01:00
|
|
|
LogConfigValue *LogConfig
|
2016-01-17 15:20:49 +00:00
|
|
|
RouterConfigValue *router.Config
|
2015-11-22 17:41:52 +01:00
|
|
|
InboundConfigValue *ConnectionConfig
|
|
|
|
OutboundConfigValue *ConnectionConfig
|
|
|
|
InboundDetoursValue []*InboundDetourConfig
|
|
|
|
OutboundDetoursValue []*OutboundDetourConfig
|
2015-09-19 15:35:20 +02:00
|
|
|
}
|
|
|
|
|
2015-12-02 20:44:01 +00:00
|
|
|
func (config *Config) Port() v2net.Port {
|
2015-09-19 15:35:20 +02:00
|
|
|
return config.PortValue
|
|
|
|
}
|
|
|
|
|
2015-12-06 16:41:41 +01:00
|
|
|
func (config *Config) LogConfig() point.LogConfig {
|
2015-12-02 23:41:34 +00:00
|
|
|
if config.LogConfigValue == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2015-10-09 17:58:35 +02:00
|
|
|
return config.LogConfigValue
|
|
|
|
}
|
|
|
|
|
2016-01-17 15:20:49 +00:00
|
|
|
func (this *Config) RouterConfig() *router.Config {
|
2015-12-02 23:41:34 +00:00
|
|
|
if this.RouterConfigValue == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2015-11-22 17:41:52 +01:00
|
|
|
return this.RouterConfigValue
|
|
|
|
}
|
|
|
|
|
2015-12-06 16:41:41 +01:00
|
|
|
func (this *Config) InboundConfig() point.ConnectionConfig {
|
2015-12-02 23:41:34 +00:00
|
|
|
if this.InboundConfigValue == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return this.InboundConfigValue
|
2015-09-19 15:35:20 +02:00
|
|
|
}
|
|
|
|
|
2015-12-06 16:41:41 +01:00
|
|
|
func (this *Config) OutboundConfig() point.ConnectionConfig {
|
2015-12-02 23:41:34 +00:00
|
|
|
if this.OutboundConfigValue == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return this.OutboundConfigValue
|
2015-09-19 15:35:20 +02:00
|
|
|
}
|
2015-10-31 22:22:43 +01:00
|
|
|
|
2015-12-06 16:41:41 +01:00
|
|
|
func (this *Config) InboundDetours() []point.InboundDetourConfig {
|
|
|
|
detours := make([]point.InboundDetourConfig, len(this.InboundDetoursValue))
|
2015-10-31 22:22:43 +01:00
|
|
|
for idx, detour := range this.InboundDetoursValue {
|
|
|
|
detours[idx] = detour
|
|
|
|
}
|
|
|
|
return detours
|
|
|
|
}
|
2015-11-22 17:41:52 +01:00
|
|
|
|
2015-12-06 16:41:41 +01:00
|
|
|
func (this *Config) OutboundDetours() []point.OutboundDetourConfig {
|
|
|
|
detours := make([]point.OutboundDetourConfig, len(this.OutboundDetoursValue))
|
2015-11-22 17:41:52 +01:00
|
|
|
for idx, detour := range this.OutboundDetoursValue {
|
|
|
|
detours[idx] = detour
|
|
|
|
}
|
|
|
|
return detours
|
|
|
|
}
|