From fbfa2d1d7ac7bb462ebfc1374cc8586a316f6e1f Mon Sep 17 00:00:00 2001 From: Nathan Freitas Date: Thu, 12 Jan 2012 21:53:42 -0500 Subject: [PATCH] flush iptables immediately when disabled in settings --- .../android/settings/SettingsPreferences.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/org/torproject/android/settings/SettingsPreferences.java b/src/org/torproject/android/settings/SettingsPreferences.java index bb5b24b6..55134ab7 100644 --- a/src/org/torproject/android/settings/SettingsPreferences.java +++ b/src/org/torproject/android/settings/SettingsPreferences.java @@ -5,6 +5,7 @@ package org.torproject.android.settings; import org.torproject.android.R; import org.torproject.android.R.xml; +import org.torproject.android.TorConstants; import org.torproject.android.service.TorServiceUtils; import org.torproject.android.service.TorTransProxy; @@ -18,6 +19,7 @@ import android.preference.PreferenceManager; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceActivity; import android.preference.PreferenceCategory; +import android.util.Log; import android.widget.Toast; @@ -145,11 +147,21 @@ public class SettingsPreferences prefcBTransProxyAll.setEnabled(prefCBTransProxy.isChecked()); prefTransProxyApps.setEnabled(prefCBTransProxy.isChecked() && (!prefcBTransProxyAll.isChecked())); + if (!prefCBTransProxy.isChecked()) + clearTransProxyState (); + } return true; } - + private void clearTransProxyState () + { + try { + new TorTransProxy().flushIptables(this); + } catch (Exception e) { + Log.e(TorConstants.TAG,"error flushing iptables",e); + } + } }