add handle options for sniffer

This commit is contained in:
ginuerzh
2024-10-10 22:49:56 +08:00
parent 9a56c8fba3
commit 8f994ab632
94 changed files with 416 additions and 240 deletions
+18 -10
View File
@@ -161,30 +161,38 @@ func (h *forwardHandler) handleDirectForward(ctx context.Context, conn *sshd_uti
conn.SetReadDeadline(time.Time{})
}
dial := func(ctx context.Context, network, address string) (net.Conn, error) {
return cc, nil
}
dialTLS := func(ctx context.Context, network, address string, cfg *tls.Config) (net.Conn, error) {
return cc, nil
}
sniffer := &sniffing.Sniffer{
Recorder: h.recorder.Recorder,
RecorderOptions: h.recorder.Options,
RecorderObject: ro,
Certificate: h.md.certificate,
PrivateKey: h.md.privateKey,
NegotiatedProtocol: h.md.alpn,
CertPool: h.certPool,
MitmBypass: h.md.mitmBypass,
ReadTimeout: h.md.readTimeout,
Log: log,
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
return cc, nil
},
DialTLS: func(ctx context.Context, network, address string, cfg *tls.Config) (net.Conn, error) {
return cc, nil
},
}
switch proto {
case sniffing.ProtoHTTP:
return sniffer.HandleHTTP(ctx, xnet.NewReadWriteConn(br, conn, conn))
return sniffer.HandleHTTP(ctx, xnet.NewReadWriteConn(br, conn, conn),
sniffing.WithDial(dial),
sniffing.WithDialTLS(dialTLS),
sniffing.WithRecorderObject(ro),
sniffing.WithLog(log),
)
case sniffing.ProtoTLS:
return sniffer.HandleTLS(ctx, xnet.NewReadWriteConn(br, conn, conn))
return sniffer.HandleTLS(ctx, xnet.NewReadWriteConn(br, conn, conn),
sniffing.WithDial(dial),
sniffing.WithDialTLS(dialTLS),
sniffing.WithRecorderObject(ro),
sniffing.WithLog(log),
)
}
}