1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-01 06:55:25 -05:00

Simpilify configuration files

This commit is contained in:
V2Ray
2015-10-06 23:11:08 +02:00
parent 78daf8a879
commit 72b4eeba8b
27 changed files with 251 additions and 208 deletions

View File

@@ -1,20 +1,20 @@
package mocks
import (
"github.com/v2ray/v2ray-core"
"github.com/v2ray/v2ray-core/config"
)
type ConnectionConfig struct {
ProtocolValue string
ContentValue []byte
SettingsValue interface{}
}
func (config *ConnectionConfig) Protocol() string {
return config.ProtocolValue
}
func (config *ConnectionConfig) Content() []byte {
return config.ContentValue
func (config *ConnectionConfig) Settings(config.Type) interface{} {
return config.SettingsValue
}
type Config struct {
@@ -27,10 +27,10 @@ func (config *Config) Port() uint16 {
return config.PortValue
}
func (config *Config) InboundConfig() core.ConnectionConfig {
func (config *Config) InboundConfig() config.ConnectionConfig {
return config.InboundConfigValue
}
func (config *Config) OutboundConfig() core.ConnectionConfig {
func (config *Config) OutboundConfig() config.ConnectionConfig {
return config.OutboundConfigValue
}

View File

@@ -32,7 +32,7 @@ func (handler *InboundConnectionHandler) Communicate(packet v2net.Packet) error
return nil
}
func (handler *InboundConnectionHandler) Create(point *core.Point, config []byte) (core.InboundConnectionHandler, error) {
func (handler *InboundConnectionHandler) Create(point *core.Point, config interface{}) (core.InboundConnectionHandler, error) {
handler.Server = point
return handler, nil
}

View File

@@ -34,11 +34,7 @@ func (handler *OutboundConnectionHandler) Start(ray core.OutboundRay) error {
return nil
}
func (handler *OutboundConnectionHandler) Initialize(config []byte) error {
return nil
}
func (handler *OutboundConnectionHandler) Create(point *core.Point, packet v2net.Packet) (core.OutboundConnectionHandler, error) {
func (handler *OutboundConnectionHandler) Create(point *core.Point, config interface{}, packet v2net.Packet) (core.OutboundConnectionHandler, error) {
handler.Destination = packet.Destination()
if packet.Chunk() != nil {
handler.Data2Send.Write(packet.Chunk())

View File

@@ -22,7 +22,10 @@ func NewSubject(assert *Assertion) *Subject {
// decorate prefixes the string with the file and line of the call site
// and inserts the final newline if needed and indentation tabs for formatting.
func decorate(s string) string {
_, file, line, ok := runtime.Caller(4) // decorate + log + public function.
_, file, line, ok := runtime.Caller(3)
if strings.Contains(file, "testing") {
_, file, line, ok = runtime.Caller(4)
}
if ok {
// Truncate file name at last file name separator.
if index := strings.LastIndex(file, "/"); index >= 0 {