heartbeat

Simple server monitor system using encrypted messages over udp
git clone https://noulin.net/git/heartbeat.git
Log | Files | Refs | README

commit 527298b31677dd8b48a15bacd829d33b3023587f
parent a2fd768907b0ada2f5a93e887624d06d4e46a8ef
Author: Remy Noulin <loader2x@gmail.com>
Date:   Fri,  7 Jul 2023 21:22:28 +0200

log source ip when id is wrong

heartbeat.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

Diffstat:
Mheartbeat.c | 9++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/heartbeat.c b/heartbeat.c @@ -229,6 +229,7 @@ void config(smallJsont *cfg) { #include <netdb.h> #include <sys/stat.h> #include <fcntl.h> +#include <arpa/inet.h> // for inet_ntoa void sendMail(char *cmd); @@ -421,7 +422,7 @@ void probe(char *cfgfile) { // start server or bridge for the agents int bridgesock; struct sockaddr_in bridge; - struct sockaddr client; + struct sockaddr_in client; char buf[1024]; bridgesock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); @@ -615,10 +616,12 @@ void probe(char *cfgfile) { // when agent is logger, store message //logD("store message"); if (m->id >= ARRAY_SIZE(agentf)) { - logE("Invalid id"); + char *ip = inet_ntoa((client).sin_addr); + logE("Invalid id: %d, ip %s", m->id, ip); } elif (m->id == id) { - logE("Invalid id, the logger doesn't send packets"); + char *ip = inet_ntoa((client).sin_addr); + logE("Invalid id, the logger doesn't send packets, ip %s", ip); } else { bool saveEvent = no;