Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/humla.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Lublin <daniel@lublin.se>2020-04-09 15:37:59 +0300
committerDaniel Lublin <daniel@lublin.se>2020-04-09 15:43:33 +0300
commite451061ccba59f8e1a329d4a42093260c75d5567 (patch)
tree21c535ccc81ef62a50036ad0869dcead3f69f263
parent15956fceff99fc3e3a2727fa2ada4cb83b42f4f2 (diff)
Let the Tor proxy do DNS resolving and .onion works!
-rw-r--r--src/main/java/se/lublin/humla/net/HumlaSSLSocketFactory.java12
-rw-r--r--src/main/java/se/lublin/humla/net/HumlaTCP.java6
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);