metrics: RTT/loss histograms + Ed25519 signing + peer exchange via INIT handshake + file logging to stats/<peer>.dat

- etcp_metrics struct: 12-bucket RTT histogram, 11-bucket loss histogram, 10-min snapshots (>=200 pkts)
- Total counters: packets/bytes sent/rcvd, losses (retrans + probe gap detection)
- CSV append to <stats_dir>/<peer_id>.dat every 10 min
- Ed25519 pubkey exchange in INIT handshake (V3), always present
- Signed metrics exchange via ETCP_SECTION_METRICS (0x0A)
- Received metrics saved as from_<peer_id>.dat with signature hex
- on_metrics_rcvd callback in ETCP_BINDINGS
- stats_dir derived from config file path, mkdir'd at instance init
- Simplified versioning: ETCP_INIT_REQ_SIZE / ETCP_INIT_RESP_SIZE via sizeof
This commit is contained in:
Evgeny committed 2026-07-07 17:16:45 +03:00
1 parent f5c93266dc
commit 1889d23240
29 files changed
+1247 -53

No files matched your search

+27 -10
View File
@@ -1,9 +1,9 @@
#include <QApplication>
#include <QFile>
#include <QDir>
#include <QSettings>
#include "mainwindow.h"
#include "../db/db_manager.h"
#include "../transport/node_config.h"
#include "debug_ui.h"
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
@@ -11,22 +11,39 @@ int main(int argc, char *argv[]) {
app.setQuitOnLastWindowClosed(false);
QString cfgPath = QCoreApplication::applicationDirPath() + "/chatgui.cfg";
QString dbPath = "chats.db";
if (QFile::exists(cfgPath)) {
QSettings cfg(cfgPath, QSettings::IniFormat);
dbPath = cfg.value("db_path", "chats.db").toString();
NodeConfig cfg(cfgPath);
bool needSave = false;
if (!cfg.exists()) {
if (!cfg.create("chatgui", 1333)) {
qCritical("Failed to create config: %s", qPrintable(cfgPath));
return 1;
}
} else {
QSettings cfg(cfgPath, QSettings::IniFormat);
cfg.setValue("db_path", "chats.db");
cfg.sync();
if (!cfg.load()) {
qCritical("Failed to load config: %s", qPrintable(cfgPath));
return 1;
}
if (cfg.privKey().length() != 64 || cfg.pubKey().length() != 64 ||
cfg.nodeId().length() != 16) {
cfg.generateIdentity();
needSave = true;
}
if (needSave)
cfg.save();
}
if (!cfg.debugFile().isEmpty())
guiDebugFile(cfg.debugFile().toUtf8().constData());
QString dbPath = cfg.dbPath();
if (dbPath.isEmpty()) dbPath = "chats.db";
if (!QDir::isAbsolutePath(dbPath))
dbPath = QCoreApplication::applicationDirPath() + "/" + dbPath;
DbManager db(dbPath);
MainWindow w(nullptr, &db);
MainWindow w(nullptr, &db, cfgPath, cfg.debugFile());
w.show();
return app.exec();