From 088ddcd192358db918ee0ecb34e720c69265d3dc Mon Sep 17 00:00:00 2001 From: Nathan Freitas Date: Mon, 16 May 2011 03:50:10 +0000 Subject: [PATCH] added exit node option to preferences svn:r24753 --- src/org/torproject/android/SettingsPreferences.java | 2 +- src/org/torproject/android/service/TorService.java | 12 ++++++++++++ .../torproject/android/service/TorTransProxy.java | 12 ++++++++---- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/org/torproject/android/SettingsPreferences.java b/src/org/torproject/android/SettingsPreferences.java index a060a266..2eef5535 100644 --- a/src/org/torproject/android/SettingsPreferences.java +++ b/src/org/torproject/android/SettingsPreferences.java @@ -77,7 +77,7 @@ public class SettingsPreferences } - int hiddenGroupIdx = 5; + int hiddenGroupIdx = 6; prefHiddenServices = ((CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(hiddenGroupIdx)).getPreference(0)); prefHiddenServices.setOnPreferenceClickListener(this); diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java index 9dae147d..a3af8e4c 100644 --- a/src/org/torproject/android/service/TorService.java +++ b/src/org/torproject/android/service/TorService.java @@ -1288,6 +1288,10 @@ public class TorService extends Service implements TorServiceConstants, Runnable boolean enableHiddenServices = prefs.getBoolean("pref_hs_enable", false); + boolean enableStrictExitNodes = prefs.getBoolean("pref_strict_exit_nodes", false); + String exitNodes = prefs.getString("pref_exit_nodes", ""); + + //boolean enableTransparentProxy = prefs.getBoolean(TorConstants.PREF_TRANSPARENT, false); if (currentStatus == STATUS_ON) @@ -1302,6 +1306,14 @@ public class TorService extends Service implements TorServiceConstants, Runnable { logException("unable to setup transproxy",e); } + } + + if (exitNodes.length() > 0) + { + + mBinder.updateConfiguration("ExitNodes", exitNodes, false); + mBinder.updateConfiguration("StrictExitNodes", enableStrictExitNodes ? "1" : "0", false); + } if (useBridges) diff --git a/src/org/torproject/android/service/TorTransProxy.java b/src/org/torproject/android/service/TorTransProxy.java index 492d0202..548dda64 100644 --- a/src/org/torproject/android/service/TorTransProxy.java +++ b/src/org/torproject/android/service/TorTransProxy.java @@ -335,15 +335,17 @@ public class TorTransProxy implements TorServiceConstants { script.append(ipTablesPath); script.append(" -I FORWARD"); - script.append(" -s 192.168.43.0/24 -j ACCEPT"); + script.append(" -j ACCEPT"); script.append(" || exit\n"); + /* script.append(ipTablesPath); script.append(" -P FORWARD DROP"); script.append(" || exit\n"); + */ script.append(ipTablesPath); - script.append(" -t nat -I POSTROUTING -s 192.168.43.0/24 -j MASQUERADE"); + script.append(" -t nat -I POSTROUTING -j MASQUERADE"); script.append(" || exit\n"); String[] cmdAdd = {script.toString()}; @@ -372,8 +374,8 @@ public class TorTransProxy implements TorServiceConstants { purgeIptables(context); - //enableWifiHotspotRules(context); - + enableWifiHotspotRules(context); + int torUid = context.getApplicationInfo().uid; // Set up port redirection @@ -472,6 +474,8 @@ public class TorTransProxy implements TorServiceConstants { String msg = res.toString(); TorService.logMessage(cmdAdd[0] + ";errCode=" + code + ";resp=" + msg); + + return code; }