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();
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));
} 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";
+ }
+
}