Reputation: 105
I had built a tor hidden service on Android phone. The web page of hidden service can be displayed in another Android phone through Tor browser.
Now I would like to create a client APP to send http request to the hidden service. But I have no idea for it.
Any suggestion? Thanks!
Upvotes: 0
Views: 1429
Reputation: 105
I found the solution using OkHttp
InetSocketAddress proxyAddr = new InetSocketAddress("127.0.0.1", 9050);
Proxy proxyTor = new Proxy(Proxy.Type.SOCKS, proxyAddr);
OkHttpClient.Builder builder = new OkHttpClient.Builder().proxy(proxyTor).connectTimeout(30, TimeUnit.SECONDS);
OkHttpClient client = builder.build();
Request request = new Request.Builder().url(address).build();
try (Response response = client.newCall(request).execute()) {
result = response.body().string();
} catch (Exception e) {
e.printStackTrace();
}
Upvotes: 1