uptime protocol change

This commit is contained in:
joonicks 2025-11-13 15:10:59 +01:00
parent d3fdf50bdd
commit 31900f1b2c
3 changed files with 11 additions and 7 deletions

View File

@ -1,5 +1,6 @@
3.5(.dev) -- 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: Branchless more compact base64 conversion for RANDSRC in send_spy().
* Changed: New botnet connection announced on spy sstatus instead of spy botnet. * Changed: New botnet connection announced on spy sstatus instead of spy botnet.
* Changed: Adjusted output of INFO command. * Changed: Adjusted output of INFO command.

View File

@ -273,7 +273,7 @@ BEG char *uptimehost MDEF(NULL); /* proc var */
BEG char *uptimenick MDEF(NULL); /* proc var */ BEG char *uptimenick MDEF(NULL); /* proc var */
BEG int uptimesock; BEG int uptimesock;
BEG uint32_t uptimeip MDEF((uint32_t)-1); 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 uint32_t uptimeregnr MDEF(0);
BEG time_t uptimelast MDEF(0); BEG time_t uptimelast MDEF(0);
BEG const char *defaultuptimehost MDEF("uptime.eggheads.org"); BEG const char *defaultuptimehost MDEF("uptime.eggheads.org");

View File

@ -38,7 +38,7 @@ typedef struct
int regnr; int regnr;
int pid; int pid;
int type; int type;
uint32_t cookie; uint32_t packets_sent;
uint32_t uptime; uint32_t uptime;
uint32_t ontime; uint32_t ontime;
uint32_t mytime; uint32_t mytime;
@ -51,7 +51,7 @@ typedef struct
int regnr; int regnr;
int pid; int pid;
int type; int type;
uint32_t cookie; uint32_t packets_sent;
uint32_t uptime; uint32_t uptime;
uint32_t ontime; uint32_t ontime;
uint32_t mytime; uint32_t mytime;
@ -64,7 +64,7 @@ void init_uptime(void)
{ {
struct sockaddr_in sai; struct sockaddr_in sai;
uptimecookie = rand(); uptimepackets = 0;
if (!uptimehost) if (!uptimehost)
{ {
@ -134,8 +134,8 @@ void send_uptime(int type)
sz = (uptimelast + 1) & 7; sz = (uptimelast + 1) & 7;
uptimelast = (now & ~7) + 21600 + sz; /* 21600 seconds = 6 hours */ uptimelast = (now & ~7) + 21600 + sz; /* 21600 seconds = 6 hours */
uptimecookie = (uptimecookie + 1) * 18457; uptimepackets = uptimepackets + 1;
upPack.cookie = htonl(uptimecookie); upPack.packets_sent = htonl(uptimepackets);
upPack.mytime = htonl(now); upPack.mytime = htonl(now);
upPack.regnr = uptimeregnr; upPack.regnr = uptimeregnr;
@ -196,6 +196,9 @@ void send_uptime(int type)
sprintf(upPack.string,"%s %s %s",nick,server,VERSION); 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... * udp sending...
*/ */
@ -238,7 +241,7 @@ void process_uptime(void)
res = recvfrom(uptimesock,(void*)&regPack,sizeof(regPack),0,(struct sockaddr*)&sai,&sz); res = recvfrom(uptimesock,(void*)&regPack,sizeof(regPack),0,(struct sockaddr*)&sai,&sz);
if (res == sizeof(regPack)) if (res == sizeof(regPack))
{ {
if (uptimecookie == ntohl(regPack.cookie)) if (uptimepackets == ntohl(regPack.cookie))
{ {
if (uptimeregnr == 0) if (uptimeregnr == 0)
uptimeregnr = ntohl(regPack.regnr); uptimeregnr = ntohl(regPack.regnr);