Send a rate-limited server notice if a blacklist gives a non-127.0.0.x reply.

This commit is contained in:
Jilles Tjoelker 2008-01-05 00:38:23 +01:00
parent 1115a7a586
commit 962747349b
2 changed files with 12 additions and 2 deletions

View file

@ -32,6 +32,7 @@ struct Blacklist {
char host[HOSTLEN]; char host[HOSTLEN];
char reject_reason[IRCD_BUFSIZE]; char reject_reason[IRCD_BUFSIZE];
unsigned int hits; unsigned int hits;
time_t lastwarning;
}; };
/* A lookup in progress for a particular DNSBL for a particular client */ /* A lookup in progress for a particular DNSBL for a particular client */

View file

@ -81,8 +81,16 @@ static void blacklist_dns_callback(void *vptr, struct DNSReply *reply)
if (reply != NULL) if (reply != NULL)
{ {
/* only accept 127.0.0.x as a listing */ /* only accept 127.0.0.x as a listing */
listed = reply->addr.ss_family == AF_INET && if (reply->addr.ss_family == AF_INET &&
!memcmp(&((struct sockaddr_in *)&reply->addr)->sin_addr, "\177\0\0", 3); !memcmp(&((struct sockaddr_in *)&reply->addr)->sin_addr, "\177\0\0", 3))
listed = TRUE;
else if (blcptr->blacklist->lastwarning + 3600 < CurrentTime)
{
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Garbage reply from blacklist %s",
blcptr->blacklist->host);
blcptr->blacklist->lastwarning = CurrentTime;
}
} }
/* they have a blacklist entry for this client */ /* they have a blacklist entry for this client */
@ -150,6 +158,7 @@ struct Blacklist *new_blacklist(char *name, char *reject_reason)
blptr->status &= ~CONF_ILLEGAL; blptr->status &= ~CONF_ILLEGAL;
strlcpy(blptr->host, name, HOSTLEN); strlcpy(blptr->host, name, HOSTLEN);
strlcpy(blptr->reject_reason, reject_reason, IRCD_BUFSIZE); strlcpy(blptr->reject_reason, reject_reason, IRCD_BUFSIZE);
blptr->lastwarning = 0;
return blptr; return blptr;
} }