mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 19:03:43 +00:00
feat(capture): record whole packets of an account, a character or everything on every server
Staff arm a packet capture on the dashboard; master passes MESSAGE_CAPTURE_CONTROL ARM to every world, auth and chat and arms its own. Each server's PacketCapture tap (dServer receive, and a send hook in RakPeer::Send so replica constructions are seen too) records into one preallocated chunk per server and ships sealed chunks through master on the main loop when capture_flush_bytes or capture_flush_interval_ms is reached; past capture_buffer_max_mb the oldest chunks are dropped and the dashboard records a gap. Nothing is armed: one flag check. - targets: an account (from its login; packets before the login are kept per connection and added once auth or the world knows whose they are), a character (from when it is picked), or everything; up to 8 at once (a bit each in the record mask) - worlds and auth record their clients' packets and the master link messages of a captured player (session keys by name, zone transfers by request, player added/removed, migration); chat finds the player in each packet; master records server traffic for everything - secrets are never recorded: structs that carry them (login request, login response user key, world validation session key, session key messages between servers) are read, blanked and written again before recording; auth keeps only the handshake and login - PacketDecoder: a registry by service and message id names every packet and decodes the registered structs; CaptureBundle is the file format (DLUBNDL1, metadata, records); CaptureTools orders records on one timeline, pulls movement out, makes bundles portable or anonymous and diffs replays - the dashboard keeps packet captures in message_capture_sessions (capture_kind 1) and their packets in a file under capture_dir, one write per batch; arming is audited - MESSAGE_CAPTURE_CONTROL/DATA only gain appended enum values and trailing fields Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
#include "CommonPackets.h"
|
||||
#include "MasterPackets.h"
|
||||
#include "ZoneInstanceManager.h"
|
||||
#include "PacketCapture.h"
|
||||
#include "master/MessageCapture.h"
|
||||
#include "StringifiedEnum.h"
|
||||
#include "GeneralUtils.h"
|
||||
#include "TrafficStats.h"
|
||||
@@ -134,6 +136,9 @@ dServer::dServer(
|
||||
mPeer->AttachPlugin(mReplicaManager);
|
||||
mPeer->SetNetworkIDManager(mNetIDManager);
|
||||
}
|
||||
|
||||
// The dashboard's packet capture records what goes through the listening peer and, for a captured player, the master link
|
||||
PacketCapture::Attach(serverType, mPeer, mMasterPeer, zoneID, static_cast<uint32_t>(instanceID));
|
||||
}
|
||||
|
||||
dServer::~dServer() {
|
||||
@@ -148,6 +153,7 @@ Packet* dServer::ReceiveFromMaster() {
|
||||
CountTraffic(packet, TrafficStats::Peer::MASTER);
|
||||
if (packet) {
|
||||
if (packet->length < 1) { mMasterPeer->DeallocatePacket(packet); return nullptr; }
|
||||
PacketCapture::OnReceiveFromMaster(packet);
|
||||
|
||||
switch (packet->data[0]) {
|
||||
case ID_DISCONNECTION_NOTIFICATION:
|
||||
@@ -201,6 +207,15 @@ Packet* dServer::ReceiveFromMaster() {
|
||||
break;
|
||||
}
|
||||
|
||||
case MessageType::Master::MESSAGE_CAPTURE_CONTROL: {
|
||||
// Packet captures run on every server; the game message inspector's start and stop go to the world's own handler
|
||||
MessageCaptureControl control;
|
||||
if (!control.Deserialize(inStream)) break;
|
||||
if (control.action != eMessageCaptureControl::ARM && control.action != eMessageCaptureControl::DISARM) return packet;
|
||||
PacketCapture::Control(control);
|
||||
break;
|
||||
}
|
||||
|
||||
// When we handle these packets in World instead dServer, we just return the packet's pointer.
|
||||
default:
|
||||
return packet;
|
||||
@@ -219,6 +234,7 @@ Packet* dServer::ReceiveFromMaster() {
|
||||
Packet* dServer::Receive() {
|
||||
Packet* packet = mPeer->Receive();
|
||||
CountTraffic(packet, PeerOfConnections());
|
||||
PacketCapture::OnReceive(packet);
|
||||
return packet;
|
||||
}
|
||||
|
||||
@@ -297,6 +313,7 @@ void dServer::UpdateBandwidthLimit() {
|
||||
}
|
||||
|
||||
void dServer::Shutdown() {
|
||||
PacketCapture::Detach();
|
||||
if (mPeer) {
|
||||
mPeer->Shutdown(1000);
|
||||
RakNetworkFactory::DestroyRakPeerInterface(mPeer);
|
||||
|
||||
Reference in New Issue
Block a user