String remotehost = null;
for(String command = conn.readln(); ; command = conn.readln()) try {
if (command == null) return;
- Log.warn(conn.getRemoteAddress()+"", command);
+ Log.warn("**"+conn.getRemoteAddress()+"**", command);
String c = command.toUpperCase();
if (c.startsWith("HELO")) {
remotehost = c.substring(5).trim();
command = command.substring(8).trim();
if(command.indexOf(' ') != -1) command = command.substring(0, command.indexOf(' '));
Address addr = new Address(command);
+ /*
+ Log.warn("**"+conn.getRemoteAddress()+"**",
+ "addr.isLocal(): " + addr.isLocal() + "\n" +
+ "conn.getRemoteAddress().isLoopbackAddress(): " + conn.getRemoteAddress().isLoopbackAddress() + "\n" +
+ "johnw: " + (from!=null&&from.toString().indexOf("johnw")!=-1) + "\n"
+ );
+ */
if (addr.isLocal()) {
// FEATURE: should check the address further and give 550 if undeliverable
conn.println("250 " + addr + " is on this machine; I will deliver it");
ret = new InetAddress[1];
try {
ret[0] = InetAddress.getByName(hostName);
+ if (ret[0].equals(IP.getIP(127,0,0,1)) || ret[0].isLoopbackAddress()) throw new UnknownHostException();
return ret;
} catch (UnknownHostException uhe) {
Log.warn(SMTP.class, "no MX hosts or A record for " + hostName);
mx = mx.substring(mx.indexOf(" ") + 1);
if (mx.charAt(mx.length() - 1) == '.') mx = mx.substring(0, mx.length() - 1);
InetAddress ia = InetAddress.getByName(mx);
- if (ia.equals(IP.getIP(127,0,0,1))) continue;
+ if (ia.equals(IP.getIP(127,0,0,1)) || ia.isLoopbackAddress()) continue;
ret[i++] = ia;
}
}