]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/blacklist.c
Cleanups to 005 code, from ratbox (androsyn).
[irc/rqf/shadowircd.git] / src / blacklist.c
index 382ea9139b0e448f7df44e4d94f7f9bc2293d4aa..766807f057fbea53869605dca60f59b0b6f615c5 100644 (file)
@@ -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;
 }