From 3e9159571ac0e843bafa5521e5550de1038e88e0 Mon Sep 17 00:00:00 2001 From: fangdingjun Date: Fri, 16 Dec 2016 13:58:59 +0800 Subject: [PATCH] golint: change SocksConn to Conn --- socks.go | 16 ++++++++-------- socks_test.go | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/socks.go b/socks.go index 3bb0ea2..3f7c76c 100755 --- a/socks.go +++ b/socks.go @@ -18,9 +18,9 @@ const ( type dialFunc func(network, addr string) (net.Conn, error) -// SocksConn present a client connection -type SocksConn struct { - ClientConn net.Conn +// Conn present a client connection +type Conn struct { + net.Conn // the function to dial to upstream server // when nil, use net.Dial Dial dialFunc @@ -31,11 +31,11 @@ type SocksConn struct { } // Serve serve the client -func (s *SocksConn) Serve() { +func (s *Conn) Serve() { buf := make([]byte, 1) // read version - io.ReadFull(s.ClientConn, buf) + io.ReadFull(s.Conn, buf) dial := s.Dial if s.Dial == nil { @@ -45,14 +45,14 @@ func (s *SocksConn) Serve() { switch buf[0] { case socks4Version: - s4 := socks4Conn{clientConn: s.ClientConn, dial: dial} + s4 := socks4Conn{clientConn: s.Conn, dial: dial} s4.Serve() case socks5Version: - s5 := socks5Conn{clientConn: s.ClientConn, dial: dial, + s5 := socks5Conn{clientConn: s.Conn, dial: dial, username: s.Username, password: s.Password} s5.Serve() default: log.Printf("error version %d", buf[0]) - s.ClientConn.Close() + s.Conn.Close() } } diff --git a/socks_test.go b/socks_test.go index e680dad..24d7463 100755 --- a/socks_test.go +++ b/socks_test.go @@ -56,7 +56,7 @@ func testSocks(t *testing.T, user, pass string, auth bool) error { return } log.Printf("connected from %s", conn.RemoteAddr()) - s := SocksConn{ClientConn: conn, Username: user, Password: pass} + s := Conn{Conn: conn, Username: user, Password: pass} s.Serve() }()