Mercurial > dnsbl
comparison src/dnsbl.cpp @ 168:6bac960af6b4
add generic reverse dns filtering regex
author | carl |
---|---|
date | Thu, 30 Aug 2007 11:08:46 -0700 |
parents | 9b129ed78d7d |
children | d3189495ec68 |
comparison
equal
deleted
inserted
replaced
167:9b129ed78d7d | 168:6bac960af6b4 |
---|---|
247 ip = 0; | 247 ip = 0; |
248 helo = NULL; | 248 helo = NULL; |
249 mailaddr = NULL; | 249 mailaddr = NULL; |
250 queueid = NULL; | 250 queueid = NULL; |
251 authenticated = NULL; | 251 authenticated = NULL; |
252 client_name = NULL; | |
252 have_whites = false; | 253 have_whites = false; |
253 only_whites = true; | 254 only_whites = true; |
254 want_spamassassin = false; | 255 want_spamassassin = false; |
255 memory = NULL; | 256 memory = NULL; |
256 scanner = NULL; | 257 scanner = NULL; |
275 | 276 |
276 void mlfiPriv::reset(bool final) { | 277 void mlfiPriv::reset(bool final) { |
277 if (mailaddr) free(mailaddr); | 278 if (mailaddr) free(mailaddr); |
278 if (queueid) free(queueid); | 279 if (queueid) free(queueid); |
279 if (authenticated) free(authenticated); | 280 if (authenticated) free(authenticated); |
281 if (client_name) free(client_name); | |
280 discard(env_to); | 282 discard(env_to); |
281 if (memory) delete memory; | 283 if (memory) delete memory; |
282 if (scanner) delete scanner; | 284 if (scanner) delete scanner; |
283 if (assassin) delete assassin; | 285 if (assassin) delete assassin; |
284 if (!final) { | 286 if (!final) { |
285 mailaddr = NULL; | 287 mailaddr = NULL; |
286 queueid = NULL; | 288 queueid = NULL; |
287 authenticated = NULL; | 289 authenticated = NULL; |
290 client_name = NULL; | |
288 have_whites = false; | 291 have_whites = false; |
289 only_whites = true; | 292 only_whites = true; |
290 want_spamassassin = false; | 293 want_spamassassin = false; |
291 memory = NULL; | 294 memory = NULL; |
292 scanner = NULL; | 295 scanner = NULL; |
963 { | 966 { |
964 mlfiPriv &priv = *MLFIPRIV; | 967 mlfiPriv &priv = *MLFIPRIV; |
965 priv.mailaddr = to_lower_string(from[0]); | 968 priv.mailaddr = to_lower_string(from[0]); |
966 priv.queueid = strdup(smfi_getsymval(ctx, "i")); | 969 priv.queueid = strdup(smfi_getsymval(ctx, "i")); |
967 priv.authenticated = smfi_getsymval(ctx, "{auth_authen}"); | 970 priv.authenticated = smfi_getsymval(ctx, "{auth_authen}"); |
971 priv.client_name = smfi_getsymval(ctx, "_"); | |
968 if (priv.authenticated) priv.authenticated = strdup(priv.authenticated); | 972 if (priv.authenticated) priv.authenticated = strdup(priv.authenticated); |
973 if (priv.client_name) priv.client_name = strdup(priv.client_name); | |
969 if (spamc != spamc_empty) { | 974 if (spamc != spamc_empty) { |
970 priv.assassin = new SpamAssassin(&priv, priv.ip, priv.helo, priv.mailaddr, priv.queueid); | 975 priv.assassin = new SpamAssassin(&priv, priv.ip, priv.helo, priv.mailaddr, priv.queueid); |
971 } | 976 } |
972 return SMFIS_CONTINUE; | 977 return SMFIS_CONTINUE; |
973 } | 978 } |
1029 char adr[sizeof "255.255.255.255"]; | 1034 char adr[sizeof "255.255.255.255"]; |
1030 adr[0] = '\0'; | 1035 adr[0] = '\0'; |
1031 inet_ntop(AF_INET, (const u_char *)&priv.ip, adr, sizeof(adr)); | 1036 inet_ntop(AF_INET, (const u_char *)&priv.ip, adr, sizeof(adr)); |
1032 char buf[maxlen]; | 1037 char buf[maxlen]; |
1033 snprintf(buf, sizeof(buf), rejectlist->message, adr, adr); | 1038 snprintf(buf, sizeof(buf), rejectlist->message, adr, adr); |
1039 smfi_setreply(ctx, "550", "5.7.1", buf); | |
1040 return SMFIS_REJECT; | |
1041 } | |
1042 char *msg = con.generic_match(priv.client_name); | |
1043 if (msg) { | |
1044 // reject the recipient based on generic reverse dns | |
1045 char buf[maxlen]; | |
1046 snprintf(buf, sizeof(buf), msg, priv.client_name); | |
1034 smfi_setreply(ctx, "550", "5.7.1", buf); | 1047 smfi_setreply(ctx, "550", "5.7.1", buf); |
1035 return SMFIS_REJECT; | 1048 return SMFIS_REJECT; |
1036 } | 1049 } |
1037 if (st == black) { | 1050 if (st == black) { |
1038 // reject the recipient based on blacklisting either from or to | 1051 // reject the recipient based on blacklisting either from or to |