I want to use Java Socket with SOCKS proxy to connect on Tor (I am using Orbot and Tor service is running on port 9050 ).
I got the error :
I/System.out: java.net.UnknownHostException: Host is unresolved: 3g2upl4pq6kufc4m.onion
My code is as follow :
// setup proxy
address = new InetSocketAddress('localhost', 9050);
proxy = new java.net.Proxy(java.net.Proxy.Type.SOCKS,address);
// setup socket
client = new Socket(proxy);
inet = new InetSocketAddress("3g2upl4pq6kufc4m.onion", 80);
// connect
client.connect(inet);
This is legitimate, as Android will probably perform DNS resolution via DNS server specified in network configuration and the resolution of onion address will not work.
How do I specify to let Tor service to perform the DNS resolution (Tor will normally handle the hostname from the TCP packet) ?