description |
---|
Using Tor's new Rust-based runtime in your Android app |
Arti-Mobile-Ex is the current project for building and using the Arti (Tor in Rust) project within your mobile app. The repository is available at: https://gitlab.com/guardianproject/arti-mobile-ex
- install Rust and Android Studio. Make sure you can run an Hello World with both.
- go in the common folder and run
make android
. - take a coffee, or two.
- open the android folder in Android Studio or use gradle to build your app as usual.
There is a sample Android Studio project that demonstrates how easy it can be to use Arti within your Android app.
Once you have built and imported the Arti library into your project, all that you do to initialize it using default ports, all that you need to do is:
Arti.init(this);
From there, you can easily proxy any HTTP connection over Arti's built-in SOCKs proxy port
Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(proxyHost, proxyPort));
HttpURLConnection connection = null;
URL url = new URL(targetURL);
connection = (HttpURLConnection)url.openConnection(proxy);
connection.setRequestMethod("GET");
You can also use the ProxyConfig class to enable WebView proxying, as well
ProxyConfig proxyConfig = new ProxyConfig.Builder()
.addProxyRule("127.0.0.1:8118") //http proxy for tor
.addDirect().build();
ProxyController.getInstance().setProxyOverride(proxyConfig, new Executor() {
@Override
public void execute(Runnable command) {
//do nothing
}
}, new Runnable() {
@Override
public void run() {
}
});