flush iptables immediately when disabled in settings

This commit is contained in:
Nathan Freitas 2012-01-12 21:53:42 -05:00
parent ce0ea902ca
commit fbfa2d1d7a
1 changed files with 13 additions and 1 deletions

View File

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