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() }()