Mercurial > dnsbl
comparison src/dnsbl.cpp @ 138:9d0bc30b4576
add smtp auth rate limits
author | carl |
---|---|
date | Tue, 26 Sep 2006 15:09:46 -0700 |
parents | a6190f7798f4 |
children | 003026deaed1 |
comparison
equal
deleted
inserted
replaced
137:a6190f7798f4 | 138:9d0bc30b4576 |
---|---|
147 // | 147 // |
148 int incr_rcpt_count(char *user); | 148 int incr_rcpt_count(char *user); |
149 int incr_rcpt_count(char *user) { | 149 int incr_rcpt_count(char *user) { |
150 pthread_mutex_lock(&rate_mutex); | 150 pthread_mutex_lock(&rate_mutex); |
151 rcpt_rates::iterator i = rcpt_counts.find(user); | 151 rcpt_rates::iterator i = rcpt_counts.find(user); |
152 int c = (i == rcpt_counts.end()) ? 0 : (*i).second; | 152 int c = 1; |
153 rcpt_counts[user] = c++; | 153 if (i == rcpt_counts.end()) { |
154 user = strdup(user); | |
155 rcpt_counts[user] = c; | |
156 } | |
157 else { | |
158 c = (*i).second++; | |
159 } | |
154 pthread_mutex_unlock(&rate_mutex); | 160 pthread_mutex_unlock(&rate_mutex); |
155 return c; | 161 return c; |
156 } | 162 } |
157 | 163 |
158 //////////////////////////////////////////////// | 164 //////////////////////////////////////////////// |
1171 loop++; | 1177 loop++; |
1172 if (loop == 20) { | 1178 if (loop == 20) { |
1173 // three minutes thru each loop, 20 loops per hour | 1179 // three minutes thru each loop, 20 loops per hour |
1174 // clear the recipient counts | 1180 // clear the recipient counts |
1175 pthread_mutex_lock(&rate_mutex); | 1181 pthread_mutex_lock(&rate_mutex); |
1182 for (rcpt_rates::iterator i=rcpt_counts.begin(); i!=rcpt_counts.end(); i++) { | |
1183 char *x = (*i).first; | |
1184 free(x); | |
1185 } | |
1176 rcpt_counts.clear(); | 1186 rcpt_counts.clear(); |
1177 pthread_mutex_unlock(&rate_mutex); | 1187 pthread_mutex_unlock(&rate_mutex); |
1178 loop = 0; | 1188 loop = 0; |
1179 } | 1189 } |
1180 CONFIG &dc = *config; | 1190 CONFIG &dc = *config; |