Compare commits

..
5 Commits
Author SHA1 Message Date
刘河 0d257a95dd Compress crypt bug 2019-03-04 13:41:20 +08:00
刘河 ad22ada1f1 delete idea 2019-03-04 09:36:25 +08:00
刘河 948d931883 Ignore 2019-03-04 09:34:07 +08:00
刘河 8afa6b2929 .gitignore 2019-03-04 09:32:45 +08:00
刘河 7a49e48b89 gitignore 2019-03-04 09:32:16 +08:00
4 changed files with 13 additions and 17 deletions
+1
View File
@@ -0,0 +1 @@
.idea
Generated
-8
View File
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
+10 -7
View File
@@ -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 {
+2 -2
View File
@@ -70,8 +70,8 @@
<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>