comparison src/context.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 d6d5c50b9278
children e118fd2c6af0
comparison
equal deleted inserted replaced
258:7a16904fec66 259:be939802c64e
841 } 841 }
842 842
843 843
844 int CONTEXT::find_rate(const char *user) { 844 int CONTEXT::find_rate(const char *user) {
845 if (rcpt_per_hour.empty()) return default_rcpt_rate; 845 if (rcpt_per_hour.empty()) return default_rcpt_rate;
846 rcpt_rates::iterator i = rcpt_per_hour.find(user); 846 rcpt_rates::iterator i = rcpt_per_hour.find(user); // look for authen id, or sender user@email limiting
847 return (i == rcpt_per_hour.end()) ? default_rcpt_rate : (*i).second; 847 if (i != rcpt_per_hour.end()) return (*i).second; // found authen id, or user@email limiting
848 const char *f = strchr(user, '@');
849 if (!f) return default_rcpt_rate;
850 i = rcpt_per_hour.find(f); // look for @domain limiting
851 if (i != rcpt_per_hour.end()) return (*i).second; // found @domain limiting
852 return default_rcpt_rate;
853 }
854
855
856 bool CONTEXT::is_unauthenticated_limited(const char *user) {
857 rcpt_rates::iterator i = rcpt_per_hour.find(user); // look for sender user@email limiting
858 if (i != rcpt_per_hour.end()) return true; // found user@email limiting
859 const char *f = strchr(user, '@');
860 i = rcpt_per_hour.find(f); // look for sender @domain limiting
861 return (i != rcpt_per_hour.end()); // found @domain limiting
848 } 862 }
849 863
850 864
851 const char *CONTEXT::find_from(const char *from, bool update_white, const char *queueid) { 865 const char *CONTEXT::find_from(const char *from, bool update_white, const char *queueid) {
852 WHITELISTERP w = whitelister; 866 WHITELISTERP w = whitelister;