From 9353b8afa87d059b2adb6b1231cd526b4c95adcd Mon Sep 17 00:00:00 2001 From: Jinjie Zhang Date: Wed, 30 Jun 2021 18:45:00 +0800 Subject: [PATCH] fix: fix localhost proxy --- bridge/bridge.go | 6 +++--- lib/file/obj.go | 4 ++-- server/proxy/socks5.go | 3 +++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bridge/bridge.go b/bridge/bridge.go index 41568df..f8f2e45 100755 --- a/bridge/bridge.go +++ b/bridge/bridge.go @@ -24,9 +24,9 @@ import ( ) type Client struct { - tunnel *nps_mux.Mux - signal *conn.Conn - file *nps_mux.Mux + tunnel *nps_mux.Mux // WORK_CHAN connection + signal *conn.Conn // WORK_MAIN connection + file *nps_mux.Mux // WORK_FILE connection Version string retryTime int // it will be add 1 when ping not ok until to 3 will close the client } diff --git a/lib/file/obj.go b/lib/file/obj.go index 31f3e63..ff6fa7a 100644 --- a/lib/file/obj.go +++ b/lib/file/obj.go @@ -25,8 +25,8 @@ func (s *Flow) Add(in, out int64) { } type Config struct { - U string - P string + U string // username + P string // password Compress bool Crypt bool } diff --git a/server/proxy/socks5.go b/server/proxy/socks5.go index 3faefe5..75bcf1e 100755 --- a/server/proxy/socks5.go +++ b/server/proxy/socks5.go @@ -96,6 +96,9 @@ func (s *Sock5ModeServer) sendReply(c net.Conn, rep uint8) { localAddr := c.LocalAddr().String() localHost, localPort, _ := net.SplitHostPort(localAddr) ipBytes := net.ParseIP(localHost).To4() + if ipBytes == nil { + ipBytes = net.ParseIP("127.0.0.1").To4() + } nPort, _ := strconv.Atoi(localPort) reply = append(reply, ipBytes...) portBytes := make([]byte, 2)