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 af8392050c
commit c41a85dfb6
2 changed files with 12 additions and 2 deletions

View File

@ -32,6 +32,7 @@ struct Blacklist {
char host[HOSTLEN];
char reject_reason[IRCD_BUFSIZE];
unsigned int hits;
time_t lastwarning;
};
/* 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)
{
/* only accept 127.0.0.x as a listing */
listed = reply->addr.ss_family == AF_INET &&
!memcmp(&((struct sockaddr_in *)&reply->addr)->sin_addr, "\177\0\0", 3);
if (reply->addr.ss_family == AF_INET &&
!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 */
@ -150,6 +158,7 @@ struct Blacklist *new_blacklist(char *name, char *reject_reason)
blptr->status &= ~CONF_ILLEGAL;
strlcpy(blptr->host, name, HOSTLEN);
strlcpy(blptr->reject_reason, reject_reason, IRCD_BUFSIZE);
blptr->lastwarning = 0;
return blptr;
}