X-Git-Url: https://jfr.im/git/irc/rqf/shadowircd.git/blobdiff_plain/212380e3f42f585dc1ea927402252eb943f91f7b..b37edd511a0db4a1705753a9072274ae310b864e:/src/blacklist.c diff --git a/src/blacklist.c b/src/blacklist.c index 382ea91..766807f 100644 --- a/src/blacklist.c +++ b/src/blacklist.c @@ -2,7 +2,7 @@ * charybdis: A slightly useful ircd. * blacklist.c: Manages DNS blacklist entries and lookups * - * Copyright (C) 2006 charybdis development team + * Copyright (C) 2006-2008 charybdis development team * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -65,6 +65,7 @@ static struct Blacklist *find_blacklist(char *name) static void blacklist_dns_callback(void *vptr, struct DNSReply *reply) { struct BlacklistClient *blcptr = (struct BlacklistClient *) vptr; + int listed = 0; if (blcptr == NULL || blcptr->client_p == NULL) return; @@ -77,8 +78,23 @@ static void blacklist_dns_callback(void *vptr, struct DNSReply *reply) return; } + if (reply != NULL) + { + /* only accept 127.0.0.x as a listing */ + 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 */ - if (reply != NULL && blcptr->client_p->preClient->dnsbl_listed == NULL) + if (listed && blcptr->client_p->preClient->dnsbl_listed == NULL) { blcptr->client_p->preClient->dnsbl_listed = blcptr->blacklist; /* reference to blacklist moves from blcptr to client_p->preClient... */ @@ -142,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; }