feat(network): add protocol packet capture and replay system

Add a recording and replay foundation for the MHF network protocol.
A RecordingConn decorator wraps network.Conn to transparently capture
all decrypted packets to binary .mhfr files, with zero handler changes
and zero overhead when disabled.

- network/pcap: binary capture format (writer, reader, filters)
- RecordingConn: thread-safe Conn decorator with direction tracking
- CaptureOptions in config (disabled by default)
- Capture wired into all three server types (sign, entrance, channel)
- cmd/replay: CLI tool with dump, json, stats, and compare modes
- 19 new tests, all passing with -race
This commit is contained in:
Houmgaor
2026-02-23 18:50:44 +01:00
parent e5ffc4d52d
commit 7ef5efc549
20 changed files with 1716 additions and 15 deletions

View File

@@ -104,13 +104,21 @@ func (s *Server) handleConnection(conn net.Conn) {
}
// Create a new session.
var cc network.Conn = network.NewCryptConn(conn, s.erupeConfig.RealClientMode, s.logger)
cc, captureCleanup := startSignCapture(s, cc, conn.RemoteAddr())
session := &Session{
logger: s.logger,
server: s,
rawConn: conn,
cryptConn: network.NewCryptConn(conn, s.erupeConfig.RealClientMode, s.logger),
logger: s.logger,
server: s,
rawConn: conn,
cryptConn: cc,
captureCleanup: captureCleanup,
}
// Do the session's work.
session.work()
if session.captureCleanup != nil {
session.captureCleanup()
}
}