socks5: fix #148

This commit is contained in:
nadoo committed 2020-04-04 18:00:31 +08:00
1 parent fda05d5d3d
commit 9c3f2f600a
3 files changed
+11 -15

No files matched your search

+4 -9
View File
@@ -103,16 +103,11 @@ func (s *Socks5) ListenAndServeTCP() {
}
// Serve serves a connection.
func (s *Socks5) Serve(cc net.Conn) {
defer cc.Close()
func (s *Socks5) Serve(c net.Conn) {
defer c.Close()
var c *conn.Conn
switch ccc := cc.(type) {
case *net.TCPConn:
ccc.SetKeepAlive(true)
c = conn.NewConn(ccc)
case *conn.Conn:
c = ccc
if c, ok := c.(*net.TCPConn); ok {
c.SetKeepAlive(true)
}
tgt, err := s.handshake(c)