Commit bacfbe23 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Use DNS lookup for establishing the outgoing connection.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1446 b35dd754-fafc-0310-a699-88a17e54d16e
parent d2f81787
...@@ -113,10 +113,14 @@ class ServerDialback { ...@@ -113,10 +113,14 @@ class ServerDialback {
*/ */
public OutgoingServerSession createOutgoingSession(String domain, String hostname, int port) { public OutgoingServerSession createOutgoingSession(String domain, String hostname, int port) {
// TODO Check if the hostname is in the blacklist // TODO Check if the hostname is in the blacklist
String realHostname = null;
try { try {
// Establish a TCP connection to the Receiving Server // Establish a TCP connection to the Receiving Server
Log.debug("OS - Trying to connect to " + hostname + ":" + port); Log.debug("OS - Trying to connect to " + hostname + ":" + port);
Socket socket = SocketFactory.getDefault().createSocket(hostname, port); // Get the real hostname to connect to using DNS lookup of the specified hostname
DNSUtil.HostAddress address = DNSUtil.resolveXMPPServerDomain(hostname);
realHostname = address.getHost();
Socket socket = SocketFactory.getDefault().createSocket(realHostname, port);
// Set a read timeout of 60 seconds during the dialback operation. Then reset to 0. // Set a read timeout of 60 seconds during the dialback operation. Then reset to 0.
socket.setSoTimeout(60000); socket.setSoTimeout(60000);
Log.debug("OS - Connection to " + hostname + ":" + port + " successfull"); Log.debug("OS - Connection to " + hostname + ":" + port + " successfull");
...@@ -173,7 +177,10 @@ class ServerDialback { ...@@ -173,7 +177,10 @@ class ServerDialback {
} }
} }
catch (Exception e) { catch (Exception e) {
Log.error("Error connecting to the remote server: " + hostname, e); Log.error("Error connecting to the remote server: " + hostname + "(DNS lookup: " +
realHostname +
")",
e);
// Close the connection // Close the connection
if (connection != null) { if (connection != null) {
connection.close(); connection.close();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment