From 31900f1b2cdccaa6c21b024786ec5a6500bd05ed Mon Sep 17 00:00:00 2001 From: joonicks Date: Thu, 13 Nov 2025 15:10:59 +0100 Subject: [PATCH] uptime protocol change --- VERSIONS | 1 + src/global.h | 2 +- src/uptime.c | 15 +++++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/VERSIONS b/VERSIONS index a101f74..9cf1065 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,5 +1,6 @@ 3.5(.dev) -- + * Changed: Apparently Eggheads changed the uptime protocol without telling anyone. * Changed: Branchless more compact base64 conversion for RANDSRC in send_spy(). * Changed: New botnet connection announced on spy sstatus instead of spy botnet. * Changed: Adjusted output of INFO command. diff --git a/src/global.h b/src/global.h index ba531f9..2eaf2fc 100644 --- a/src/global.h +++ b/src/global.h @@ -273,7 +273,7 @@ BEG char *uptimehost MDEF(NULL); /* proc var */ BEG char *uptimenick MDEF(NULL); /* proc var */ BEG int uptimesock; BEG uint32_t uptimeip MDEF((uint32_t)-1); -BEG uint32_t uptimecookie; +BEG uint32_t uptimepackets MDEF(0); BEG uint32_t uptimeregnr MDEF(0); BEG time_t uptimelast MDEF(0); BEG const char *defaultuptimehost MDEF("uptime.eggheads.org"); diff --git a/src/uptime.c b/src/uptime.c index 91d018d..498ed88 100644 --- a/src/uptime.c +++ b/src/uptime.c @@ -38,7 +38,7 @@ typedef struct int regnr; int pid; int type; - uint32_t cookie; + uint32_t packets_sent; uint32_t uptime; uint32_t ontime; uint32_t mytime; @@ -51,7 +51,7 @@ typedef struct int regnr; int pid; int type; - uint32_t cookie; + uint32_t packets_sent; uint32_t uptime; uint32_t ontime; uint32_t mytime; @@ -64,7 +64,7 @@ void init_uptime(void) { struct sockaddr_in sai; - uptimecookie = rand(); + uptimepackets = 0; if (!uptimehost) { @@ -134,8 +134,8 @@ void send_uptime(int type) sz = (uptimelast + 1) & 7; uptimelast = (now & ~7) + 21600 + sz; /* 21600 seconds = 6 hours */ - uptimecookie = (uptimecookie + 1) * 18457; - upPack.cookie = htonl(uptimecookie); + uptimepackets = uptimepackets + 1; + upPack.packets_sent = htonl(uptimepackets); upPack.mytime = htonl(now); upPack.regnr = uptimeregnr; @@ -196,6 +196,9 @@ void send_uptime(int type) sprintf(upPack.string,"%s %s %s",nick,server,VERSION); +#ifdef DEBUG + debug("(send_uptime) packets sent %i, my pid %i, my ident = \"%s\"\n",uptimepackets,ntohl(upPack.pid),upPack.string); +#endif /* DEBUG */ /* * udp sending... */ @@ -238,7 +241,7 @@ void process_uptime(void) res = recvfrom(uptimesock,(void*)®Pack,sizeof(regPack),0,(struct sockaddr*)&sai,&sz); if (res == sizeof(regPack)) { - if (uptimecookie == ntohl(regPack.cookie)) + if (uptimepackets == ntohl(regPack.cookie)) { if (uptimeregnr == 0) uptimeregnr = ntohl(regPack.regnr);