diff options
-rw-r--r-- | src/main/java/se/lublin/humla/net/HumlaSSLSocketFactory.java | 12 | ||||
-rw-r--r-- | src/main/java/se/lublin/humla/net/HumlaTCP.java | 6 |
2 files changed, 8 insertions, 10 deletions
diff --git a/src/main/java/se/lublin/humla/net/HumlaSSLSocketFactory.java b/src/main/java/se/lublin/humla/net/HumlaSSLSocketFactory.java index 94ebafb..5907cfa 100644 --- a/src/main/java/se/lublin/humla/net/HumlaSSLSocketFactory.java +++ b/src/main/java/se/lublin/humla/net/HumlaSSLSocketFactory.java @@ -73,15 +73,15 @@ public class HumlaSSLSocketFactory { /** * Creates a new SSLSocket that runs through a SOCKS5 proxy to reach its destination. */ - public SSLSocket createTorSocket(InetAddress host, int port, String proxyHost, int proxyPort) throws IOException { + public SSLSocket createTorSocket(String host, int port, String proxyHost, int proxyPort) throws IOException { Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(proxyHost, proxyPort)); Socket socket = new Socket(proxy); - socket.connect(new InetSocketAddress(host, port)); - return (SSLSocket) mContext.getSocketFactory().createSocket(socket, host.getHostName(), port, true); + socket.connect(InetSocketAddress.createUnresolved(host, port)); + return (SSLSocket) mContext.getSocketFactory().createSocket(socket, host, port, true); } - public SSLSocket createSocket(InetAddress host, int port) throws IOException { - return (SSLSocket) mContext.getSocketFactory().createSocket(host, port); + public SSLSocket createSocket(String host, int port) throws IOException { + return (SSLSocket) mContext.getSocketFactory().createSocket(InetAddress.getByName(host), port); } /** @@ -139,4 +139,4 @@ public class HumlaSSLSocketFactory { return mServerChain; } } -}
\ No newline at end of file +} diff --git a/src/main/java/se/lublin/humla/net/HumlaTCP.java b/src/main/java/se/lublin/humla/net/HumlaTCP.java index fcdac31..2e2e4df 100644 --- a/src/main/java/se/lublin/humla/net/HumlaTCP.java +++ b/src/main/java/se/lublin/humla/net/HumlaTCP.java @@ -76,14 +76,12 @@ public class HumlaTCP extends HumlaNetworkThread { public void run() { mRunning = true; try { - InetAddress address = InetAddress.getByName(mHost); - Log.i(Constants.TAG, "HumlaTCP: Connecting"); if(mUseTor) - mTCPSocket = mSocketFactory.createTorSocket(address, mPort, HumlaConnection.TOR_HOST, HumlaConnection.TOR_PORT); + mTCPSocket = mSocketFactory.createTorSocket(mHost, mPort, HumlaConnection.TOR_HOST, HumlaConnection.TOR_PORT); else - mTCPSocket = mSocketFactory.createSocket(address, mPort); + mTCPSocket = mSocketFactory.createSocket(mHost, mPort); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { // SNI support requires at least API 17 SSLCertificateSocketFactory scsf = (SSLCertificateSocketFactory) SSLCertificateSocketFactory.getDefault(0); |