diff src/dnsbl.cpp @ 28:33e1e3910506

add configurable list of tlds
author carl
date Thu, 27 May 2004 10:08:51 -0700
parents 43a4f6b3e668
children 4dfdf33f1db0
line wrap: on
line diff
--- a/src/dnsbl.cpp	Sat May 22 22:30:45 2004 -0700
+++ b/src/dnsbl.cpp	Thu May 27 10:08:51 2004 -0700
@@ -132,6 +132,7 @@
     char *      tag_limit_message;  // error message for excessive bad html tags
     int         tag_limit;          // limit on bad html tags
     string_set  html_tags;          // set of valid html tags
+    string_set  tlds;               // set of valid tld components
     CONFIG();
     ~CONFIG();
 };
@@ -244,7 +245,7 @@
     authenticated = false;
     have_whites   = false;
     only_whites   = true;
-    memory        = new recorder(&pc->html_tags);
+    memory        = new recorder(&pc->html_tags, &pc->tlds);
     scanner       = new url_scanner(memory);
 }
 mlfiPriv::~mlfiPriv() {
@@ -263,7 +264,7 @@
         authenticated = false;
         have_whites   = false;
         only_whites   = true;
-        memory        = new recorder(&pc->html_tags);
+        memory        = new recorder(&pc->html_tags, &pc->tlds);
         scanner       = new url_scanner(memory);
     }
 }
@@ -845,7 +846,8 @@
 static void load_conf(CONFIG &dc, char *fn) {
     dc.config_files.push_back(fn);
     map<char*, int, ltstr> commands;
-    enum {dummy, content, hostlimit, htmllimit, htmltag, dnsbl, dnsbll, envfrom, envto, include, includedcc};
+    enum {dummy, tld, content, hostlimit, htmllimit, htmltag, dnsbl, dnsbll, envfrom, envto, include, includedcc};
+    commands["tld"        ] = tld;
     commands["content"    ] = content;
     commands["host_limit" ] = hostlimit;
     commands["html_limit" ] = htmllimit;
@@ -874,6 +876,15 @@
             // have a decent command
             bool processed = false;
             switch (commands[cmd]) {
+                case tld: {
+                    char *tld = strtok(NULL, delim);
+                    if (!tld) break;                            // no tld value
+                    char buf[200];
+                    snprintf(buf, sizeof(buf), ".%s", tld);
+                    dc.tlds.insert(register_string(buf));       // leading .
+                    processed = true;
+                    } break;
+
                 case content: {
                     char *suff = strtok(NULL, delim);
                     if (!suff) break;                           // no dns suffix