diff 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
line wrap: on
line diff
--- a/src/dnsbl.cpp	Mon Aug 27 20:49:19 2007 -0700
+++ b/src/dnsbl.cpp	Thu Aug 30 11:08:46 2007 -0700
@@ -249,6 +249,7 @@
 	mailaddr			= NULL;
 	queueid 			= NULL;
 	authenticated		= NULL;
+	client_name 		= NULL;
 	have_whites 		= false;
 	only_whites 		= true;
 	want_spamassassin	= false;
@@ -277,6 +278,7 @@
 	if (mailaddr)	   free(mailaddr);
 	if (queueid)	   free(queueid);
 	if (authenticated) free(authenticated);
+	if (client_name)   free(client_name);
 	discard(env_to);
 	if (memory)   delete memory;
 	if (scanner)  delete scanner;
@@ -285,6 +287,7 @@
 		mailaddr			= NULL;
 		queueid 			= NULL;
 		authenticated		= NULL;
+		client_name 		= NULL;
 		have_whites 		= false;
 		only_whites 		= true;
 		want_spamassassin	= false;
@@ -965,7 +968,9 @@
 	priv.mailaddr	   = to_lower_string(from[0]);
 	priv.queueid	   = strdup(smfi_getsymval(ctx, "i"));
 	priv.authenticated = smfi_getsymval(ctx, "{auth_authen}");
+	priv.client_name   = smfi_getsymval(ctx, "_");
 	if (priv.authenticated) priv.authenticated = strdup(priv.authenticated);
+	if (priv.client_name)	priv.client_name   = strdup(priv.client_name);
 	if (spamc != spamc_empty) {
 		priv.assassin  = new SpamAssassin(&priv, priv.ip, priv.helo, priv.mailaddr, priv.queueid);
 	}
@@ -1034,6 +1039,14 @@
 		smfi_setreply(ctx, "550", "5.7.1", buf);
 		return SMFIS_REJECT;
 	}
+	char *msg = con.generic_match(priv.client_name);
+	if (msg) {
+		// reject the recipient based on generic reverse dns
+		char buf[maxlen];
+		snprintf(buf, sizeof(buf), msg, priv.client_name);
+		smfi_setreply(ctx, "550", "5.7.1", buf);
+		return SMFIS_REJECT;
+	}
 	if (st == black) {
 		// reject the recipient based on blacklisting either from or to
 		smfi_setreply(ctx, "550", "5.7.1", "no such user");