return err on Serve instead of log.Print

master
fangdingjun 6 years ago
parent 0477b2d842
commit fc6f0a9ee1

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

@ -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) {

Loading…
Cancel
Save