comparison 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
comparison
equal deleted inserted replaced
27:43a4f6b3e668 28:33e1e3910506
130 char * host_limit_message; // error message for excessive host names 130 char * host_limit_message; // error message for excessive host names
131 int host_limit; // limit on host names 131 int host_limit; // limit on host names
132 char * tag_limit_message; // error message for excessive bad html tags 132 char * tag_limit_message; // error message for excessive bad html tags
133 int tag_limit; // limit on bad html tags 133 int tag_limit; // limit on bad html tags
134 string_set html_tags; // set of valid html tags 134 string_set html_tags; // set of valid html tags
135 string_set tlds; // set of valid tld components
135 CONFIG(); 136 CONFIG();
136 ~CONFIG(); 137 ~CONFIG();
137 }; 138 };
138 CONFIG::CONFIG() { 139 CONFIG::CONFIG() {
139 reference_count = 0; 140 reference_count = 0;
242 ip = 0; 243 ip = 0;
243 mailaddr = NULL; 244 mailaddr = NULL;
244 authenticated = false; 245 authenticated = false;
245 have_whites = false; 246 have_whites = false;
246 only_whites = true; 247 only_whites = true;
247 memory = new recorder(&pc->html_tags); 248 memory = new recorder(&pc->html_tags, &pc->tlds);
248 scanner = new url_scanner(memory); 249 scanner = new url_scanner(memory);
249 } 250 }
250 mlfiPriv::~mlfiPriv() { 251 mlfiPriv::~mlfiPriv() {
251 pthread_mutex_lock(&config_mutex); 252 pthread_mutex_lock(&config_mutex);
252 pc->reference_count--; 253 pc->reference_count--;
261 if (!final) { 262 if (!final) {
262 mailaddr = NULL; 263 mailaddr = NULL;
263 authenticated = false; 264 authenticated = false;
264 have_whites = false; 265 have_whites = false;
265 only_whites = true; 266 only_whites = true;
266 memory = new recorder(&pc->html_tags); 267 memory = new recorder(&pc->html_tags, &pc->tlds);
267 scanner = new url_scanner(memory); 268 scanner = new url_scanner(memory);
268 } 269 }
269 } 270 }
270 271
271 #define MLFIPRIV ((struct mlfiPriv *) smfi_getpriv(ctx)) 272 #define MLFIPRIV ((struct mlfiPriv *) smfi_getpriv(ctx))
843 844
844 static void load_conf(CONFIG &dc, char *fn); 845 static void load_conf(CONFIG &dc, char *fn);
845 static void load_conf(CONFIG &dc, char *fn) { 846 static void load_conf(CONFIG &dc, char *fn) {
846 dc.config_files.push_back(fn); 847 dc.config_files.push_back(fn);
847 map<char*, int, ltstr> commands; 848 map<char*, int, ltstr> commands;
848 enum {dummy, content, hostlimit, htmllimit, htmltag, dnsbl, dnsbll, envfrom, envto, include, includedcc}; 849 enum {dummy, tld, content, hostlimit, htmllimit, htmltag, dnsbl, dnsbll, envfrom, envto, include, includedcc};
850 commands["tld" ] = tld;
849 commands["content" ] = content; 851 commands["content" ] = content;
850 commands["host_limit" ] = hostlimit; 852 commands["host_limit" ] = hostlimit;
851 commands["html_limit" ] = htmllimit; 853 commands["html_limit" ] = htmllimit;
852 commands["html_tag" ] = htmltag; 854 commands["html_tag" ] = htmltag;
853 commands["dnsbl" ] = dnsbl; 855 commands["dnsbl" ] = dnsbl;
872 char *cmd = strtok(line, delim); 874 char *cmd = strtok(line, delim);
873 if (cmd && (cmd[0] != '#') && (cmd[0] != '\0')) { 875 if (cmd && (cmd[0] != '#') && (cmd[0] != '\0')) {
874 // have a decent command 876 // have a decent command
875 bool processed = false; 877 bool processed = false;
876 switch (commands[cmd]) { 878 switch (commands[cmd]) {
879 case tld: {
880 char *tld = strtok(NULL, delim);
881 if (!tld) break; // no tld value
882 char buf[200];
883 snprintf(buf, sizeof(buf), ".%s", tld);
884 dc.tlds.insert(register_string(buf)); // leading .
885 processed = true;
886 } break;
887
877 case content: { 888 case content: {
878 char *suff = strtok(NULL, delim); 889 char *suff = strtok(NULL, delim);
879 if (!suff) break; // no dns suffix 890 if (!suff) break; // no dns suffix
880 char *msg = suff + strlen(suff); 891 char *msg = suff + strlen(suff);
881 if ((msg - line) >= strlen(orig)) break; // line ended with the dns suffix 892 if ((msg - line) >= strlen(orig)) break; // line ended with the dns suffix