diff src/dnsbl.cpp @ 259:be939802c64e

add recipient rate limits by email from address or domain
author Carl Byington <carl@five-ten-sg.com>
date Sat, 21 Jul 2012 08:34:04 -0700
parents d11b529ce9c5
children e118fd2c6af0
line wrap: on
line diff
--- a/src/dnsbl.cpp	Sun Jul 01 10:34:43 2012 -0700
+++ b/src/dnsbl.cpp	Sat Jul 21 08:34:04 2012 -0700
@@ -1143,9 +1143,9 @@
             uint pp = p - priv.client_name;
             priv.client_dns_name = strdup(priv.client_name);
             priv.client_dns_name[pp] = '\0';
-            char text[500];
-            snprintf(text, sizeof(text), "found simple dns client name %s", priv.client_dns_name);
-            my_syslog(text);
+            //char text[500];
+            //snprintf(text, sizeof(text), "found simple dns client name %s", priv.client_dns_name);
+            //my_syslog(text);
         }
     }
     if (spamc != spamc_empty) {
@@ -1194,6 +1194,21 @@
         smfi_setreply(ctx, (char*)"550", (char*)"5.7.1", (char*)"recipient can not reply due to blacklisting");
         return SMFIS_REJECT;
     }
+    if (!priv.authenticated && dc.default_context->is_unauthenticated_limited(priv.mailaddr)) {
+        int hourly, daily;
+        incr_rcpt_count(priv.mailaddr, hourly, daily);
+        int h_limit = dc.default_context->find_rate(priv.mailaddr);
+        int d_limit = dc.default_context->get_daily_multiple() * h_limit;
+        if (debug_syslog > 1) {
+            char msg[maxlen];
+            snprintf(msg, sizeof(msg), "unauthenticated address %s (%d %d recipients, %d %d limits)", priv.mailaddr, hourly, daily, h_limit, d_limit);
+            my_syslog(&priv, msg);
+        }
+        if ((hourly > h_limit) || (daily > d_limit)){
+            smfi_setreply(ctx, (char*)"550", (char*)"5.7.1", (char*)"recipient rate limit exceeded");
+            return SMFIS_REJECT;
+        }
+    }
     if (priv.authenticated) {
         int hourly, daily;
         incr_rcpt_count(priv.authenticated, hourly, daily);