1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-17 23:06:30 -05:00

lazy evaluation of log fields

This commit is contained in:
v2ray 2016-01-18 12:24:33 +01:00
parent 8f20933457
commit eec0bb4db4
25 changed files with 124 additions and 117 deletions

View File

@ -19,7 +19,7 @@ func (this *Config) UnmarshalJSON(data []byte) error {
} }
settings, err := CreateRouterConfig(jsonConfig.Strategy, []byte(jsonConfig.Settings)) settings, err := CreateRouterConfig(jsonConfig.Strategy, []byte(jsonConfig.Settings))
if err != nil { if err != nil {
log.Error("Router: Failed to load router settings: %v", err) log.Error("Router: Failed to load router settings: ", err)
return err return err
} }
this.Strategy = jsonConfig.Strategy this.Strategy = jsonConfig.Strategy

View File

@ -13,7 +13,7 @@ func parseChinaIPRule(data []byte) (*Rule, error) {
rawRule := new(JsonRule) rawRule := new(JsonRule)
err := json.Unmarshal(data, rawRule) err := json.Unmarshal(data, rawRule)
if err != nil { if err != nil {
log.Error("Router: Invalid router rule: %v", err) log.Error("Router: Invalid router rule: ", err)
return nil, err return nil, err
} }
return &Rule{ return &Rule{

View File

@ -24,7 +24,7 @@ func parseChinaSitesRule(data []byte) (*Rule, error) {
rawRule := new(JsonRule) rawRule := new(JsonRule)
err := json.Unmarshal(data, rawRule) err := json.Unmarshal(data, rawRule)
if err != nil { if err != nil {
log.Error("Router: Invalid router rule: %v", err) log.Error("Router: Invalid router rule: ", err)
return nil, err return nil, err
} }
return &Rule{ return &Rule{

View File

@ -53,7 +53,7 @@ func parseFieldRule(msg json.RawMessage) (*Rule, error) {
for _, ipStr := range *(rawFieldRule.IP) { for _, ipStr := range *(rawFieldRule.IP) {
cidrMatcher, err := NewCIDRMatcher(ipStr.String()) cidrMatcher, err := NewCIDRMatcher(ipStr.String())
if err != nil { if err != nil {
log.Error("Router: Invalid IP range in router rule: %v", err) log.Error("Router: Invalid IP range in router rule: ", err)
return nil, err return nil, err
} }
conds.Add(cidrMatcher) conds.Add(cidrMatcher)
@ -78,14 +78,14 @@ func parseRule(msg json.RawMessage) *Rule {
rawRule := new(JsonRule) rawRule := new(JsonRule)
err := json.Unmarshal(msg, rawRule) err := json.Unmarshal(msg, rawRule)
if err != nil { if err != nil {
log.Error("Router: Invalid router rule: %v", err) log.Error("Router: Invalid router rule: ", err)
return nil return nil
} }
if rawRule.Type == "field" { if rawRule.Type == "field" {
fieldrule, err := parseFieldRule(msg) fieldrule, err := parseFieldRule(msg)
if err != nil { if err != nil {
log.Error("Invalid field rule: %v", err) log.Error("Invalid field rule: ", err)
return nil return nil
} }
return fieldrule return fieldrule
@ -93,7 +93,7 @@ func parseRule(msg json.RawMessage) *Rule {
if rawRule.Type == "chinaip" { if rawRule.Type == "chinaip" {
chinaiprule, err := parseChinaIPRule(msg) chinaiprule, err := parseChinaIPRule(msg)
if err != nil { if err != nil {
log.Error("Router: Invalid chinaip rule: %v", err) log.Error("Router: Invalid chinaip rule: ", err)
return nil return nil
} }
return chinaiprule return chinaiprule
@ -101,12 +101,12 @@ func parseRule(msg json.RawMessage) *Rule {
if rawRule.Type == "chinasites" { if rawRule.Type == "chinasites" {
chinasitesrule, err := parseChinaSitesRule(msg) chinasitesrule, err := parseChinaSitesRule(msg)
if err != nil { if err != nil {
log.Error("Invalid chinasites rule: %v", err) log.Error("Invalid chinasites rule: ", err)
return nil return nil
} }
return chinasitesrule return chinasitesrule
} }
log.Error("Unknown router rule type: %s", rawRule.Type) log.Error("Unknown router rule type: ", rawRule.Type)
return nil return nil
} }

View File

@ -27,7 +27,7 @@ func (this *accessLog) String() string {
func InitAccessLogger(file string) error { func InitAccessLogger(file string) error {
logger, err := newFileLogWriter(file) logger, err := newFileLogWriter(file)
if err != nil { if err != nil {
Error("Failed to create access logger on file (%s): %v", file, err) Error("Failed to create access logger on file (", file, "): ", file, err)
return err return err
} }
accessLoggerInstance = logger accessLoggerInstance = logger

View File

@ -2,6 +2,8 @@ package log
import ( import (
"fmt" "fmt"
"github.com/v2ray/v2ray-core/common/serial"
) )
const ( const (
@ -13,16 +15,24 @@ const (
type errorLog struct { type errorLog struct {
prefix string prefix string
format string
values []interface{} values []interface{}
} }
func (this *errorLog) String() string { func (this *errorLog) String() string {
var data string data := ""
if len(this.values) == 0 { for _, value := range this.values {
data = this.format switch typedVal := value.(type) {
} else { case string:
data = fmt.Sprintf(this.format, this.values...) data += typedVal
case *string:
data += *typedVal
case serial.String:
data += typedVal.String()
case error:
data += typedVal.Error()
default:
data += fmt.Sprintf("%v", value)
}
} }
return this.prefix + data return this.prefix + data
} }
@ -64,7 +74,7 @@ func SetLogLevel(level LogLevel) {
func InitErrorLogger(file string) error { func InitErrorLogger(file string) error {
logger, err := newFileLogWriter(file) logger, err := newFileLogWriter(file)
if err != nil { if err != nil {
Error("Failed to create error logger on file (%s): %v", file, err) Error("Failed to create error logger on file (", file, "): ", err)
return err return err
} }
streamLoggerInstance = logger streamLoggerInstance = logger
@ -72,37 +82,33 @@ func InitErrorLogger(file string) error {
} }
// Debug outputs a debug log with given format and optional arguments. // Debug outputs a debug log with given format and optional arguments.
func Debug(format string, v ...interface{}) { func Debug(v ...interface{}) {
debugLogger.Log(&errorLog{ debugLogger.Log(&errorLog{
prefix: "[Debug]", prefix: "[Debug]",
format: format,
values: v, values: v,
}) })
} }
// Info outputs an info log with given format and optional arguments. // Info outputs an info log with given format and optional arguments.
func Info(format string, v ...interface{}) { func Info(v ...interface{}) {
infoLogger.Log(&errorLog{ infoLogger.Log(&errorLog{
prefix: "[Info]", prefix: "[Info]",
format: format,
values: v, values: v,
}) })
} }
// Warning outputs a warning log with given format and optional arguments. // Warning outputs a warning log with given format and optional arguments.
func Warning(format string, v ...interface{}) { func Warning(v ...interface{}) {
warningLogger.Log(&errorLog{ warningLogger.Log(&errorLog{
prefix: "[Warning]", prefix: "[Warning]",
format: format,
values: v, values: v,
}) })
} }
// Error outputs an error log with given format and optional arguments. // Error outputs an error log with given format and optional arguments.
func Error(format string, v ...interface{}) { func Error(v ...interface{}) {
errorLogger.Log(&errorLog{ errorLogger.Log(&errorLog{
prefix: "[Error]", prefix: "[Error]",
format: format,
values: v, values: v,
}) })
} }

View File

@ -5,6 +5,7 @@ import (
"log" "log"
"testing" "testing"
"github.com/v2ray/v2ray-core/common/serial"
v2testing "github.com/v2ray/v2ray-core/testing" v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert" "github.com/v2ray/v2ray-core/testing/assert"
) )
@ -28,11 +29,11 @@ func TestStreamLogger(t *testing.T) {
infoLogger = &stdOutLogWriter{ infoLogger = &stdOutLogWriter{
logger: log.New(buffer, "", 0), logger: log.New(buffer, "", 0),
} }
Info("Test %s Format", "Stream Logger") Info("Test ", "Stream Logger", " Format")
assert.Bytes(buffer.Bytes()).Equals([]byte("[Info]Test Stream Logger Format\n")) assert.StringLiteral(string(buffer.Bytes())).Equals("[Info]Test Stream Logger Format\n")
buffer.Reset() buffer.Reset()
errorLogger = infoLogger errorLogger = infoLogger
Error("Test No Format") Error("Test ", serial.StringLiteral("literal"), " Format")
assert.Bytes(buffer.Bytes()).Equals([]byte("[Error]Test No Format\n")) assert.StringLiteral(string(buffer.Bytes())).Equals("[Error]Test literal Format\n")
} }

View File

@ -46,7 +46,7 @@ func IPAddress(ip []byte) Address {
} }
return &addr return &addr
default: default:
log.Error("Invalid IP format: %v", ip) log.Error("Invalid IP format: ", ip)
return nil return nil
} }
} }

View File

@ -20,7 +20,7 @@ func (this *PortRange) UnmarshalJSON(data []byte) error {
err := json.Unmarshal(data, &maybeint) err := json.Unmarshal(data, &maybeint)
if err == nil { if err == nil {
if maybeint <= 0 || maybeint >= 65535 { if maybeint <= 0 || maybeint >= 65535 {
log.Error("Invalid port [%s]", string(data)) log.Error("Invalid port [", string(data), "]")
return InvalidPortRange return InvalidPortRange
} }
this.From = Port(maybeint) this.From = Port(maybeint)
@ -35,7 +35,7 @@ func (this *PortRange) UnmarshalJSON(data []byte) error {
if len(pair) == 1 { if len(pair) == 1 {
value, err := strconv.Atoi(pair[0]) value, err := strconv.Atoi(pair[0])
if err != nil || value <= 0 || value >= 65535 { if err != nil || value <= 0 || value >= 65535 {
log.Error("Invalid from port %s", pair[0]) log.Error("Invalid from port ", pair[0])
return InvalidPortRange return InvalidPortRange
} }
this.From = Port(value) this.From = Port(value)
@ -44,20 +44,20 @@ func (this *PortRange) UnmarshalJSON(data []byte) error {
} else if len(pair) == 2 { } else if len(pair) == 2 {
from, err := strconv.Atoi(pair[0]) from, err := strconv.Atoi(pair[0])
if err != nil || from <= 0 || from >= 65535 { if err != nil || from <= 0 || from >= 65535 {
log.Error("Invalid from port %s", pair[0]) log.Error("Invalid from port ", pair[0])
return InvalidPortRange return InvalidPortRange
} }
this.From = Port(from) this.From = Port(from)
to, err := strconv.Atoi(pair[1]) to, err := strconv.Atoi(pair[1])
if err != nil || to <= 0 || to >= 65535 { if err != nil || to <= 0 || to >= 65535 {
log.Error("Invalid to port %s", pair[1]) log.Error("Invalid to port ", pair[1])
return InvalidPortRange return InvalidPortRange
} }
this.To = Port(to) this.To = Port(to)
if this.From > this.To { if this.From > this.To {
log.Error("Invalid port range %d -> %d", this.From, this.To) log.Error("Invalid port range ", this.From, " -> ", this.To)
return InvalidPortRange return InvalidPortRange
} }
return nil return nil

View File

@ -74,7 +74,7 @@ func (this *DokodemoDoor) ListenUDP(port v2net.Port) error {
Zone: "", Zone: "",
}) })
if err != nil { if err != nil {
log.Error("Dokodemo failed to listen on port %d: %v", port, err) log.Error("Dokodemo failed to listen on port ", port, ": ", err)
return err return err
} }
this.udpMutex.Lock() this.udpMutex.Lock()
@ -97,7 +97,7 @@ func (this *DokodemoDoor) handleUDPPackets() {
buffer.Slice(0, nBytes) buffer.Slice(0, nBytes)
if err != nil { if err != nil {
buffer.Release() buffer.Release()
log.Error("Dokodemo failed to read from UDP: %v", err) log.Error("Dokodemo failed to read from UDP: ", err)
return return
} }
@ -124,7 +124,7 @@ func (this *DokodemoDoor) ListenTCP(port v2net.Port) error {
Zone: "", Zone: "",
}) })
if err != nil { if err != nil {
log.Error("Dokodemo failed to listen on port %d: %v", port, err) log.Error("Dokodemo failed to listen on port ", port, ": ", err)
return err return err
} }
this.tcpMutex.Lock() this.tcpMutex.Lock()
@ -144,7 +144,7 @@ func (this *DokodemoDoor) AcceptTCPConnections() {
} }
connection, err := this.tcpListener.AcceptTCP() connection, err := this.tcpListener.AcceptTCP()
if err != nil { if err != nil {
log.Error("Dokodemo failed to accept new connections: %v", err) log.Error("Dokodemo failed to accept new connections: ", err)
return err return err
} }
go this.HandleTCPConnection(connection) go this.HandleTCPConnection(connection)

View File

@ -17,7 +17,7 @@ type FreedomConnection struct {
} }
func (this *FreedomConnection) Dispatch(firstPacket v2net.Packet, ray ray.OutboundRay) error { func (this *FreedomConnection) Dispatch(firstPacket v2net.Packet, ray ray.OutboundRay) error {
log.Info("Freedom: Opening connection to %s", firstPacket.Destination().String()) log.Info("Freedom: Opening connection to ", firstPacket.Destination())
var conn net.Conn var conn net.Conn
err := retry.Timed(5, 100).On(func() error { err := retry.Timed(5, 100).On(func() error {
@ -30,7 +30,7 @@ func (this *FreedomConnection) Dispatch(firstPacket v2net.Packet, ray ray.Outbou
}) })
if err != nil { if err != nil {
close(ray.OutboundOutput()) close(ray.OutboundOutput())
log.Error("Freedom: Failed to open connection: %s : %v", firstPacket.Destination().String(), err) log.Error("Freedom: Failed to open connection to ", firstPacket.Destination(), ": ", err)
return err return err
} }
defer conn.Close() defer conn.Close()
@ -60,7 +60,7 @@ func (this *FreedomConnection) Dispatch(firstPacket v2net.Packet, ray ray.Outbou
defer close(output) defer close(output)
response, err := v2net.ReadFrom(conn, nil) response, err := v2net.ReadFrom(conn, nil)
log.Info("Freedom receives %d bytes from %s", response.Len(), conn.RemoteAddr().String()) log.Info("Freedom receives ", response.Len(), " bytes from ", conn.RemoteAddr())
if response.Len() > 0 { if response.Len() > 0 {
output <- response output <- response
} else { } else {

View File

@ -68,7 +68,7 @@ func (this *HttpProxyServer) accept() {
} }
tcpConn, err := this.tcpListener.AcceptTCP() tcpConn, err := this.tcpListener.AcceptTCP()
if err != nil { if err != nil {
log.Error("Failed to accept HTTP connection: %v", err) log.Error("Failed to accept HTTP connection: ", err)
return err return err
} }
go this.handleConnection(tcpConn) go this.handleConnection(tcpConn)
@ -106,10 +106,10 @@ func (this *HttpProxyServer) handleConnection(conn *net.TCPConn) {
request, err := http.ReadRequest(reader) request, err := http.ReadRequest(reader)
if err != nil { if err != nil {
log.Warning("Failed to read http request: %v", err) log.Warning("Failed to read http request: ", err)
return return
} }
log.Info("Request to Method [%s] Host [%s] with URL [%s]", request.Method, request.Host, request.URL.String()) log.Info("Request to Method [", request.Method, "] Host [", request.Host, "] with URL [", request.URL, "]")
defaultPort := v2net.Port(80) defaultPort := v2net.Port(80)
if strings.ToLower(request.URL.Scheme) == "https" { if strings.ToLower(request.URL.Scheme) == "https" {
defaultPort = v2net.Port(443) defaultPort = v2net.Port(443)
@ -120,7 +120,7 @@ func (this *HttpProxyServer) handleConnection(conn *net.TCPConn) {
} }
dest, err := parseHost(host, defaultPort) dest, err := parseHost(host, defaultPort)
if err != nil { if err != nil {
log.Warning("Malformed proxy host (%s): %v", host, err) log.Warning("Malformed proxy host (", host, "): ", err)
return return
} }
if strings.ToUpper(request.Method) == "CONNECT" { if strings.ToUpper(request.Method) == "CONNECT" {
@ -222,7 +222,7 @@ func (this *HttpProxyServer) handlePlainHTTP(request *http.Request, dest v2net.D
requestBuffer := alloc.NewBuffer().Clear() // Don't release this buffer as it is passed into a Packet. requestBuffer := alloc.NewBuffer().Clear() // Don't release this buffer as it is passed into a Packet.
request.Write(requestBuffer) request.Write(requestBuffer)
log.Debug("Request to remote:\n%s", string(requestBuffer.Value)) log.Debug("Request to remote:\n", string(requestBuffer.Value))
packet := v2net.NewPacket(dest, requestBuffer, true) packet := v2net.NewPacket(dest, requestBuffer, true)
ray := this.space.PacketDispatcher().DispatchToOutbound(packet) ray := this.space.PacketDispatcher().DispatchToOutbound(packet)

View File

@ -41,7 +41,7 @@ func init() {
} else if rawConfig.AuthMethod == AuthMethodUserPass { } else if rawConfig.AuthMethod == AuthMethodUserPass {
socksConfig.AuthType = AuthTypePassword socksConfig.AuthType = AuthTypePassword
} else { } else {
log.Error("Socks: Unknown auth method: %s", rawConfig.AuthMethod) log.Error("Socks: Unknown auth method: ", rawConfig.AuthMethod)
return nil, internal.ErrorBadConfiguration return nil, internal.ErrorBadConfiguration
} }

View File

@ -49,7 +49,7 @@ func ReadAuthentication(reader io.Reader) (auth Socks5AuthenticationRequest, aut
return return
} }
if nBytes < 2 { if nBytes < 2 {
log.Info("Socks: expected 2 bytes read, but only %d bytes read", nBytes) log.Warning("Socks: expected 2 bytes read, but only ", nBytes, " bytes read")
err = transport.CorruptedPacket err = transport.CorruptedPacket
return return
} }
@ -65,20 +65,20 @@ func ReadAuthentication(reader io.Reader) (auth Socks5AuthenticationRequest, aut
auth.version = buffer.Value[0] auth.version = buffer.Value[0]
if auth.version != socksVersion { if auth.version != socksVersion {
log.Warning("Socks: Unknown protocol version %d", auth.version) log.Warning("Socks: Unknown protocol version ", auth.version)
err = proxy.InvalidProtocolVersion err = proxy.InvalidProtocolVersion
return return
} }
auth.nMethods = buffer.Value[1] auth.nMethods = buffer.Value[1]
if auth.nMethods <= 0 { if auth.nMethods <= 0 {
log.Info("Socks: Zero length of authentication methods") log.Warning("Socks: Zero length of authentication methods")
err = transport.CorruptedPacket err = transport.CorruptedPacket
return return
} }
if nBytes-2 != int(auth.nMethods) { if nBytes-2 != int(auth.nMethods) {
log.Info("Socks: Unmatching number of auth methods, expecting %d, but got %d", auth.nMethods, nBytes) log.Warning("Socks: Unmatching number of auth methods, expecting ", auth.nMethods, ", but got ", nBytes)
err = transport.CorruptedPacket err = transport.CorruptedPacket
return return
} }
@ -227,7 +227,7 @@ func ReadRequest(reader io.Reader) (request *Socks5Request, err error) {
} }
if nBytes != int(domainLength) { if nBytes != int(domainLength) {
log.Info("Socks: Unable to read domain with %d bytes, expecting %d bytes", nBytes, domainLength) log.Warning("Socks: Unable to read domain with ", nBytes, " bytes, expecting ", domainLength, " bytes")
err = transport.CorruptedPacket err = transport.CorruptedPacket
return return
} }
@ -242,7 +242,7 @@ func ReadRequest(reader io.Reader) (request *Socks5Request, err error) {
return return
} }
default: default:
log.Info("Socks: Unexpected address type %d", request.AddrType) log.Warning("Socks: Unexpected address type ", request.AddrType)
err = transport.CorruptedPacket err = transport.CorruptedPacket
return return
} }

View File

@ -83,7 +83,7 @@ func ReadUDPRequest(packet []byte) (*Socks5UDPRequest, error) {
} }
dataBegin = 5 + domainLength + 2 dataBegin = 5 + domainLength + 2
default: default:
log.Warning("Unknown address type %d", addrType) log.Warning("Unknown address type ", addrType)
return nil, ErrorUnknownAddressType return nil, ErrorUnknownAddressType
} }

View File

@ -63,7 +63,7 @@ func (this *SocksServer) Listen(port v2net.Port) error {
Zone: "", Zone: "",
}) })
if err != nil { if err != nil {
log.Error("Socks: failed to listen on port %d: %v", port, err) log.Error("Socks: failed to listen on port ", port, ": ", err)
return err return err
} }
this.accepting = true this.accepting = true
@ -87,7 +87,7 @@ func (this *SocksServer) AcceptConnections() {
} }
connection, err := this.tcpListener.AcceptTCP() connection, err := this.tcpListener.AcceptTCP()
if err != nil { if err != nil {
log.Error("Socks: failed to accept new connection %v", err) log.Error("Socks: failed to accept new connection: ", err)
return err return err
} }
go this.HandleConnection(connection) go this.HandleConnection(connection)
@ -103,7 +103,7 @@ func (this *SocksServer) HandleConnection(connection *net.TCPConn) error {
auth, auth4, err := protocol.ReadAuthentication(reader) auth, auth4, err := protocol.ReadAuthentication(reader)
if err != nil && err != protocol.Socks4Downgrade { if err != nil && err != protocol.Socks4Downgrade {
log.Error("Socks: failed to read authentication: %v", err) log.Error("Socks: failed to read authentication: ", err)
return err return err
} }
@ -124,7 +124,7 @@ func (this *SocksServer) handleSocks5(reader *v2net.TimeOutReader, writer io.Wri
authResponse := protocol.NewAuthenticationResponse(protocol.AuthNoMatchingMethod) authResponse := protocol.NewAuthenticationResponse(protocol.AuthNoMatchingMethod)
err := protocol.WriteAuthentication(writer, authResponse) err := protocol.WriteAuthentication(writer, authResponse)
if err != nil { if err != nil {
log.Error("Socks: failed to write authentication: %v", err) log.Error("Socks: failed to write authentication: ", err)
return err return err
} }
log.Warning("Socks: client doesn't support allowed any auth methods.") log.Warning("Socks: client doesn't support allowed any auth methods.")
@ -134,13 +134,13 @@ func (this *SocksServer) handleSocks5(reader *v2net.TimeOutReader, writer io.Wri
authResponse := protocol.NewAuthenticationResponse(expectedAuthMethod) authResponse := protocol.NewAuthenticationResponse(expectedAuthMethod)
err := protocol.WriteAuthentication(writer, authResponse) err := protocol.WriteAuthentication(writer, authResponse)
if err != nil { if err != nil {
log.Error("Socks: failed to write authentication: %v", err) log.Error("Socks: failed to write authentication: ", err)
return err return err
} }
if this.config.AuthType == AuthTypePassword { if this.config.AuthType == AuthTypePassword {
upRequest, err := protocol.ReadUserPassRequest(reader) upRequest, err := protocol.ReadUserPassRequest(reader)
if err != nil { if err != nil {
log.Error("Socks: failed to read username and password: %v", err) log.Error("Socks: failed to read username and password: ", err)
return err return err
} }
status := byte(0) status := byte(0)
@ -150,18 +150,18 @@ func (this *SocksServer) handleSocks5(reader *v2net.TimeOutReader, writer io.Wri
upResponse := protocol.NewSocks5UserPassResponse(status) upResponse := protocol.NewSocks5UserPassResponse(status)
err = protocol.WriteUserPassResponse(writer, upResponse) err = protocol.WriteUserPassResponse(writer, upResponse)
if err != nil { if err != nil {
log.Error("Socks: failed to write user pass response: %v", err) log.Error("Socks: failed to write user pass response: ", err)
return err return err
} }
if status != byte(0) { if status != byte(0) {
log.Warning("Socks: Invalid user account: %s", upRequest.AuthDetail()) log.Warning("Socks: Invalid user account: ", upRequest.AuthDetail())
return proxy.InvalidAuthentication return proxy.InvalidAuthentication
} }
} }
request, err := protocol.ReadRequest(reader) request, err := protocol.ReadRequest(reader)
if err != nil { if err != nil {
log.Error("Socks: failed to read request: %v", err) log.Error("Socks: failed to read request: ", err)
return err return err
} }
@ -180,10 +180,10 @@ func (this *SocksServer) handleSocks5(reader *v2net.TimeOutReader, writer io.Wri
_, err = writer.Write(responseBuffer.Value) _, err = writer.Write(responseBuffer.Value)
responseBuffer.Release() responseBuffer.Release()
if err != nil { if err != nil {
log.Error("Socks: failed to write response: %v", err) log.Error("Socks: failed to write response: ", err)
return err return err
} }
log.Warning("Socks: Unsupported socks command %d", request.Command) log.Warning("Socks: Unsupported socks command ", request.Command)
return UnsupportedSocksCommand return UnsupportedSocksCommand
} }
@ -199,12 +199,12 @@ func (this *SocksServer) handleSocks5(reader *v2net.TimeOutReader, writer io.Wri
_, err = writer.Write(responseBuffer.Value) _, err = writer.Write(responseBuffer.Value)
responseBuffer.Release() responseBuffer.Release()
if err != nil { if err != nil {
log.Error("Socks: failed to write response: %v", err) log.Error("Socks: failed to write response: ", err)
return err return err
} }
dest := request.Destination() dest := request.Destination()
log.Info("Socks: TCP Connect request to %s", dest.String()) log.Info("Socks: TCP Connect request to ", dest)
packet := v2net.NewPacket(dest, nil, true) packet := v2net.NewPacket(dest, nil, true)
this.transport(reader, writer, packet) this.transport(reader, writer, packet)
@ -233,7 +233,7 @@ func (this *SocksServer) handleUDP(reader *v2net.TimeOutReader, writer io.Writer
responseBuffer.Release() responseBuffer.Release()
if err != nil { if err != nil {
log.Error("Socks: failed to write response: %v", err) log.Error("Socks: failed to write response: ", err)
return err return err
} }
@ -260,7 +260,7 @@ func (this *SocksServer) handleSocks4(reader io.Reader, writer io.Writer, auth p
responseBuffer.Release() responseBuffer.Release()
if result == protocol.Socks4RequestRejected { if result == protocol.Socks4RequestRejected {
log.Warning("Socks: Unsupported socks 4 command %d", auth.Command) log.Warning("Socks: Unsupported socks 4 command ", auth.Command)
return UnsupportedSocksCommand return UnsupportedSocksCommand
} }

View File

@ -17,7 +17,7 @@ func (this *SocksServer) ListenUDP(port v2net.Port) error {
} }
conn, err := net.ListenUDP("udp", addr) conn, err := net.ListenUDP("udp", addr)
if err != nil { if err != nil {
log.Error("Socks: failed to listen UDP on port %d: %v", port, err) log.Error("Socks: failed to listen UDP on port ", port, ": ", err)
return err return err
} }
this.udpMutex.Lock() this.udpMutex.Lock()
@ -40,15 +40,15 @@ func (this *SocksServer) AcceptPackets() error {
nBytes, addr, err := this.udpConn.ReadFromUDP(buffer.Value) nBytes, addr, err := this.udpConn.ReadFromUDP(buffer.Value)
this.udpMutex.RUnlock() this.udpMutex.RUnlock()
if err != nil { if err != nil {
log.Error("Socks: failed to read UDP packets: %v", err) log.Error("Socks: failed to read UDP packets: ", err)
buffer.Release() buffer.Release()
continue continue
} }
log.Info("Socks: Client UDP connection from %v", addr) log.Info("Socks: Client UDP connection from ", addr)
request, err := protocol.ReadUDPRequest(buffer.Value[:nBytes]) request, err := protocol.ReadUDPRequest(buffer.Value[:nBytes])
buffer.Release() buffer.Release()
if err != nil { if err != nil {
log.Error("Socks: failed to parse UDP request: %v", err) log.Error("Socks: failed to parse UDP request: ", err)
continue continue
} }
if request.Data == nil || request.Data.Len() == 0 { if request.Data == nil || request.Data.Len() == 0 {
@ -62,7 +62,7 @@ func (this *SocksServer) AcceptPackets() error {
} }
udpPacket := v2net.NewPacket(request.Destination(), request.Data, false) udpPacket := v2net.NewPacket(request.Destination(), request.Data, false)
log.Info("Socks: Send packet to %s with %d bytes", udpPacket.Destination().String(), request.Data.Len()) log.Info("Socks: Send packet to ", udpPacket.Destination(), " with ", request.Data.Len(), " bytes")
go this.handlePacket(udpPacket, addr, request.Address, request.Port) go this.handlePacket(udpPacket, addr, request.Address, request.Port)
} }
return nil return nil
@ -79,7 +79,7 @@ func (this *SocksServer) handlePacket(packet v2net.Packet, clientAddr *net.UDPAd
Port: port, Port: port,
Data: data, Data: data,
} }
log.Info("Socks: Writing back UDP response with %d bytes from %s to %s", data.Len(), targetAddr.String(), clientAddr.String()) log.Info("Socks: Writing back UDP response with ", data.Len(), " bytes from ", targetAddr, " to ", clientAddr)
udpMessage := alloc.NewSmallBuffer().Clear() udpMessage := alloc.NewSmallBuffer().Clear()
response.Write(udpMessage) response.Write(udpMessage)
@ -94,7 +94,7 @@ func (this *SocksServer) handlePacket(packet v2net.Packet, clientAddr *net.UDPAd
udpMessage.Release() udpMessage.Release()
response.Data.Release() response.Data.Release()
if err != nil { if err != nil {
log.Error("Socks: failed to write UDP message (%d bytes) to %s: %v", nBytes, clientAddr.String(), err) log.Error("Socks: failed to write UDP message (", nBytes, " bytes) to ", clientAddr, ": ", err)
} }
} }
} }

View File

@ -55,7 +55,7 @@ func (this *VMessInboundHandler) Listen(port v2net.Port) error {
Zone: "", Zone: "",
}) })
if err != nil { if err != nil {
log.Error("Unable to listen tcp port %d: %v", port, err) log.Error("Unable to listen tcp port ", port, ": ", err)
return err return err
} }
this.accepting = true this.accepting = true
@ -76,7 +76,7 @@ func (this *VMessInboundHandler) AcceptConnections() error {
} }
connection, err := this.listener.AcceptTCP() connection, err := this.listener.AcceptTCP()
if err != nil { if err != nil {
log.Error("Failed to accpet connection: %s", err.Error()) log.Error("Failed to accpet connection: ", err)
return err return err
} }
go this.HandleConnection(connection) go this.HandleConnection(connection)
@ -96,11 +96,11 @@ func (this *VMessInboundHandler) HandleConnection(connection *net.TCPConn) error
request, err := requestReader.Read(connReader) request, err := requestReader.Read(connReader)
if err != nil { if err != nil {
log.Access(connection.RemoteAddr().String(), "", log.AccessRejected, err.Error()) log.Access(connection.RemoteAddr().String(), "", log.AccessRejected, err.Error())
log.Warning("VMessIn: Invalid request from (%s): %v", connection.RemoteAddr().String(), err) log.Warning("VMessIn: Invalid request from ", connection.RemoteAddr(), ": ", err)
return err return err
} }
log.Access(connection.RemoteAddr().String(), request.Address.String(), log.AccessAccepted, "") log.Access(connection.RemoteAddr().String(), request.Address.String(), log.AccessAccepted, "")
log.Debug("VMessIn: Received request for %s", request.Address.String()) log.Debug("VMessIn: Received request for ", request.Address)
ray := this.space.PacketDispatcher().DispatchToOutbound(v2net.NewPacket(request.Destination(), nil, true)) ray := this.space.PacketDispatcher().DispatchToOutbound(v2net.NewPacket(request.Destination(), nil, true))
input := ray.InboundInput() input := ray.InboundInput()
@ -118,7 +118,7 @@ func (this *VMessInboundHandler) HandleConnection(connection *net.TCPConn) error
aesStream, err := v2crypto.NewAesEncryptionStream(responseKey[:], responseIV[:]) aesStream, err := v2crypto.NewAesEncryptionStream(responseKey[:], responseIV[:])
if err != nil { if err != nil {
log.Error("VMessIn: Failed to create AES decryption stream: %v", err) log.Error("VMessIn: Failed to create AES decryption stream: ", err)
close(input) close(input)
return err return err
} }
@ -152,7 +152,7 @@ func handleInput(request *protocol.VMessRequest, reader io.Reader, input chan<-
aesStream, err := v2crypto.NewAesDecryptionStream(request.RequestKey, request.RequestIV) aesStream, err := v2crypto.NewAesDecryptionStream(request.RequestKey, request.RequestIV)
if err != nil { if err != nil {
log.Error("VMessIn: Failed to create AES decryption stream: %v", err) log.Error("VMessIn: Failed to create AES decryption stream: ", err)
return return
} }
requestReader := v2crypto.NewCryptionReader(aesStream, reader) requestReader := v2crypto.NewCryptionReader(aesStream, reader)

View File

@ -67,13 +67,13 @@ func startCommunicate(request *protocol.VMessRequest, dest v2net.Destination, ra
Port: int(dest.Port()), Port: int(dest.Port()),
}) })
if err != nil { if err != nil {
log.Error("Failed to open %s: %v", dest.String(), err) log.Error("Failed to open ", dest, ": ", err)
if ray != nil { if ray != nil {
close(ray.OutboundOutput()) close(ray.OutboundOutput())
} }
return err return err
} }
log.Info("VMessOut: Tunneling request to %s via %s", request.Address.String(), dest.String()) log.Info("VMessOut: Tunneling request to ", request.Address, " via ", dest)
defer conn.Close() defer conn.Close()
@ -97,7 +97,7 @@ func handleRequest(conn net.Conn, request *protocol.VMessRequest, firstPacket v2
defer finish.Unlock() defer finish.Unlock()
aesStream, err := v2crypto.NewAesEncryptionStream(request.RequestKey[:], request.RequestIV[:]) aesStream, err := v2crypto.NewAesEncryptionStream(request.RequestKey[:], request.RequestIV[:])
if err != nil { if err != nil {
log.Error("VMessOut: Failed to create AES encryption stream: %v", err) log.Error("VMessOut: Failed to create AES encryption stream: ", err)
return return
} }
encryptRequestWriter := v2crypto.NewCryptionWriter(aesStream, conn) encryptRequestWriter := v2crypto.NewCryptionWriter(aesStream, conn)
@ -106,7 +106,7 @@ func handleRequest(conn net.Conn, request *protocol.VMessRequest, firstPacket v2
defer buffer.Release() defer buffer.Release()
buffer, err = request.ToBytes(protocol.NewRandomTimestampGenerator(protocol.Timestamp(time.Now().Unix()), 30), buffer) buffer, err = request.ToBytes(protocol.NewRandomTimestampGenerator(protocol.Timestamp(time.Now().Unix()), 30), buffer)
if err != nil { if err != nil {
log.Error("VMessOut: Failed to serialize VMess request: %v", err) log.Error("VMessOut: Failed to serialize VMess request: ", err)
return return
} }
@ -129,7 +129,7 @@ func handleRequest(conn net.Conn, request *protocol.VMessRequest, firstPacket v2
_, err = conn.Write(buffer.Value) _, err = conn.Write(buffer.Value)
if err != nil { if err != nil {
log.Error("VMessOut: Failed to write VMess request: %v", err) log.Error("VMessOut: Failed to write VMess request: ", err)
return return
} }
@ -151,14 +151,14 @@ func handleResponse(conn net.Conn, request *protocol.VMessRequest, output chan<-
aesStream, err := v2crypto.NewAesDecryptionStream(responseKey[:], responseIV[:]) aesStream, err := v2crypto.NewAesDecryptionStream(responseKey[:], responseIV[:])
if err != nil { if err != nil {
log.Error("VMessOut: Failed to create AES encryption stream: %v", err) log.Error("VMessOut: Failed to create AES encryption stream: ", err)
return return
} }
decryptResponseReader := v2crypto.NewCryptionReader(aesStream, conn) decryptResponseReader := v2crypto.NewCryptionReader(aesStream, conn)
buffer, err := v2net.ReadFrom(decryptResponseReader, nil) buffer, err := v2net.ReadFrom(decryptResponseReader, nil)
if err != nil { if err != nil {
log.Error("VMessOut: Failed to read VMess response (%d bytes): %v", buffer.Len(), err) log.Error("VMessOut: Failed to read VMess response (", buffer.Len(), " bytes): ", err)
buffer.Release() buffer.Release()
return return
} }
@ -166,7 +166,7 @@ func handleResponse(conn net.Conn, request *protocol.VMessRequest, output chan<-
log.Warning("VMessOut: unexepcted response header. The connection is probably hijacked.") log.Warning("VMessOut: unexepcted response header. The connection is probably hijacked.")
return return
} }
log.Info("VMessOut received %d bytes from %s", buffer.Len()-4, conn.RemoteAddr().String()) log.Info("VMessOut received ", buffer.Len()-4, " bytes from ", conn.RemoteAddr())
responseBegin := 4 responseBegin := 4
if buffer.Value[2] != 0 { if buffer.Value[2] != 0 {

View File

@ -71,7 +71,7 @@ func (this *VMessRequestReader) Read(reader io.Reader) (*VMessRequest, error) {
nBytes, err := v2net.ReadAllBytes(reader, buffer.Value[:vmess.IDBytesLen]) nBytes, err := v2net.ReadAllBytes(reader, buffer.Value[:vmess.IDBytesLen])
if err != nil { if err != nil {
log.Debug("VMess: Failed to read request ID (%d bytes): %v", nBytes, err) log.Debug("VMess: Failed to read request ID (", nBytes, " bytes): ", err)
return nil, err return nil, err
} }
@ -85,7 +85,7 @@ func (this *VMessRequestReader) Read(reader io.Reader) (*VMessRequest, error) {
iv := timestampHash.Sum(nil) iv := timestampHash.Sum(nil)
aesStream, err := v2crypto.NewAesDecryptionStream(userObj.ID.CmdKey(), iv) aesStream, err := v2crypto.NewAesDecryptionStream(userObj.ID.CmdKey(), iv)
if err != nil { if err != nil {
log.Debug("VMess: Failed to create AES stream: %v", err) log.Debug("VMess: Failed to create AES stream: ", err)
return nil, err return nil, err
} }
@ -93,7 +93,7 @@ func (this *VMessRequestReader) Read(reader io.Reader) (*VMessRequest, error) {
nBytes, err = v2net.ReadAllBytes(decryptor, buffer.Value[:41]) nBytes, err = v2net.ReadAllBytes(decryptor, buffer.Value[:41])
if err != nil { if err != nil {
log.Debug("VMess: Failed to read request header (%d bytes): %v", nBytes, err) log.Debug("VMess: Failed to read request header (", nBytes, " bytes): ", err)
return nil, err return nil, err
} }
bufferLen := nBytes bufferLen := nBytes
@ -104,7 +104,7 @@ func (this *VMessRequestReader) Read(reader io.Reader) (*VMessRequest, error) {
} }
if request.Version != Version { if request.Version != Version {
log.Warning("VMess: Invalid protocol version %d", request.Version) log.Warning("VMess: Invalid protocol version ", request.Version)
return nil, proxy.InvalidProtocolVersion return nil, proxy.InvalidProtocolVersion
} }
@ -120,7 +120,7 @@ func (this *VMessRequestReader) Read(reader io.Reader) (*VMessRequest, error) {
nBytes, err = v2net.ReadAllBytes(decryptor, buffer.Value[41:45]) // 4 bytes nBytes, err = v2net.ReadAllBytes(decryptor, buffer.Value[41:45]) // 4 bytes
bufferLen += 4 bufferLen += 4
if err != nil { if err != nil {
log.Debug("VMess: Failed to read target IPv4 (%d bytes): %v", nBytes, err) log.Debug("VMess: Failed to read target IPv4 (", nBytes, " bytes): ", err)
return nil, err return nil, err
} }
request.Address = v2net.IPAddress(buffer.Value[41:45]) request.Address = v2net.IPAddress(buffer.Value[41:45])
@ -128,14 +128,14 @@ func (this *VMessRequestReader) Read(reader io.Reader) (*VMessRequest, error) {
nBytes, err = v2net.ReadAllBytes(decryptor, buffer.Value[41:57]) // 16 bytes nBytes, err = v2net.ReadAllBytes(decryptor, buffer.Value[41:57]) // 16 bytes
bufferLen += 16 bufferLen += 16
if err != nil { if err != nil {
log.Debug("VMess: Failed to read target IPv6 (%d bytes): %v", nBytes, err) log.Debug("VMess: Failed to read target IPv6 (", nBytes, " bytes): ", nBytes, err)
return nil, err return nil, err
} }
request.Address = v2net.IPAddress(buffer.Value[41:57]) request.Address = v2net.IPAddress(buffer.Value[41:57])
case addrTypeDomain: case addrTypeDomain:
nBytes, err = v2net.ReadAllBytes(decryptor, buffer.Value[41:42]) nBytes, err = v2net.ReadAllBytes(decryptor, buffer.Value[41:42])
if err != nil { if err != nil {
log.Debug("VMess: Failed to read target domain (%d bytes): %v", nBytes, err) log.Debug("VMess: Failed to read target domain (", nBytes, " bytes): ", nBytes, err)
return nil, err return nil, err
} }
domainLength := int(buffer.Value[41]) domainLength := int(buffer.Value[41])
@ -144,7 +144,7 @@ func (this *VMessRequestReader) Read(reader io.Reader) (*VMessRequest, error) {
} }
nBytes, err = v2net.ReadAllBytes(decryptor, buffer.Value[42:42+domainLength]) nBytes, err = v2net.ReadAllBytes(decryptor, buffer.Value[42:42+domainLength])
if err != nil { if err != nil {
log.Debug("VMess: Failed to read target domain (%d bytes): %v", nBytes, err) log.Debug("VMess: Failed to read target domain (", nBytes, " bytes): ", nBytes, err)
return nil, err return nil, err
} }
bufferLen += 1 + domainLength bufferLen += 1 + domainLength
@ -154,7 +154,7 @@ func (this *VMessRequestReader) Read(reader io.Reader) (*VMessRequest, error) {
nBytes, err = v2net.ReadAllBytes(decryptor, buffer.Value[bufferLen:bufferLen+4]) nBytes, err = v2net.ReadAllBytes(decryptor, buffer.Value[bufferLen:bufferLen+4])
if err != nil { if err != nil {
log.Debug("VMess: Failed to read checksum (%d bytes): %v", nBytes, err) log.Debug("VMess: Failed to read checksum (", nBytes, " bytes): ", nBytes, err)
return nil, err return nil, err
} }

View File

@ -65,7 +65,7 @@ func main() {
} }
config, err := point.LoadConfig(configFile) config, err := point.LoadConfig(configFile)
if err != nil { if err != nil {
log.Error("Failed to read config file (%s): %v", configFile, err) log.Error("Failed to read config file (", configFile, "): ", configFile, err)
return return
} }
@ -75,13 +75,13 @@ func main() {
vPoint, err := point.NewPoint(config) vPoint, err := point.NewPoint(config)
if err != nil { if err != nil {
log.Error("Failed to create Point server: %v", err) log.Error("Failed to create Point server: ", err)
return return
} }
err = vPoint.Start() err = vPoint.Start()
if err != nil { if err != nil {
log.Error("Error starting Point server: %v", err) log.Error("Error starting Point server: ", err)
return return
} }

View File

@ -138,14 +138,14 @@ func JsonLoadConfig(file string) (*Config, error) {
fixedFile := os.ExpandEnv(file) fixedFile := os.ExpandEnv(file)
rawConfig, err := ioutil.ReadFile(fixedFile) rawConfig, err := ioutil.ReadFile(fixedFile)
if err != nil { if err != nil {
log.Error("Failed to read server config file (%s): %v", file, err) log.Error("Failed to read server config file (", file, "): ", file, err)
return nil, err return nil, err
} }
jsonConfig := &Config{} jsonConfig := &Config{}
err = json.Unmarshal(rawConfig, jsonConfig) err = json.Unmarshal(rawConfig, jsonConfig)
if err != nil { if err != nil {
log.Error("Failed to load server config: %v", err) log.Error("Failed to load server config: ", err)
return nil, err return nil, err
} }

View File

@ -28,7 +28,7 @@ func (this *InboundDetourHandler) Initialize() error {
ichConfig := this.config.Settings ichConfig := this.config.Settings
ich, err := proxyrepo.CreateInboundConnectionHandler(this.config.Protocol, this.space, ichConfig) ich, err := proxyrepo.CreateInboundConnectionHandler(this.config.Protocol, this.space, ichConfig)
if err != nil { if err != nil {
log.Error("Failed to create inbound connection handler: %v", err) log.Error("Failed to create inbound connection handler: ", err)
return err return err
} }
this.ich = append(this.ich, &InboundConnectionHandlerWithPort{ this.ich = append(this.ich, &InboundConnectionHandlerWithPort{
@ -51,7 +51,7 @@ func (this *InboundDetourHandler) Start() error {
err := retry.Timed(100 /* times */, 100 /* ms */).On(func() error { err := retry.Timed(100 /* times */, 100 /* ms */).On(func() error {
err := ich.handler.Listen(ich.port) err := ich.handler.Listen(ich.port)
if err != nil { if err != nil {
log.Error("Failed to start inbound detour on port %d: %v", ich.port, err) log.Error("Failed to start inbound detour on port ", ich.port, ": ", err)
return err return err
} }
return nil return nil

View File

@ -58,7 +58,7 @@ func NewPoint(pConfig *Config) (*Point, error) {
ichConfig := pConfig.InboundConfig.Settings ichConfig := pConfig.InboundConfig.Settings
ich, err := proxyrepo.CreateInboundConnectionHandler(pConfig.InboundConfig.Protocol, vpoint.space.ForContext("vpoint-default-inbound"), ichConfig) ich, err := proxyrepo.CreateInboundConnectionHandler(pConfig.InboundConfig.Protocol, vpoint.space.ForContext("vpoint-default-inbound"), ichConfig)
if err != nil { if err != nil {
log.Error("Failed to create inbound connection handler: %v", err) log.Error("Failed to create inbound connection handler: ", err)
return nil, err return nil, err
} }
vpoint.ich = ich vpoint.ich = ich
@ -66,7 +66,7 @@ func NewPoint(pConfig *Config) (*Point, error) {
ochConfig := pConfig.OutboundConfig.Settings ochConfig := pConfig.OutboundConfig.Settings
och, err := proxyrepo.CreateOutboundConnectionHandler(pConfig.OutboundConfig.Protocol, vpoint.space.ForContext("vpoint-default-outbound"), ochConfig) och, err := proxyrepo.CreateOutboundConnectionHandler(pConfig.OutboundConfig.Protocol, vpoint.space.ForContext("vpoint-default-outbound"), ochConfig)
if err != nil { if err != nil {
log.Error("Failed to create outbound connection handler: %v", err) log.Error("Failed to create outbound connection handler: ", err)
return nil, err return nil, err
} }
vpoint.och = och vpoint.och = och
@ -93,7 +93,7 @@ func NewPoint(pConfig *Config) (*Point, error) {
for _, detourConfig := range outboundDetours { for _, detourConfig := range outboundDetours {
detourHandler, err := proxyrepo.CreateOutboundConnectionHandler(detourConfig.Protocol, vpoint.space.ForContext(detourConfig.Tag), detourConfig.Settings) detourHandler, err := proxyrepo.CreateOutboundConnectionHandler(detourConfig.Protocol, vpoint.space.ForContext(detourConfig.Tag), detourConfig.Settings)
if err != nil { if err != nil {
log.Error("Failed to create detour outbound connection handler: %v", err) log.Error("Failed to create detour outbound connection handler: ", err)
return nil, err return nil, err
} }
vpoint.odh[detourConfig.Tag] = detourHandler vpoint.odh[detourConfig.Tag] = detourHandler
@ -104,7 +104,7 @@ func NewPoint(pConfig *Config) (*Point, error) {
if routerConfig != nil { if routerConfig != nil {
r, err := router.CreateRouter(routerConfig.Strategy, routerConfig.Settings) r, err := router.CreateRouter(routerConfig.Strategy, routerConfig.Settings)
if err != nil { if err != nil {
log.Error("Failed to create router: %v", err) log.Error("Failed to create router: ", err)
return nil, BadConfiguration return nil, BadConfiguration
} }
vpoint.router = r vpoint.router = r
@ -124,7 +124,7 @@ func (this *Point) Close() {
// In the case of any errors, the state of the server is unpredicatable. // In the case of any errors, the state of the server is unpredicatable.
func (this *Point) Start() error { func (this *Point) Start() error {
if this.port <= 0 { if this.port <= 0 {
log.Error("Invalid port %d", this.port) log.Error("Invalid port ", this.port)
return BadConfiguration return BadConfiguration
} }
@ -133,7 +133,7 @@ func (this *Point) Start() error {
if err != nil { if err != nil {
return err return err
} }
log.Warning("Point server started on port %d", this.port) log.Warning("Point server started on port ", this.port)
return nil return nil
}) })
if err != nil { if err != nil {
@ -162,7 +162,7 @@ func (this *Point) DispatchToOutbound(context app.Context, packet v2net.Packet)
if this.router != nil { if this.router != nil {
if tag, err := this.router.TakeDetour(dest); err == nil { if tag, err := this.router.TakeDetour(dest); err == nil {
if handler, found := this.odh[tag]; found { if handler, found := this.odh[tag]; found {
log.Info("Point: Taking detour [%s] for [%s]", tag, dest) log.Info("Point: Taking detour [", tag, "] for [", dest, "]", tag, dest)
dispatcher = handler dispatcher = handler
} }
} }

View File

@ -40,19 +40,19 @@ func InitializeServerSetOnce(testcase string) error {
func InitializeServer(configFile string) error { func InitializeServer(configFile string) error {
config, err := point.LoadConfig(configFile) config, err := point.LoadConfig(configFile)
if err != nil { if err != nil {
log.Error("Failed to read config file (%s): %v", configFile, err) log.Error("Failed to read config file (", configFile, "): ", configFile, err)
return err return err
} }
vPoint, err := point.NewPoint(config) vPoint, err := point.NewPoint(config)
if err != nil { if err != nil {
log.Error("Failed to create Point server: %v", err) log.Error("Failed to create Point server: ", err)
return err return err
} }
err = vPoint.Start() err = vPoint.Start()
if err != nil { if err != nil {
log.Error("Error starting Point server: %v", err) log.Error("Error starting Point server: ", err)
return err return err
} }
runningServers = append(runningServers, vPoint) runningServers = append(runningServers, vPoint)