add transport for tunnel entrypoint

This commit is contained in:
ginuerzh
2024-10-15 18:47:36 +08:00
parent 5bba004324
commit 51ca9f620a
8 changed files with 357 additions and 355 deletions
+2 -1
View File
@@ -176,6 +176,7 @@ func (h *Sniffer) HandleHTTP(ctx context.Context, conn net.Conn, opts ...HandleO
log.Debugf("connected to node %s(%s)", node.Name, node.Addr)
ro.Time = time.Time{}
shouldClose, err := h.httpRoundTrip(ctx, conn, cc, node, req, &pStats, &ho)
if err != nil || shouldClose {
return err
@@ -510,7 +511,7 @@ func (h *Sniffer) httpRoundTrip(ctx context.Context, rw, cc io.ReadWriter, node
ro.HTTP.Response.ContentLength = respBody.Length()
}
if req.Header.Get("Upgrade") == "websocket" {
if resp.StatusCode == http.StatusSwitchingProtocols {
xnet.Transport(rw, cc)
}
+1 -1
View File
@@ -365,7 +365,7 @@ func (h *Sniffer) httpRoundTrip(ctx context.Context, rw, cc io.ReadWriter, req *
ro.HTTP.Response.ContentLength = respBody.Length()
}
if req.Header.Get("Upgrade") == "websocket" {
if resp.StatusCode == http.StatusSwitchingProtocols {
xnet.Transport(rw, cc)
}