mirror of
https://github.com/Adaptix-Framework/AdaptixC2
synced 2026-06-08 10:20:39 +00:00
b037a729cd
Optimize client-server log synchronization performance with batch processing. Server-side changes: - Add TYPE_SYNC_BATCH (0x14) packet type - Implement batch transmission in TsSyncStored() (BATCH_SIZE=100) - Add SyncPackerBatch structure for batch packets - Add performance monitoring with timing logs Client-side changes: - Add TYPE_SYNC_BATCH packet type definition - Implement batch packet validation in isValidSyncPacket() - Add batch processing logic in processSyncPacket() - Optimize UI updates with setUpdatesEnabled() for batch operations - Add sync performance tracking and display Performance improvements: - Reduce WebSocket calls from N to N/100 (99% reduction) - Reduce UI update operations by 99% - Expected sync time for 3000 logs: 6s -> 1.5s (75% improvement) Related issue: Slow sync performance with 3000+ logs
65 lines
1.8 KiB
C++
65 lines
1.8 KiB
C++
#include <UI/Dialogs/DialogSyncPacket.h>
|
|
|
|
DialogSyncPacket::DialogSyncPacket()
|
|
{
|
|
splashScreen = new CustomSplashScreen();
|
|
splashScreen->setPixmap(QPixmap(":/SyncLogo"));
|
|
|
|
logNameLabel = new QLabel("Log synchronization");
|
|
|
|
logProgressLabel = new QLabel();
|
|
logProgressLabel->setAlignment(Qt::AlignCenter);
|
|
|
|
progressBar = new QProgressBar();
|
|
|
|
layout = new QVBoxLayout(splashScreen);
|
|
layout->addWidget(logNameLabel);
|
|
layout->addStretch();
|
|
layout->addWidget(progressBar);
|
|
layout->addWidget(logProgressLabel);
|
|
}
|
|
|
|
DialogSyncPacket::~DialogSyncPacket() = default;
|
|
|
|
void DialogSyncPacket::init(int count)
|
|
{
|
|
receivedLogs = 0;
|
|
totalLogs = count;
|
|
startTime = QDateTime::currentMSecsSinceEpoch();
|
|
QString progress = QString("Received: %1 / %2").arg(receivedLogs).arg(totalLogs);
|
|
logProgressLabel->setText(progress);
|
|
logProgressLabel->setAlignment(Qt::AlignCenter);
|
|
|
|
progressBar->setRange(receivedLogs, totalLogs);
|
|
progressBar->setValue(receivedLogs);
|
|
}
|
|
|
|
void DialogSyncPacket::upgrade() const
|
|
{
|
|
QString progress = QString("Received: %1 / %2").arg(receivedLogs).arg(totalLogs);
|
|
logProgressLabel->setText(progress);
|
|
|
|
if (totalLogs > 0) {
|
|
progressBar->setValue(receivedLogs);
|
|
}
|
|
|
|
if (receivedLogs >= totalLogs) {
|
|
finish();
|
|
}
|
|
}
|
|
|
|
void DialogSyncPacket::finish() const
|
|
{
|
|
qint64 elapsed = QDateTime::currentMSecsSinceEpoch() - startTime;
|
|
double seconds = elapsed / 1000.0;
|
|
|
|
QString completeMsg = QString("Synchronization complete! %1 items in %2s")
|
|
.arg(totalLogs)
|
|
.arg(seconds, 0, 'f', 2);
|
|
|
|
logProgressLabel->setText(completeMsg);
|
|
qDebug() << "[SYNC] Client sync completed:" << totalLogs << "items in" << elapsed << "ms";
|
|
|
|
splashScreen->close();
|
|
}
|