Android / Java: Come usare Tor-Onion-Proxy-Library?


Mi collegherò a un server in un'app Android con tor ma senza usare orbot. Ho trovato questa libreria: https://github.com/jehy/Tor-Onion-Proxy-Library

Ho aggiunto

    compile 'com.github.jehy:Tor-Onion-Proxy-Library:0.0.7'
    compile 'org.slf4j:slf4j-api:1.7.7'
    compile 'org.slf4j:slf4j-android:1.7.7'

Alla mia build.gradle (Modulo: app) e

allprojects {
repositories {
    maven { url 'https://jitpack.io' }
}

}

Successivamente ho aggiunto nel mio frammento nel onCreateView

    int totalSecondsPerTorStartup = 4 * 60;
    int totalTriesPerTorStartup = 5;
    try {
        boolean ok = onionProxyManager.startWithRepeat(totalSecondsPerTorStartup, totalTriesPerTorStartup);
        if (!ok)
            Log.e("TorTest", "Couldn't start Tor!");
    }
    catch (InterruptedException | IOException e) {
        e.printStackTrace();
    }

Ma ottengo un errore Cannot resolve symbol 'onionProxyManager'. Ho seguito le istruzioni su Github...

Se cambio onionProxyManager in OnionProxyManager posso importare com.msopentech.thali.toronionproxy.OnionProxyManager ma ottengo un errore su startWithRepeat.

Quindi per favore aiutami se puoi. Grazie!

Author: Hannes, 2018-01-10

1 answers

int totalSecondsPerTorStartup = 4 * 60;
int totalTriesPerTorStartup = 5;
String fileStorageLocation = "torfiles";
OnionProxyManager onionProxyManager =
        new AndroidOnionProxyManager(getActivity(), fileStorageLocation);
    public void start(){
// Start the Tor Onion Proxy
try {
  boolean ok = onionProxyManager.startWithRepeat(totalSecondsPerTorStartup, totalTriesPerTorStartup);
// Now the socket is open but note that it can take some time before the Tor network has everything
// connected and connection requests can fail for spurious reasons (especially when connecting to
// hidden services) so have lots of retry logic.
  if (!ok)
    // Log.e("TorTest", "Couldn't start Tor!");
    return;
  }
  catch (InterruptedException | IOException e) {
    e.printStackTrace();
}
 0
Author: JJohn, 2018-02-24 00:20:06