From 65d5c07533f07dea24995bbc5040c8194dcfcd48 Mon Sep 17 00:00:00 2001 From: v2ray Date: Mon, 18 Jan 2016 12:58:04 +0100 Subject: [PATCH] BytesLiteral.String --- common/net/port_json.go | 3 ++- common/serial/bytes.go | 4 ++++ proxy/http/http.go | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/common/net/port_json.go b/common/net/port_json.go index 8d31baac..4a9c3272 100644 --- a/common/net/port_json.go +++ b/common/net/port_json.go @@ -9,6 +9,7 @@ import ( "strings" "github.com/v2ray/v2ray-core/common/log" + "github.com/v2ray/v2ray-core/common/serial" ) var ( @@ -20,7 +21,7 @@ func (this *PortRange) UnmarshalJSON(data []byte) error { err := json.Unmarshal(data, &maybeint) if err == nil { if maybeint <= 0 || maybeint >= 65535 { - log.Error("Invalid port [", string(data), "]") + log.Error("Invalid port [", serial.BytesLiteral(data), "]") return InvalidPortRange } this.From = Port(maybeint) diff --git a/common/serial/bytes.go b/common/serial/bytes.go index 28818768..45f49666 100644 --- a/common/serial/bytes.go +++ b/common/serial/bytes.go @@ -21,3 +21,7 @@ func (this BytesLiteral) Int64Value() int64 { int64(value[6])<<8 + int64(value[7]) } + +func (this BytesLiteral) String() string { + return string(this.Value()) +} diff --git a/proxy/http/http.go b/proxy/http/http.go index 049a4030..7d122140 100644 --- a/proxy/http/http.go +++ b/proxy/http/http.go @@ -14,6 +14,7 @@ import ( "github.com/v2ray/v2ray-core/common/log" v2net "github.com/v2ray/v2ray-core/common/net" "github.com/v2ray/v2ray-core/common/retry" + "github.com/v2ray/v2ray-core/common/serial" "github.com/v2ray/v2ray-core/transport/ray" ) @@ -222,7 +223,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. request.Write(requestBuffer) - log.Debug("Request to remote:\n", string(requestBuffer.Value)) + log.Debug("Request to remote:\n", serial.BytesLiteral(requestBuffer.Value)) packet := v2net.NewPacket(dest, requestBuffer, true) ray := this.space.PacketDispatcher().DispatchToOutbound(packet)