diff 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
line wrap: on
line diff
--- a/src/context.cpp	Sun Apr 08 16:17:53 2012 -0700
+++ b/src/context.cpp	Mon Apr 09 18:02:05 2012 -0700
@@ -727,7 +727,10 @@
     require_match       = (parent) ? parent->require_match      : false;
     dcc_greylist        = (parent) ? parent->dcc_greylist       : false;
     dcc_bulk_threshold  = (parent) ? parent->dcc_bulk_threshold : 0;
-    default_rcpt_rate   = INT_MAX;
+    dnsbl_list_parsed   = false;
+    dnswl_list_parsed   = false;
+    default_rcpt_rate   = 36000;        // 10 per second
+    rcpt_daily_multiple = 3;
 }
 
 
@@ -991,13 +994,13 @@
 
 
 dnsblp_list& CONTEXT::get_dnsbl_list() {
-    if (dnsbl_list.empty() && parent) return parent->get_dnsbl_list();
+    if (!dnsbl_list_parsed && parent) return parent->get_dnsbl_list();
     return dnsbl_list;
 }
 
 
 dnswlp_list& CONTEXT::get_dnswl_list() {
-    if (dnswl_list.empty() && parent) return parent->get_dnswl_list();
+    if (!dnswl_list_parsed && parent) return parent->get_dnswl_list();
     return dnswl_list;
 }
 
@@ -1050,25 +1053,23 @@
 
     {
     dnsblp_list dl = get_dnsbl_list();
-    if (!dl.empty()) {
         printf("%s     dnsbl_list", indent);
         for (dnsblp_list::iterator i=dl.begin(); i!=dl.end(); i++) {
             DNSBL &d = *(*i);
             printf(" %s", d.name);
         }
         printf("; \n");
-    }}
+    }
 
     {
     dnswlp_list dl = get_dnswl_list();
-    if (!dl.empty()) {
         printf("%s     dnswl_list", indent);
         for (dnswlp_list::iterator i=dl.begin(); i!=dl.end(); i++) {
             DNSWL &d = *(*i);
             printf(" %s", d.name);
         }
         printf("; \n");
-    }}
+    }
 
     if (content_filtering) {
         printf("%s     content on { \n", indent);
@@ -1185,7 +1186,7 @@
     printf("%s     }; \n", indent);
 
     if (isdefault) {
-        printf("%s     rate_limit %d { \n", indent, default_rcpt_rate);
+        printf("%s     rate_limit %d %d { \n", indent, default_rcpt_rate, rcpt_daily_multiple);
         for (rcpt_rates::iterator j=rcpt_per_hour.begin(); j!=rcpt_per_hour.end(); j++) {
             const char *u = (*j).first;
             int         l = (*j).second;
@@ -1305,6 +1306,7 @@
             return false;
         }
     }
+    me.set_dnsbll_parsed();
     return true;
 }
 
@@ -1326,6 +1328,7 @@
             return false;
         }
     }
+    me.set_dnswll_parsed();
     return true;
 }
 
@@ -1705,6 +1708,11 @@
     const char *def = tok.next();
     tok.push(def);
     if (def != token_lbrace) me.set_default_rate(tok.nextint());
+
+    def = tok.next();
+    tok.push(def);
+    if (def != token_lbrace) me.set_daily_multiple(tok.nextint());
+
     if (!tsa(tok, token_lbrace)) return false;
     while (true) {
         const char *have = tok.next();