add traffic sniffing for handler

This commit is contained in:
ginuerzh
2024-09-27 15:55:28 +08:00
parent dfb6cb95d0
commit 3c8add4b82
43 changed files with 4518 additions and 1839 deletions
+12 -4
View File
@@ -30,10 +30,6 @@ import (
xrecorder "github.com/go-gost/x/recorder"
)
const (
defaultBodySize = 1024 * 1024 // 1MB
)
type entrypoint struct {
node string
service string
@@ -70,6 +66,18 @@ func (ep *entrypoint) handle(ctx context.Context, conn net.Conn) error {
return ep.handleConnect(ctx, xnet.NewBufferReaderConn(conn, br), log)
}
ro := &xrecorder.HandlerRecorderObject{
Node: ep.node,
Service: ep.service,
RemoteAddr: conn.RemoteAddr().String(),
LocalAddr: conn.LocalAddr().String(),
Network: "tcp",
Time: start,
}
ro.ClientIP, _, _ = net.SplitHostPort(conn.RemoteAddr().String())
return ep.handleHTTP(ctx, xio.NewReadWriter(br, conn), ro, log)
var cc net.Conn
for {
resp := &http.Response{