added exit node option to preferences

svn:r24753
This commit is contained in:
Nathan Freitas 2011-05-16 03:50:10 +00:00
parent 37443d9a68
commit 088ddcd192
3 changed files with 21 additions and 5 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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;
}