general: optimize code

This commit is contained in:
nadoo committed 2019-09-07 20:25:00 +08:00
1 parent 69bbaa809c
commit d36b8fa394
12 files changed
+65 -59

No files matched your search

+1 -1
View File
@@ -30,7 +30,7 @@ func NewPktConn(c net.PacketConn, writeAddr net.Addr, tgtAddr socks.Addr, tgtHea
if ctrlConn != nil {
go func() {
buf := []byte{}
buf := make([]byte, 1)
for {
_, err := ctrlConn.Read(buf)
if err, ok := err.(net.Error); ok && err.Timeout() {
+2 -1
View File
@@ -9,6 +9,7 @@
// socks5 server:
// https://github.com/shadowsocks/go-shadowsocks2/tree/master/socks
// Package socks5 implements a socks5 proxy.
package socks5
import (
@@ -114,7 +115,7 @@ func (s *SOCKS5) Serve(c net.Conn) {
if err != nil {
// UDP: keep the connection until disconnect then free the UDP socket
if err == socks.Errors[9] {
buf := []byte{}
buf := make([]byte, 1)
// block here
for {
_, err := c.Read(buf)