comparison src/dnsbl.cpp @ 57:419e00901570

changes to handle 5iantlavalamp.com
author carl
date Thu, 28 Oct 2004 22:48:52 -0700
parents 44babba1a9b9
children 7bb8bbf79285
comparison
equal deleted inserted replaced
56:57607387263d 57:419e00901570
140 from_map env_from; 140 from_map env_from;
141 string_map env_to_dnsbll; // map recipient to a named dnsbll 141 string_map env_to_dnsbll; // map recipient to a named dnsbll
142 string_map env_to_chkfrom; // map recipient to a named from map 142 string_map env_to_chkfrom; // map recipient to a named from map
143 char * content_suffix; // for sbl url body filtering 143 char * content_suffix; // for sbl url body filtering
144 char * content_message; // "" 144 char * content_message; // ""
145 string_set content_host_ignore;// hosts to ignore for content sbl checking
145 char * host_limit_message; // error message for excessive host names 146 char * host_limit_message; // error message for excessive host names
146 int host_limit; // limit on host names 147 int host_limit; // limit on host names
147 bool host_random; // pick a random selection of host names rather than error for excessive hosts 148 bool host_random; // pick a random selection of host names rather than error for excessive hosts
148 char * tag_limit_message; // error message for excessive bad html tags 149 char * tag_limit_message; // error message for excessive bad html tags
149 int tag_limit; // limit on bad html tags 150 int tag_limit; // limit on bad html tags
606 int lim = priv.pc->host_limit; // we should not look at more than this many hosts 607 int lim = priv.pc->host_limit; // we should not look at more than this many hosts
607 int cnt = priv.memory->hosts.size(); // number of hosts we could look at 608 int cnt = priv.memory->hosts.size(); // number of hosts we could look at
608 int_set ips; // remove duplicate ip addresses 609 int_set ips; // remove duplicate ip addresses
609 for (string_set::iterator i=priv.memory->hosts.begin(); i!=priv.memory->hosts.end(); i++) { 610 for (string_set::iterator i=priv.memory->hosts.begin(); i!=priv.memory->hosts.end(); i++) {
610 host = *i; // a reference into priv.memory->hosts, which will live until this smtp transaction is closed 611 host = *i; // a reference into priv.memory->hosts, which will live until this smtp transaction is closed
612 string_set::iterator j = priv.pc->content_host_ignore.find(host);
613 if (j == priv.pc->content_host_ignore.end()) {
614 continue; // don't bother looking up this host
615 }
611 if ((cnt > lim) && (lim > 0) && ran) { 616 if ((cnt > lim) && (lim > 0) && ran) {
612 // try to only look at lim/cnt fraction of the available cnt host names 617 // try to only look at lim/cnt fraction of the available cnt host names
613 int r = rand() % cnt; 618 int r = rand() % cnt;
614 if (r >= lim) { 619 if (r >= lim) {
615 char buf[1000]; 620 char buf[1000];
927 } 932 }
928 fprintf(stdout, "\n"); 933 fprintf(stdout, "\n");
929 } 934 }
930 if (dc.content_suffix) { 935 if (dc.content_suffix) {
931 fprintf(stdout, "\ncontent filtering enabled with %s %s\n", dc.content_suffix, dc.content_message); 936 fprintf(stdout, "\ncontent filtering enabled with %s %s\n", dc.content_suffix, dc.content_message);
937 }
938 for (string_set::iterator i=dc.content_host_ignore.begin(); i!=dc.content_host_ignore.end(); i++) {
939 fprintf(stdout, "ignore %s\n", (*i));
932 } 940 }
933 if (dc.host_limit && !dc.host_random) { 941 if (dc.host_limit && !dc.host_random) {
934 fprintf(stdout, "\ncontent filtering for host names hard limit %d %s\n", dc.host_limit, dc.host_limit_message); 942 fprintf(stdout, "\ncontent filtering for host names hard limit %d %s\n", dc.host_limit, dc.host_limit_message);
935 } 943 }
936 if (dc.host_limit && dc.host_random) { 944 if (dc.host_limit && dc.host_random) {
1046 my_syslog(buf); 1054 my_syslog(buf);
1047 return; 1055 return;
1048 } 1056 }
1049 dc.config_files.push_back(fn); 1057 dc.config_files.push_back(fn);
1050 map<char*, int, ltstr> commands; 1058 map<char*, int, ltstr> commands;
1051 enum {dummy, tld, content, hostlimit, hostslimit, htmllimit, htmltag, dnsbl, dnsbll, envfrom, envto, include, includedcc}; 1059 enum {dummy, tld, content, ignore, hostlimit, hostslimit, htmllimit, htmltag, dnsbl, dnsbll, envfrom, envto, include, includedcc};
1052 commands["tld" ] = tld; 1060 commands["tld" ] = tld;
1053 commands["content" ] = content; 1061 commands["content" ] = content;
1062 commands["ignore" ] = ignore;
1054 commands["host_limit" ] = hostlimit; 1063 commands["host_limit" ] = hostlimit;
1055 commands["host_soft_limit"] = hostslimit; 1064 commands["host_soft_limit"] = hostslimit;
1056 commands["html_limit" ] = htmllimit; 1065 commands["html_limit" ] = htmllimit;
1057 commands["html_tag" ] = htmltag; 1066 commands["html_tag" ] = htmltag;
1058 commands["dnsbl" ] = dnsbl; 1067 commands["dnsbl" ] = dnsbl;
1099 dc.content_suffix = register_string(suff); 1108 dc.content_suffix = register_string(suff);
1100 dc.content_message = register_string(msg); 1109 dc.content_message = register_string(msg);
1101 processed = true; 1110 processed = true;
1102 } break; 1111 } break;
1103 1112
1113 case ignore: {
1114 char *host = next_token(delim);
1115 if (!host) break;
1116 dc.content_host_ignore.insert(host);
1117 processed = true;
1118 } break;
1119
1104 case hostlimit: { 1120 case hostlimit: {
1105 char *limit = strtok(NULL, delim); 1121 char *limit = strtok(NULL, delim);
1106 if (!limit) break; // no integer limit 1122 if (!limit) break; // no integer limit
1107 char *msg = limit + strlen(limit); 1123 char *msg = limit + strlen(limit);
1108 if ((msg - line) >= strlen(orig)) break; // line ended with the limit 1124 if ((msg - line) >= strlen(orig)) break; // line ended with the limit