Verified Commit 50c56d7a authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame 🎃
Browse files

fixup! Bug 42247: Android helpers for the TorProvider

Bug 42714: Allow to optionally use a TCP listener on Android.
parent 34e48d53
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -214,12 +214,18 @@ public class TorIntegrationAndroid implements BundleEventListener {
    if (previousProcess != null) {
      Log.w(TAG, "We still have a running process: " + previousProcess.getHandle());
    }
    mTorProcess = new TorProcess(handle);

    boolean tcpSocks = message.getBoolean("tcpSocks", false);
    mTorProcess = new TorProcess(handle, tcpSocks);

    GeckoBundle bundle = new GeckoBundle(3);
    bundle.putString("controlPortPath", mIpcDirectory + CONTROL_PORT_FILE);
    bundle.putString("socksPath", mIpcDirectory + SOCKS_FILE);
    bundle.putString("cookieFilePath", mIpcDirectory + COOKIE_AUTH_FILE);
    if (tcpSocks) {
      bundle.putInt("socksPort", 0);
    } else {
      bundle.putString("socksPath", mIpcDirectory + SOCKS_FILE);
    }
    callback.sendSuccess(bundle);
  }

@@ -248,10 +254,12 @@ public class TorIntegrationAndroid implements BundleEventListener {
    private static final String EVENT_TOR_START_FAILED = "GeckoView:Tor:TorStartFailed";
    private static final String EVENT_TOR_EXITED = "GeckoView:Tor:TorExited";
    private final String mHandle;
    private final boolean mTcpSocks;
    private Process mProcess = null;

    TorProcess(String handle) {
    TorProcess(String handle, boolean tcpSocks) {
      mHandle = handle;
      mTcpSocks = tcpSocks;
      setName("tor-process-" + handle);
      start();
    }
@@ -267,8 +275,13 @@ public class TorIntegrationAndroid implements BundleEventListener {
      args.add("1");
      args.add("+__ControlPort");
      args.add("unix:" + ipcDir + CONTROL_PORT_FILE);
      final String socksFlags = " IPv6Traffic PreferIPv6 KeepAliveIsolateSOCKSAuth";
      args.add("+__SocksPort");
      args.add("unix:" + ipcDir + SOCKS_FILE + socksFlags);
      if (mTcpSocks) {
        args.add("+__SocksPort");
      args.add("unix:" + ipcDir + SOCKS_FILE + " IPv6Traffic PreferIPv6 KeepAliveIsolateSOCKSAuth");
        args.add("auto " + socksFlags);
      }
      args.add("CookieAuthentication");
      args.add("1");
      args.add("CookieAuthFile");