comparison 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
comparison
equal deleted inserted replaced
258:7a16904fec66 259:be939802c64e
1141 const char *p = strstr(priv.client_name, " ["); 1141 const char *p = strstr(priv.client_name, " [");
1142 if (p) { 1142 if (p) {
1143 uint pp = p - priv.client_name; 1143 uint pp = p - priv.client_name;
1144 priv.client_dns_name = strdup(priv.client_name); 1144 priv.client_dns_name = strdup(priv.client_name);
1145 priv.client_dns_name[pp] = '\0'; 1145 priv.client_dns_name[pp] = '\0';
1146 char text[500]; 1146 //char text[500];
1147 snprintf(text, sizeof(text), "found simple dns client name %s", priv.client_dns_name); 1147 //snprintf(text, sizeof(text), "found simple dns client name %s", priv.client_dns_name);
1148 my_syslog(text); 1148 //my_syslog(text);
1149 } 1149 }
1150 } 1150 }
1151 if (spamc != spamc_empty) { 1151 if (spamc != spamc_empty) {
1152 priv.assassin = new SpamAssassin(&priv, priv.ip, priv.helo, priv.mailaddr, priv.queueid); 1152 priv.assassin = new SpamAssassin(&priv, priv.ip, priv.helo, priv.mailaddr, priv.queueid);
1153 } 1153 }
1191 free((void*)loto); 1191 free((void*)loto);
1192 status st; 1192 status st;
1193 if (replyvalue == token_black) { 1193 if (replyvalue == token_black) {
1194 smfi_setreply(ctx, (char*)"550", (char*)"5.7.1", (char*)"recipient can not reply due to blacklisting"); 1194 smfi_setreply(ctx, (char*)"550", (char*)"5.7.1", (char*)"recipient can not reply due to blacklisting");
1195 return SMFIS_REJECT; 1195 return SMFIS_REJECT;
1196 }
1197 if (!priv.authenticated && dc.default_context->is_unauthenticated_limited(priv.mailaddr)) {
1198 int hourly, daily;
1199 incr_rcpt_count(priv.mailaddr, hourly, daily);
1200 int h_limit = dc.default_context->find_rate(priv.mailaddr);
1201 int d_limit = dc.default_context->get_daily_multiple() * h_limit;
1202 if (debug_syslog > 1) {
1203 char msg[maxlen];
1204 snprintf(msg, sizeof(msg), "unauthenticated address %s (%d %d recipients, %d %d limits)", priv.mailaddr, hourly, daily, h_limit, d_limit);
1205 my_syslog(&priv, msg);
1206 }
1207 if ((hourly > h_limit) || (daily > d_limit)){
1208 smfi_setreply(ctx, (char*)"550", (char*)"5.7.1", (char*)"recipient rate limit exceeded");
1209 return SMFIS_REJECT;
1210 }
1196 } 1211 }
1197 if (priv.authenticated) { 1212 if (priv.authenticated) {
1198 int hourly, daily; 1213 int hourly, daily;
1199 incr_rcpt_count(priv.authenticated, hourly, daily); 1214 incr_rcpt_count(priv.authenticated, hourly, daily);
1200 int h_limit = dc.default_context->find_rate(priv.authenticated); 1215 int h_limit = dc.default_context->find_rate(priv.authenticated);