From d0300cbd91cfb6c17cab5f201074b439ac270eac Mon Sep 17 00:00:00 2001 From: adam Date: Sat, 1 Mar 2008 05:58:58 +0000 Subject: [PATCH] add hack to deal with comcast pathetic retry policy darcs-hash:20080301055858-5007d-10e6afff567f620e96d6f7cab94a867666f497f0.gz --- src/org/ibex/mail/Graylist.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/org/ibex/mail/Graylist.java b/src/org/ibex/mail/Graylist.java index a23581e..1f65dd4 100644 --- a/src/org/ibex/mail/Graylist.java +++ b/src/org/ibex/mail/Graylist.java @@ -37,7 +37,7 @@ public class Graylist extends SqliteDB { try { PreparedStatement check = conn.prepareStatement("select date from graylist where ip=? and fromaddr=? and toaddr=?"); - check.setString(1, ip.getHostAddress()); + check.setString(1, graylistAddress(ip)); check.setString(2, from); check.setString(3, to); ResultSet rs = check.executeQuery(); @@ -50,7 +50,7 @@ public class Graylist extends SqliteDB { try { PreparedStatement check = conn.prepareStatement("insert or replace into graylist (ip,fromaddr,toaddr,date) values(?,?,?,?)"); - check.setString(1, ip.getHostAddress()); + check.setString(1, graylistAddress(ip)); check.setString(2, from); check.setString(3, to); check.setTimestamp(4, new Timestamp(date)); @@ -58,5 +58,19 @@ public class Graylist extends SqliteDB { } catch (SQLException e) { throw new RuntimeException(e); } } + // + // this is mostly to deal with comcast's pathetic retry policy and + // rotating pool of outbound servers + // see: http://lists.puremagic.com/pipermail/greylist-users/2006-November/001255.html + // + private static String graylistAddress(InetAddress ipa) { + byte[] ip = ipa.getAddress(); + return + (ip[0] & 0xff)+"."+ + (ip[1] & 0xff)+"."+ + (ip[2] & 0xff)+"."+ + ".0"; + } + } -- 1.7.10.4