diff options
author | Vitaly Takmazov | 2016-07-07 14:03:10 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-07-07 14:03:10 +0300 |
commit | 7f6c01a9435fdaf35c804b97faca01242b439e70 (patch) | |
tree | f1dda5a80d1d61f56060b2f23c7c9c6a33d9491d /src/main/java/com | |
parent | 93cab67688630bbc4f6ace3c23d272828c2e47b3 (diff) |
refactor
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/juick/xmpp/s2s/ConnectionOut.java | 9 | ||||
-rw-r--r-- | src/main/java/com/juick/xmpp/s2s/DNSQueries.java | 5 | ||||
-rw-r--r-- | src/main/java/com/juick/xmpp/s2s/HostnamePort.java | 16 |
3 files changed, 6 insertions, 24 deletions
diff --git a/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java b/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java index fede701ed..cf54997fb 100644 --- a/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java +++ b/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java @@ -10,6 +10,7 @@ import javax.net.ssl.SSLSocket; import java.io.EOFException; import java.io.IOException; import java.net.InetAddress; +import java.net.InetSocketAddress; import java.net.Socket; import java.net.UnknownHostException; import java.security.KeyManagementException; @@ -61,12 +62,8 @@ public class ConnectionOut extends Connection implements Runnable { public void run() { LOGGER.info("STREAM TO " + to + " START"); try { - HostnamePort addr = DNSQueries.getServerAddress(to); - try { - socket = new Socket(InetAddress.getByName(addr.hostname), addr.port); - } catch (UnknownHostException e) { - socket = new Socket(InetAddress.getByName("talk.google.com"), 5269); - } + socket = new Socket(); + socket.connect(DNSQueries.getServerAddress(to)); restartParser(); sendOpenStream(); diff --git a/src/main/java/com/juick/xmpp/s2s/DNSQueries.java b/src/main/java/com/juick/xmpp/s2s/DNSQueries.java index 2b2d60e0f..e4c5f0854 100644 --- a/src/main/java/com/juick/xmpp/s2s/DNSQueries.java +++ b/src/main/java/com/juick/xmpp/s2s/DNSQueries.java @@ -1,5 +1,6 @@ package com.juick.xmpp.s2s; +import java.net.InetSocketAddress; import java.net.UnknownHostException; import java.util.Hashtable; import java.util.Random; @@ -16,7 +17,7 @@ public class DNSQueries { private static Random rand = new Random(); - public static HostnamePort getServerAddress(String hostname) throws UnknownHostException { + public static InetSocketAddress getServerAddress(String hostname) throws UnknownHostException { String host = hostname; int port = 5269; @@ -41,6 +42,6 @@ public class DNSQueries { } catch (NamingException e) { } - return new HostnamePort(host, port); + return new InetSocketAddress(host, port); } } diff --git a/src/main/java/com/juick/xmpp/s2s/HostnamePort.java b/src/main/java/com/juick/xmpp/s2s/HostnamePort.java deleted file mode 100644 index ce020f8d3..000000000 --- a/src/main/java/com/juick/xmpp/s2s/HostnamePort.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.juick.xmpp.s2s; - -/** - * - * @author ugnich - */ -public class HostnamePort { - - public String hostname; - public int port; - - public HostnamePort(String hostname, int port) { - this.hostname = hostname; - this.port = port; - } -} |