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) type dialFunc func(network, addr string) (net.Conn, error)
// SocksConn present a client connection // Conn present a client connection
type SocksConn struct { type Conn struct {
ClientConn net.Conn net.Conn
// the function to dial to upstream server // the function to dial to upstream server
// when nil, use net.Dial // when nil, use net.Dial
Dial dialFunc Dial dialFunc
@ -31,11 +31,11 @@ type SocksConn struct {
} }
// Serve serve the client // Serve serve the client
func (s *SocksConn) Serve() { func (s *Conn) Serve() {
buf := make([]byte, 1) buf := make([]byte, 1)
// read version // read version
io.ReadFull(s.ClientConn, buf) io.ReadFull(s.Conn, buf)
dial := s.Dial dial := s.Dial
if s.Dial == nil { if s.Dial == nil {
@ -45,14 +45,14 @@ func (s *SocksConn) Serve() {
switch buf[0] { switch buf[0] {
case socks4Version: case socks4Version:
s4 := socks4Conn{clientConn: s.ClientConn, dial: dial} s4 := socks4Conn{clientConn: s.Conn, dial: dial}
s4.Serve() s4.Serve()
case socks5Version: case socks5Version:
s5 := socks5Conn{clientConn: s.ClientConn, dial: dial, s5 := socks5Conn{clientConn: s.Conn, dial: dial,
username: s.Username, password: s.Password} username: s.Username, password: s.Password}
s5.Serve() s5.Serve()
default: default:
log.Printf("error version %d", buf[0]) 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 return
} }
log.Printf("connected from %s", conn.RemoteAddr()) 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() s.Serve()
}() }()

Loading…
Cancel
Save