This commit is contained in:
刘河
2019-02-17 19:36:48 +08:00
parent 7a8cb3d5b6
commit 9f03c2f6eb
13 changed files with 183 additions and 65 deletions

View File

@@ -60,6 +60,7 @@ func (s *server) linkCopy(link *conn.Link, c *conn.Conn, rb []byte, tunnel *conn
}
flow.Add(n, 0)
}
<-link.StatusCh
}
pool.PutBufPoolCopy(buf)
}

View File

@@ -9,7 +9,6 @@ import (
"github.com/cnlh/nps/lib/file"
"github.com/cnlh/nps/lib/lg"
"github.com/cnlh/nps/vender/github.com/astaxie/beego"
"log"
"net/http"
"net/http/httputil"
"path/filepath"
@@ -137,9 +136,10 @@ func (s *httpServer) process(c *conn.Conn, r *http.Request) {
}
lk = conn.NewLink(host.Client.GetId(), common.CONN_TCP, host.GetRandomTarget(), host.Client.Cnf.CompressEncode, host.Client.Cnf.CompressDecode, host.Client.Cnf.Crypt, c, host.Flow, nil, host.Client.Rate, nil)
if tunnel, err = s.bridge.SendLinkInfo(host.Client.Id, lk, c.Conn.RemoteAddr().String()); err != nil {
log.Println(err)
lg.Println(err)
break
}
lk.Run(true)
isConn = false
} else {
r, err = http.ReadRequest(bufio.NewReader(c))
@@ -166,6 +166,7 @@ func (s *httpServer) process(c *conn.Conn, r *http.Request) {
c.Close()
break
}
<-lk.StatusCh
}
end:
if isConn {
@@ -173,9 +174,7 @@ end:
} else {
tunnel.SendMsg([]byte(common.IO_EOF), lk)
}
c.Close()
}
func (s *httpServer) NewServer(port int) *http.Server {

View File

@@ -148,6 +148,7 @@ func (s *Sock5ModeServer) doConnect(c net.Conn, command uint8) {
return
} else {
s.sendReply(c, succeeded)
link.Run(true)
s.linkCopy(link, conn.NewConn(c), nil, tunnel, s.task.Flow)
}
return

View File

@@ -57,6 +57,7 @@ func (s *TunnelModeServer) dealClient(c *conn.Conn, cnf *file.Config, addr strin
c.Close()
return err
} else {
link.Run(true)
s.linkCopy(link, c, rb, tunnel, s.task.Flow)
}
return nil

View File

@@ -56,6 +56,7 @@ func (s *UdpModeServer) process(addr *net.UDPAddr, data []byte) {
s.task.Flow.Add(len(data), 0)
tunnel.SendMsg(data, link)
pool.PutBufPoolUdp(data)
link.Run(true)
}
}