commit f6a5b3efb0ff6879a44fd86f7c650b8c58463463
parent ad1a0ee3518026b8bcc31bdc7d3581d2941d1ea5
Author: Remy Noulin <loader2x@gmail.com>
Date: Fri, 15 Sep 2023 14:19:31 +0200
stop initializing threads, add agent name in logs, verbose logs
heartbeat.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
Diffstat:
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/heartbeat.c b/heartbeat.c
@@ -87,9 +87,12 @@ int main(int ARGC, char** ARGV) {
argc = ARGC; argv = ARGV;
- initLibsheepy(ARGV[0]);
- //setLogMode(LOG_VERBOSE);
- setLogMode(LOG_FUNC);
+ //initLibsheepy(ARGV[0]);
+ // don't initialize threads
+ // there are issues with tpool waiting for threads to finish forever
+ initLibsheepyF(ARGV[0], null);
+ setLogMode(LOG_VERBOSE);
+ //setLogMode(LOG_FUNC);
//openProgLogFile();
setLogSymbols(LOG_UTF8);
//disableLibsheepyErrorLogs;
@@ -1042,7 +1045,8 @@ void probe(char *cfgfile, char *secretFile, char *publicFile, char *loggerPublic
goto cont;
}
elif (r != data.len + sizeof(data.nonce) + sizeof(data.id) + sizeof(data.len)) {
- logE("Dropped packet with id %d. Incorrect size, received %d and expected %d", data.id, r, data.len + sizeof(data.nonce) + sizeof(data.id) + sizeof(data.len));
+ char *ip = inet_ntoa((client).sin_addr);
+ logE("Dropped packet with id %d from ip %s. Incorrect size, received %d and expected %d", data.id, ip, r, data.len + sizeof(data.nonce) + sizeof(data.id) + sizeof(data.len));
goto cont;
}
else {
@@ -1076,7 +1080,7 @@ void probe(char *cfgfile, char *secretFile, char *publicFile, char *loggerPublic
if (!len) {
char *ip = inet_ntoa((client).sin_addr);
- logE("failed to decrypt, ip %s", ip);
+ logE("Failed to decrypt, ip %s, agent %s", ip, agents[data.id]);
// drop packet
goto handleEventLoopSleep;
}
@@ -1088,14 +1092,14 @@ void probe(char *cfgfile, char *secretFile, char *publicFile, char *loggerPublic
if (u$(agent, "count") and payload.count <= u$(agent, "count")) {
// packet counter is already initialized
char *ip = inet_ntoa((client).sin_addr);
- logW("Dropping packet. Wrong remote packet count %"PRIu64" local %"PRIu64" diff %"PRIi64", ip %s", payload.count, u$(agent, "count"), (i64)u$(agent, "count") - (i64)payload.count, ip);
+ logW("Dropping packet. Wrong remote packet count %"PRIu64" local %"PRIu64" diff %"PRIi64", ip %s, agent %s", payload.count, u$(agent, "count"), (i64)u$(agent, "count") - (i64)payload.count, ip, agents[data.id]);
goto handleEventLoopSleep;
}
setG(agent, "count", payload.count);
// message is decrypted
msgt *m = &payload.m;
- /* logD("got message from id %d", data.id); */
+ /* logD("got message from id %d, agent %s", data.id, agents[data.id]); */
/* logD("with message id %d", m->messageId); */
/* logD("and status %x", m->status); */