Mercurial > dnsbl
comparison src/context.cpp @ 255:d6d5c50b9278 stable-6-0-30
Allow dnswl_list and dnsbl_list to be empty, to override lists specified in the ancestor contexts. Add daily recipient limits as a multiple of the hourly limits.
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 09 Apr 2012 18:02:05 -0700 |
parents | 15bf4f68a0b2 |
children | be939802c64e |
comparison
equal
deleted
inserted
replaced
254:720cdc2c303f | 255:d6d5c50b9278 |
---|---|
725 tag_limit_message = NULL; | 725 tag_limit_message = NULL; |
726 spamassassin_limit = (parent) ? parent->spamassassin_limit : 0; | 726 spamassassin_limit = (parent) ? parent->spamassassin_limit : 0; |
727 require_match = (parent) ? parent->require_match : false; | 727 require_match = (parent) ? parent->require_match : false; |
728 dcc_greylist = (parent) ? parent->dcc_greylist : false; | 728 dcc_greylist = (parent) ? parent->dcc_greylist : false; |
729 dcc_bulk_threshold = (parent) ? parent->dcc_bulk_threshold : 0; | 729 dcc_bulk_threshold = (parent) ? parent->dcc_bulk_threshold : 0; |
730 default_rcpt_rate = INT_MAX; | 730 dnsbl_list_parsed = false; |
731 dnswl_list_parsed = false; | |
732 default_rcpt_rate = 36000; // 10 per second | |
733 rcpt_daily_multiple = 3; | |
731 } | 734 } |
732 | 735 |
733 | 736 |
734 CONTEXT::~CONTEXT() { | 737 CONTEXT::~CONTEXT() { |
735 for (dnsblp_map::iterator i=dnsbl_names.begin(); i!=dnsbl_names.end(); i++) { | 738 for (dnsblp_map::iterator i=dnsbl_names.begin(); i!=dnsbl_names.end(); i++) { |
989 return html_tags; | 992 return html_tags; |
990 } | 993 } |
991 | 994 |
992 | 995 |
993 dnsblp_list& CONTEXT::get_dnsbl_list() { | 996 dnsblp_list& CONTEXT::get_dnsbl_list() { |
994 if (dnsbl_list.empty() && parent) return parent->get_dnsbl_list(); | 997 if (!dnsbl_list_parsed && parent) return parent->get_dnsbl_list(); |
995 return dnsbl_list; | 998 return dnsbl_list; |
996 } | 999 } |
997 | 1000 |
998 | 1001 |
999 dnswlp_list& CONTEXT::get_dnswl_list() { | 1002 dnswlp_list& CONTEXT::get_dnswl_list() { |
1000 if (dnswl_list.empty() && parent) return parent->get_dnswl_list(); | 1003 if (!dnswl_list_parsed && parent) return parent->get_dnswl_list(); |
1001 return dnswl_list; | 1004 return dnswl_list; |
1002 } | 1005 } |
1003 | 1006 |
1004 | 1007 |
1005 bool CONTEXT::acceptable_content(recorder &memory, int score, int bulk, string& msg) { | 1008 bool CONTEXT::acceptable_content(recorder &memory, int score, int bulk, string& msg) { |
1047 DNSWL &d = *(*i).second; | 1050 DNSWL &d = *(*i).second; |
1048 printf("%s dnswl %s %s %d; \n", indent, n, d.suffix, d.level); | 1051 printf("%s dnswl %s %s %d; \n", indent, n, d.suffix, d.level); |
1049 } | 1052 } |
1050 | 1053 |
1051 { | 1054 { |
1052 dnsblp_list dl = get_dnsbl_list(); | 1055 dnsblp_list dl = get_dnsbl_list(); |
1053 if (!dl.empty()) { | |
1054 printf("%s dnsbl_list", indent); | 1056 printf("%s dnsbl_list", indent); |
1055 for (dnsblp_list::iterator i=dl.begin(); i!=dl.end(); i++) { | 1057 for (dnsblp_list::iterator i=dl.begin(); i!=dl.end(); i++) { |
1056 DNSBL &d = *(*i); | 1058 DNSBL &d = *(*i); |
1057 printf(" %s", d.name); | 1059 printf(" %s", d.name); |
1058 } | 1060 } |
1059 printf("; \n"); | 1061 printf("; \n"); |
1060 }} | 1062 } |
1061 | 1063 |
1062 { | 1064 { |
1063 dnswlp_list dl = get_dnswl_list(); | 1065 dnswlp_list dl = get_dnswl_list(); |
1064 if (!dl.empty()) { | |
1065 printf("%s dnswl_list", indent); | 1066 printf("%s dnswl_list", indent); |
1066 for (dnswlp_list::iterator i=dl.begin(); i!=dl.end(); i++) { | 1067 for (dnswlp_list::iterator i=dl.begin(); i!=dl.end(); i++) { |
1067 DNSWL &d = *(*i); | 1068 DNSWL &d = *(*i); |
1068 printf(" %s", d.name); | 1069 printf(" %s", d.name); |
1069 } | 1070 } |
1070 printf("; \n"); | 1071 printf("; \n"); |
1071 }} | 1072 } |
1072 | 1073 |
1073 if (content_filtering) { | 1074 if (content_filtering) { |
1074 printf("%s content on { \n", indent); | 1075 printf("%s content on { \n", indent); |
1075 if (content_suffix) { | 1076 if (content_suffix) { |
1076 printf("%s filter %s \"%s\"; \n", indent, content_suffix, content_message); | 1077 printf("%s filter %s \"%s\"; \n", indent, content_suffix, content_message); |
1183 } | 1184 } |
1184 } | 1185 } |
1185 printf("%s }; \n", indent); | 1186 printf("%s }; \n", indent); |
1186 | 1187 |
1187 if (isdefault) { | 1188 if (isdefault) { |
1188 printf("%s rate_limit %d { \n", indent, default_rcpt_rate); | 1189 printf("%s rate_limit %d %d { \n", indent, default_rcpt_rate, rcpt_daily_multiple); |
1189 for (rcpt_rates::iterator j=rcpt_per_hour.begin(); j!=rcpt_per_hour.end(); j++) { | 1190 for (rcpt_rates::iterator j=rcpt_per_hour.begin(); j!=rcpt_per_hour.end(); j++) { |
1190 const char *u = (*j).first; | 1191 const char *u = (*j).first; |
1191 int l = (*j).second; | 1192 int l = (*j).second; |
1192 printf("%s \"%s\" \t%d; \n", indent, u, l); | 1193 printf("%s \"%s\" \t%d; \n", indent, u, l); |
1193 } | 1194 } |
1303 else { | 1304 else { |
1304 tok.token_error("dnsbl name", have); | 1305 tok.token_error("dnsbl name", have); |
1305 return false; | 1306 return false; |
1306 } | 1307 } |
1307 } | 1308 } |
1309 me.set_dnsbll_parsed(); | |
1308 return true; | 1310 return true; |
1309 } | 1311 } |
1310 | 1312 |
1311 | 1313 |
1312 //////////////////////////////////////////////// | 1314 //////////////////////////////////////////////// |
1324 else { | 1326 else { |
1325 tok.token_error("dnswl name", have); | 1327 tok.token_error("dnswl name", have); |
1326 return false; | 1328 return false; |
1327 } | 1329 } |
1328 } | 1330 } |
1331 me.set_dnswll_parsed(); | |
1329 return true; | 1332 return true; |
1330 } | 1333 } |
1331 | 1334 |
1332 | 1335 |
1333 //////////////////////////////////////////////// | 1336 //////////////////////////////////////////////// |
1703 bool parse_rate(TOKEN &tok, CONFIG &dc, CONTEXT &me); | 1706 bool parse_rate(TOKEN &tok, CONFIG &dc, CONTEXT &me); |
1704 bool parse_rate(TOKEN &tok, CONFIG &dc, CONTEXT &me) { | 1707 bool parse_rate(TOKEN &tok, CONFIG &dc, CONTEXT &me) { |
1705 const char *def = tok.next(); | 1708 const char *def = tok.next(); |
1706 tok.push(def); | 1709 tok.push(def); |
1707 if (def != token_lbrace) me.set_default_rate(tok.nextint()); | 1710 if (def != token_lbrace) me.set_default_rate(tok.nextint()); |
1711 | |
1712 def = tok.next(); | |
1713 tok.push(def); | |
1714 if (def != token_lbrace) me.set_daily_multiple(tok.nextint()); | |
1715 | |
1708 if (!tsa(tok, token_lbrace)) return false; | 1716 if (!tsa(tok, token_lbrace)) return false; |
1709 while (true) { | 1717 while (true) { |
1710 const char *have = tok.next(); | 1718 const char *have = tok.next(); |
1711 if (!have) break; | 1719 if (!have) break; |
1712 if (have == token_rbrace) break; | 1720 if (have == token_rbrace) break; |