From 0d257a95dd066d5cbec9946004be7ebe3773d191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B2=B3?= Date: Mon, 4 Mar 2019 13:41:20 +0800 Subject: [PATCH] Compress crypt bug --- server/proxy/http.go | 17 ++++++++++------- web/views/client/edit.html | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/server/proxy/http.go b/server/proxy/http.go index 75220c7e..2895a8e4 100644 --- a/server/proxy/http.go +++ b/server/proxy/http.go @@ -9,6 +9,7 @@ import ( "github.com/cnlh/nps/lib/file" "github.com/cnlh/nps/vender/github.com/astaxie/beego" "github.com/cnlh/nps/vender/github.com/astaxie/beego/logs" + "io" "net" "net/http" "net/http/httputil" @@ -116,11 +117,12 @@ func (s *httpServer) handleTunneling(w http.ResponseWriter, r *http.Request) { func (s *httpServer) process(c *conn.Conn, r *http.Request) { //多客户端域名代理 var ( - isConn = true - host *file.Host - target net.Conn - lastHost *file.Host - err error + isConn = true + host *file.Host + target net.Conn + lastHost *file.Host + err error + connClient io.ReadWriteCloser ) if host, err = file.GetCsvDb().GetInfoByHost(r.Host, r); err != nil { logs.Notice("the url %s %s can't be parsed!", r.Host, r.RequestURI) @@ -151,9 +153,10 @@ func (s *httpServer) process(c *conn.Conn, r *http.Request) { logs.Notice("connect to target %s error %s", lk.Host, err) break } + connClient = conn.GetConn(target, lk.Crypt, lk.Compress, host.Client.Rate) isConn = false go func() { - w, _ := common.CopyBuffer(c, conn.GetConn(target, lk.Crypt, lk.Compress, host.Client.Rate)) + w, _ := common.CopyBuffer(c, connClient) host.Flow.Add(0, w) c.Close() target.Close() @@ -182,7 +185,7 @@ func (s *httpServer) process(c *conn.Conn, r *http.Request) { } host.Flow.Add(int64(len(b)), 0) //write - target.Write(b) + connClient.Write(b) } end: if isConn { diff --git a/web/views/client/edit.html b/web/views/client/edit.html index 954e4a65..e955614f 100755 --- a/web/views/client/edit.html +++ b/web/views/client/edit.html @@ -70,8 +70,8 @@

add client