From 76b0db2016ee992905ffa06d0bb096f82bc05985 Mon Sep 17 00:00:00 2001 From: v2ray Date: Thu, 4 Feb 2016 22:52:42 +0100 Subject: [PATCH] return ErrorInvalidAuthentication when OTA is not valid --- proxy/shadowsocks/protocol.go | 3 ++- proxy/shadowsocks/protocol_test.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/proxy/shadowsocks/protocol.go b/proxy/shadowsocks/protocol.go index 2b51447f7..98e9b188c 100644 --- a/proxy/shadowsocks/protocol.go +++ b/proxy/shadowsocks/protocol.go @@ -7,6 +7,7 @@ import ( "github.com/v2ray/v2ray-core/common/log" v2net "github.com/v2ray/v2ray-core/common/net" "github.com/v2ray/v2ray-core/common/serial" + "github.com/v2ray/v2ray-core/proxy" "github.com/v2ray/v2ray-core/transport" ) @@ -117,7 +118,7 @@ func ReadRequest(reader io.Reader, auth *Authenticator, udp bool) (*Request, err actualAuth := auth.Authenticate(nil, buffer.Value[0:lenBuffer]) if !serial.BytesLiteral(actualAuth).Equals(serial.BytesLiteral(authBytes)) { log.Error("Shadowsocks: Invalid OTA: ", actualAuth) - return nil, transport.ErrorCorruptedPacket + return nil, proxy.ErrorInvalidAuthentication } } diff --git a/proxy/shadowsocks/protocol_test.go b/proxy/shadowsocks/protocol_test.go index fbc06be62..f0fee6e38 100644 --- a/proxy/shadowsocks/protocol_test.go +++ b/proxy/shadowsocks/protocol_test.go @@ -6,6 +6,7 @@ import ( "github.com/v2ray/v2ray-core/common/alloc" v2net "github.com/v2ray/v2ray-core/common/net" netassert "github.com/v2ray/v2ray-core/common/net/testing/assert" + "github.com/v2ray/v2ray-core/proxy" . "github.com/v2ray/v2ray-core/proxy/shadowsocks" v2testing "github.com/v2ray/v2ray-core/testing" "github.com/v2ray/v2ray-core/testing/assert" @@ -98,7 +99,7 @@ func TestInvalidOTARequest(t *testing.T) { []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5}, []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5})) _, err := ReadRequest(buffer, auth, false) - assert.Error(err).Equals(transport.ErrorCorruptedPacket) + assert.Error(err).Equals(proxy.ErrorInvalidAuthentication) } func TestUDPRequestParsing(t *testing.T) {