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