Skip to content

Commit

Permalink
Compress crypt bug
Browse files Browse the repository at this point in the history
  • Loading branch information
刘河 committed Mar 4, 2019
1 parent ad22ada commit 0d257a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
17 changes: 10 additions & 7 deletions server/proxy/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions web/views/client/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ <h3 class="ibox-title">add client</h3>
<label class="control-label col-sm-2">crypt</label>
<div class="col-sm-10">
<select class="form-control" name="crypt">
<option {{if eq false .c.Cnf.Compress}}selected{{end}} value="0">no</option>
<option {{if eq true .c.Cnf.Compress}}selected{{end}} value="1">yes</option>
<option {{if eq false .c.Cnf.Crypt}}selected{{end}} value="0">no</option>
<option {{if eq true .c.Cnf.Crypt}}selected{{end}} value="1">yes</option>
</select>
</div>
</div>
Expand Down

0 comments on commit 0d257a9

Please sign in to comment.