// if the timestamp is bigger as 0 we have allready a triplet stored
if (createTimeStamp > 0) {
long acceptTime = createTimeStamp + tempBlockTime;
if ((time < acceptTime) && (count == 0)) {
return new HookResult(HookReturnCode.DENYSOFT, SMTPRetCode.LOCAL_ERROR, DSNStatus.getStatus(DSNStatus.TRANSIENT, DSNStatus.NETWORK_DIR_SERVER)
+ " Temporary rejected: Reconnect to fast. Please try again later");
} else {
session.getLogger().debug("Update triplet " + ipAddress + " | " + sender + " | " + recip + " -> timestamp: " + time);
// update the triplet..
updateTriplet(ipAddress, sender, recip, count, time);
}
} else {
session.getLogger().debug("New triplet " + ipAddress + " | " + sender + " | " + recip );
// insert a new triplet
insertTriplet(ipAddress, sender, recip, count, time);
// Tempory block on new triplet!
return new HookResult(HookReturnCode.DENYSOFT, SMTPRetCode.LOCAL_ERROR, DSNStatus.getStatus(DSNStatus.TRANSIENT, DSNStatus.NETWORK_DIR_SERVER)
+ " Temporary rejected: Please try again later");
}
// some kind of random cleanup process
if (Math.random() > 0.99) {
// cleanup old entries
session.getLogger().debug("Delete old entries");
cleanupAutoWhiteListGreyList(time - autoWhiteListLifeTime);
cleanupGreyList(time - unseenLifeTime);
}
} catch (Exception e) {
// just log the exception
session.getLogger().error("Error on greylist method: " + e.getMessage());
}
return new HookResult(HookReturnCode.DECLINED);
}