From fc6f0a9ee1f41bda6825bcdf8372db4b8110211d Mon Sep 17 00:00:00 2001 From: fangdingjun Date: Wed, 26 Sep 2018 18:00:03 +0800 Subject: [PATCH] return err on Serve instead of log.Print --- socks4.go | 9 +++++---- socks5.go | 13 +++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/socks4.go b/socks4.go index c735ff4..6f37f1e 100755 --- a/socks4.go +++ b/socks4.go @@ -4,7 +4,7 @@ import ( "encoding/binary" "fmt" "io" - "log" + //"log" "net" ) @@ -37,13 +37,14 @@ type socks4Conn struct { dial DialFunc } -func (s4 *socks4Conn) Serve(b []byte, n int) { +func (s4 *socks4Conn) Serve(b []byte, n int) (err error) { defer s4.Close() - if err := s4.processRequest(b, n); err != nil { - log.Println(err) + if err = s4.processRequest(b, n); err != nil { + //log.Println(err) return } + return } func (s4 *socks4Conn) Close() { diff --git a/socks5.go b/socks5.go index bd05ace..0919d24 100755 --- a/socks5.go +++ b/socks5.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" "io" - "log" + //"log" "net" //"strconv" "encoding/binary" @@ -56,18 +56,19 @@ type socks5Conn struct { auth AuthService } -func (s5 *socks5Conn) Serve(b []byte, n int) { +func (s5 *socks5Conn) Serve(b []byte, n int) (err error) { defer s5.Close() - if err := s5.handshake(b, n); err != nil { - log.Println(err) + if err = s5.handshake(b, n); err != nil { + //log.Println(err) return } - if err := s5.processRequest(); err != nil { - log.Println(err) + if err = s5.processRequest(); err != nil { + //log.Println(err) return } + return } func (s5 *socks5Conn) handshake(buf []byte, n int) (err error) {