X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2Fmail%2Fprotocol%2FSMTP.java;h=dad7a06895d01252c1e5c918f0f4aae58256bea2;hb=034d6cb1d6f959c4640a0690b9ba0613e1f0ded4;hp=b764b7e62c5965525d31c793e2883166b2663a5a;hpb=a18d27681a90b7630234b278d2e09a1a1040eb8a;p=org.ibex.mail.git diff --git a/src/org/ibex/mail/protocol/SMTP.java b/src/org/ibex/mail/protocol/SMTP.java index b764b7e..dad7a06 100644 --- a/src/org/ibex/mail/protocol/SMTP.java +++ b/src/org/ibex/mail/protocol/SMTP.java @@ -155,25 +155,18 @@ public class SMTP extends MessageProtocol { try { conn.setSoTimeout(5 * 60 * 1000); StringBuffer logMessage = new StringBuffer(); - String conversationId = getConversation(); - Log.setThreadAnnotation("[conversation/" + conversationId + "] "); + String cid = getConversation(); + Log.setThreadAnnotation("[conversation " + cid + "] "); InetSocketAddress remote = (InetSocketAddress)conn.getRemoteSocketAddress(); - Log.info(this, "connection from " + remote.getHostName() + ":" + remote.getPort() + - " (" + remote.getAddress() + ")"); - PrintWriter logf = - new PrintWriter(new OutputStreamWriter(new FileOutputStream(convdir + File.separatorChar + conversationId))); + Log.info(this, "connection from "+remote.getHostName()+":"+remote.getPort()+" ("+remote.getAddress()+")"); + PrintWriter logf = new PrintWriter(new OutputStreamWriter(new FileOutputStream(convdir+File.separatorChar+cid))); try { return handleRequest(new LoggedLineReader(new InputStreamReader(conn.getInputStream()), logf), new LoggedPrintWriter(new OutputStreamWriter(conn.getOutputStream()), logf)); - } catch(Throwable t) { - Log.warn(this, t); - } finally { - logf.close(); - Log.setThreadAnnotation(""); + } catch(Throwable t) { Log.warn(this, t); + } finally { logf.close(); Log.setThreadAnnotation(""); } - } catch (Exception e) { - Log.error(this, e); - } + } catch (Exception e) { Log.error(this, e); } return false; } @@ -294,7 +287,13 @@ public class SMTP extends MessageProtocol { } else { ret = new InetAddress[attr.size()]; NamingEnumeration ne = attr.getAll(); - for(int i=0; ne.hasMore(); i++) ret[i] = (InetAddress)ne.next(); + for(int i=0; ne.hasMore(); i++) { + String mx = (String)ne.next(); + // FIXME we should be sorting here + mx = mx.substring(mx.indexOf(" ") + 1); + if (mx.charAt(mx.length() - 1) == '.') mx = mx.substring(0, mx.length() - 1); + ret[i] = InetAddress.getByName(mx); + } } } catch (Exception e) { Log.warn(SMTP.class, "couldn't find MX host for " + hostName + " due to");