golint: change SocksConn to Conn

master
fangdingjun 8 years ago
parent 4094a344ef
commit 3e9159571a

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

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

Loading…
Cancel
Save