mirror of
https://github.com/ehang-io/nps.git
synced 2025-09-01 02:46:52 +00:00
健康检查
This commit is contained in:
@@ -159,7 +159,7 @@ func (s *httpServer) process(c *conn.Conn, r *http.Request) {
|
||||
logs.Warn("auth error", err, r.RemoteAddr)
|
||||
break
|
||||
}
|
||||
lk := conn.NewLink(common.CONN_TCP, host.Target, host.Client.Cnf.Crypt, host.Client.Cnf.Compress, r.RemoteAddr)
|
||||
lk := conn.NewLink(common.CONN_TCP, host.GetRandomTarget(), host.Client.Cnf.Crypt, host.Client.Cnf.Compress, r.RemoteAddr)
|
||||
if target, err = s.bridge.SendLinkInfo(host.Client.Id, lk, c.Conn.RemoteAddr().String(), nil); err != nil {
|
||||
logs.Notice("connect to target %s error %s", lk.Host, err)
|
||||
break
|
||||
@@ -174,10 +174,10 @@ func (s *httpServer) process(c *conn.Conn, r *http.Request) {
|
||||
}()
|
||||
} else {
|
||||
r, err = http.ReadRequest(bufio.NewReader(c))
|
||||
r.URL.Scheme = scheme
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
r.URL.Scheme = scheme
|
||||
//What happened ,Why one character less???
|
||||
if r.Method == "ET" {
|
||||
r.Method = "GET"
|
||||
@@ -190,10 +190,14 @@ func (s *httpServer) process(c *conn.Conn, r *http.Request) {
|
||||
logs.Notice("the url %s %s %s can't be parsed!", r.URL.Scheme, r.Host, r.RequestURI)
|
||||
break
|
||||
} else if host != lastHost {
|
||||
host.Client.AddConn()
|
||||
if !hostTmp.Client.GetConn() {
|
||||
break
|
||||
}
|
||||
host = hostTmp
|
||||
lastHost = host
|
||||
isConn = true
|
||||
host.Client.AddConn()
|
||||
|
||||
goto start
|
||||
}
|
||||
}
|
||||
@@ -204,7 +208,7 @@ func (s *httpServer) process(c *conn.Conn, r *http.Request) {
|
||||
break
|
||||
}
|
||||
host.Flow.Add(int64(len(b)), 0)
|
||||
logs.Trace("http(s) request, method %s, host %s, url %s, remote address %s, target %s", r.Method, r.Host, r.RequestURI, r.RemoteAddr, host.Target)
|
||||
logs.Trace("%s request, method %s, host %s, url %s, remote address %s, target %s", r.URL.Scheme, r.Method, r.Host, r.RequestURI, r.RemoteAddr, host.Target)
|
||||
//write
|
||||
connClient.Write(b)
|
||||
}
|
||||
|
@@ -109,7 +109,7 @@ type process func(c *conn.Conn, s *TunnelModeServer) error
|
||||
|
||||
//tcp隧道模式
|
||||
func ProcessTunnel(c *conn.Conn, s *TunnelModeServer) error {
|
||||
return s.DealClient(c, s.task.Target, nil, common.CONN_TCP)
|
||||
return s.DealClient(c, s.task.GetRandomTarget(), nil, common.CONN_TCP)
|
||||
}
|
||||
|
||||
//http代理模式
|
||||
|
Reference in New Issue
Block a user