From 6746800a217c4faf7876fb63b94b8cad321aae72 Mon Sep 17 00:00:00 2001 From: V2Ray Date: Wed, 16 Sep 2015 16:06:16 +0200 Subject: [PATCH] Remove unnecessary code in socks io --- io/socks/socks.go | 8 ++------ io/socks/socks_test.go | 12 ------------ 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/io/socks/socks.go b/io/socks/socks.go index bfbdfb9d7..b9e138c64 100644 --- a/io/socks/socks.go +++ b/io/socks/socks.go @@ -77,12 +77,8 @@ func NewAuthenticationResponse(authMethod byte) *Socks5AuthenticationResponse { return response } -func (r *Socks5AuthenticationResponse) ToBytes() []byte { - return []byte{r.version, r.authMethod} -} - -func WriteAuthentication(writer io.Writer, response *Socks5AuthenticationResponse) error { - _, err := writer.Write(response.ToBytes()) +func WriteAuthentication(writer io.Writer, r *Socks5AuthenticationResponse) error { + _, err := writer.Write([]byte{r.version, r.authMethod}) return err } diff --git a/io/socks/socks_test.go b/io/socks/socks_test.go index ec132f683..1576cb576 100644 --- a/io/socks/socks_test.go +++ b/io/socks/socks_test.go @@ -22,18 +22,6 @@ func TestAuthenticationRequestRead(t *testing.T) { assert.Byte(request.authMethods[0]).Named("Auth Method").Equals(0x02) } -func TestAuthenticationResponseToBytes(t *testing.T) { - assert := unit.Assert(t) - - socksVersion := uint8(5) - authMethod := uint8(1) - response := Socks5AuthenticationResponse{socksVersion, authMethod} - bytes := response.ToBytes() - - assert.Byte(bytes[0]).Named("Version").Equals(socksVersion) - assert.Byte(bytes[1]).Named("Auth Method").Equals(authMethod) -} - func TestRequestRead(t *testing.T) { assert := unit.Assert(t)