Merge branch 'master' of https://git.torproject.org/orbot
This commit is contained in:
commit
1229da66cb
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.torproject.android"
|
||||
android:versionName="14.0.6"
|
||||
android:versionCode="118"
|
||||
android:versionName="14.0.7.2"
|
||||
android:versionCode="121"
|
||||
android:installLocation="auto"
|
||||
>
|
||||
|
||||
|
|
27
CHANGELOG
27
CHANGELOG
|
@ -1,5 +1,32 @@
|
|||
NOTE: Specific #s below correspond to Trac tickets logged and maintained at https://trac.torproject.org/projects/tor/
|
||||
|
||||
d2c71d7 update to 14.0.7.2
|
||||
6e65469 ensure settings are updated and binary paths are on service restart
|
||||
af433d3 remove unused variables/patterns
|
||||
b76be6d disable stdout log by default and enable daemon mode
|
||||
dafd295 simplify process reconnect and transproxy setup - on reconnect to service, don't require call to getInfo before STATUS_ON is s
|
||||
390b89e remove debug file logging for now until we can improve it
|
||||
e53e03a tuning Orbot app conflict checker code
|
||||
|
||||
c2672cc update to 14.0.7.1
|
||||
eaccf77 don't call handle intents twice!
|
||||
|
||||
24a3db8 update to 14.0.7
|
||||
add04f2 exit menu option should be a menu
|
||||
186e74b add new transproxy flush pref and strings
|
||||
c78a822 add transproxy flush option to settings
|
||||
68495c3 make delete iptables rules process match add for specific behavior no more drop all output tables, etc
|
||||
25bc4c0 add new flush transproxy interface method
|
||||
79a32e6 make sure control connection is not null on rebind - also tune app conflict checker code for Samsung Link
|
||||
b307d51 make default SOCKs port auto, and THEN try to set specified port - also remove exit IP lookup loop bad code
|
||||
9cc5f98 don't obfuscate class names; we just need to remove unused classes
|
||||
3698e46 create new thread for connecting to existing process don't rely on executor yet, as we need it to happen fast
|
||||
ea37b44 create new thread to just for existing process dont' rely on executor there yet
|
||||
3a82421 no need for asynctask - just grab the status directly
|
||||
e2f4f5f don't make these final, because the user might change them
|
||||
7d243af update changelog
|
||||
|
||||
56dfff0 bumped to 14.0.6
|
||||
05dd331 update to latest jtorctl with patches for thread, error handling
|
||||
|
||||
73d4297 bump to 14.0.5.4
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
-dontusemixedcaseclassnames
|
||||
-dontskipnonpubliclibraryclasses
|
||||
-dontpreverify
|
||||
-dontobfuscate
|
||||
-verbose
|
||||
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
<item android:id="@+id/menu_exit"
|
||||
android:title="@string/menu_exit"
|
||||
android:icon="@drawable/ic_menu_exit"
|
||||
yourapp:showAsAction="ifRoom"
|
||||
yourapp:showAsAction="never"
|
||||
|
||||
/>
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Log notice stdout
|
||||
RunAsDaemon 1
|
||||
AvoidDiskWrites 1
|
||||
ControlPort auto
|
||||
SOCKSPort 0
|
||||
DNSPort 0
|
||||
|
|
|
@ -295,4 +295,7 @@
|
|||
<string name="pref_transproxy_refresh_title">Transproxy Auto-Refresh</string>
|
||||
<string name="pref_transproxy_refresh_summary">Re-apply Transproxy rules when the network state changes</string>
|
||||
|
||||
<string name="pref_transproxy_flush_title">Transproxy FORCE REMOVE</string>
|
||||
<string name="pref_transproxy_flush_summary">Tap here to flush all transproxy network rules NOW</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -263,6 +263,11 @@ android:summary="@string/pref_transproxy_refresh_summary"
|
|||
android:enabled="true"
|
||||
android:title="@string/pref_transproxy_refresh_title"/>
|
||||
|
||||
<Preference
|
||||
android:key="pref_transproxy_flush"
|
||||
android:summary="@string/pref_transproxy_flush_summary"
|
||||
android:enabled="true"
|
||||
android:title="@string/pref_transproxy_flush_title"/>
|
||||
|
||||
<!--
|
||||
<CheckBoxPreference
|
||||
|
|
|
@ -32,7 +32,6 @@ import android.content.pm.PackageManager;
|
|||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
|
@ -297,18 +296,22 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
|||
{
|
||||
SharedPreferences sprefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
||||
|
||||
boolean showAppConflict = sprefs.getBoolean("pref_show_conflict",true);
|
||||
boolean showAppConflict = true;//sprefs.getBoolean("pref_show_conflict",true);
|
||||
|
||||
String[] badApps = {"com.sec.msc.nts.android.proxy"};
|
||||
String[] badApps = {"com.sec.msc.nts.android.proxy:com.sec.msc.nts.android.proxy","com.sec.pcw:Samsung Link"};
|
||||
|
||||
for (String badApp : badApps)
|
||||
{
|
||||
if (appInstalledOrNot(badApp))
|
||||
{
|
||||
if (showAppConflict)
|
||||
showAlert(getString(R.string.app_conflict),getString(R.string.please_disable_this_app_in_android_settings_apps_if_you_are_having_problems_with_orbot_) + badApp,true);
|
||||
String[] badAppParts = badApp.split(":");
|
||||
|
||||
appendLogTextAndScroll(getString(R.string.please_disable_this_app_in_android_settings_apps_if_you_are_having_problems_with_orbot_) + badApp);
|
||||
if (appInstalledOrNot(badAppParts[0]))
|
||||
{
|
||||
String msg = getString(R.string.please_disable_this_app_in_android_settings_apps_if_you_are_having_problems_with_orbot_) + badAppParts[1];
|
||||
|
||||
if (showAppConflict)
|
||||
showAlert(getString(R.string.app_conflict),msg,true);
|
||||
|
||||
appendLogTextAndScroll(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -423,19 +426,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
|||
//terminology but also making sure there are clear distinctions in control
|
||||
stopTor();
|
||||
|
||||
if (mConnection != null)
|
||||
unbindService(mConnection);
|
||||
|
||||
//perhaps this should be referenced as INTENT_TOR_SERVICE as in startService
|
||||
stopService(new Intent(this,TorService.class));
|
||||
|
||||
//clears all notifications from the status bar
|
||||
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mNotificationManager.cancelAll();
|
||||
|
||||
mConnection = null;
|
||||
mService = null;
|
||||
|
||||
onDestroy();
|
||||
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, e);
|
||||
|
@ -648,6 +639,8 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
|||
|
||||
}
|
||||
|
||||
setIntent(null);
|
||||
|
||||
updateStatus ("");
|
||||
|
||||
}
|
||||
|
@ -769,11 +762,51 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int request, int response, Intent data) {
|
||||
super.onActivityResult(request, response, data);
|
||||
|
||||
if (request == 1 && response == RESULT_OK)
|
||||
{
|
||||
if (data != null && data.getBooleanExtra("transproxywipe", false))
|
||||
{
|
||||
try {
|
||||
|
||||
boolean result = mService.flushTransProxy();
|
||||
|
||||
if (result)
|
||||
{
|
||||
|
||||
Toast.makeText(this, "Transparent proxy rules flushed!", Toast.LENGTH_SHORT).show();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Toast.makeText(this, "You do not have ROOT access enabled", Toast.LENGTH_SHORT).show();
|
||||
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if (mService != null)
|
||||
setLocale();
|
||||
|
||||
if (mService == null)
|
||||
{
|
||||
startService();
|
||||
}
|
||||
else
|
||||
{
|
||||
try {
|
||||
|
||||
|
@ -782,17 +815,16 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
|||
if (torStatus != TorServiceConstants.STATUS_ON)
|
||||
mService.processSettings();
|
||||
|
||||
setLocale();
|
||||
|
||||
handleIntents();
|
||||
} catch (RemoteException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
updateStatus("");
|
||||
}
|
||||
|
||||
|
||||
updateStatus("");
|
||||
}
|
||||
|
||||
AlertDialog aDialog = null;
|
||||
|
@ -831,132 +863,95 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
|||
aDialog.setCanceledOnTouchOutside(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the state of the running/not running graphic and label
|
||||
* this all needs to be looked at w/ the shift to progressDialog
|
||||
*/
|
||||
public void updateStatus (String torServiceMsg)
|
||||
private void updateStatus (String torServiceMsg)
|
||||
{
|
||||
new updateStatusAsync().execute(torServiceMsg);
|
||||
}
|
||||
|
||||
private class updateStatusAsync extends AsyncTask<String, Void, Integer> {
|
||||
int newTorStatus = torStatus;
|
||||
|
||||
String mTorServiceMsg = null;
|
||||
if (mService != null)
|
||||
try {newTorStatus = mService.getStatus();}
|
||||
catch (RemoteException e){}
|
||||
|
||||
@Override
|
||||
protected Integer doInBackground(String... params) {
|
||||
|
||||
mTorServiceMsg = params[0];
|
||||
int newTorStatus = TorServiceConstants.STATUS_OFF;
|
||||
try
|
||||
//now update the layout_main UI based on the status
|
||||
if (imgStatus != null)
|
||||
{
|
||||
if (mService != null)
|
||||
return new Integer(mService.getStatus());
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//error
|
||||
Log.d(TAG,"error in update status",e);
|
||||
}
|
||||
|
||||
return newTorStatus;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Integer result) {
|
||||
|
||||
updateUI(result.intValue());
|
||||
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
|
||||
private void updateUI (int newTorStatus)
|
||||
{
|
||||
|
||||
//now update the layout_main UI based on the status
|
||||
if (imgStatus != null)
|
||||
if (newTorStatus == TorServiceConstants.STATUS_ON)
|
||||
{
|
||||
|
||||
if (newTorStatus == TorServiceConstants.STATUS_ON)
|
||||
imgStatus.setImageResource(R.drawable.toron);
|
||||
|
||||
String lblMsg = getString(R.string.status_activated);
|
||||
lblStatus.setText(lblMsg);
|
||||
|
||||
if (mItemOnOff != null)
|
||||
mItemOnOff.setTitle(R.string.menu_stop);
|
||||
|
||||
|
||||
if (torServiceMsg != null && torServiceMsg.length() > 0)
|
||||
{
|
||||
appendLogTextAndScroll(torServiceMsg);
|
||||
}
|
||||
|
||||
boolean showFirstTime = mPrefs.getBoolean("connect_first_time",true);
|
||||
|
||||
if (showFirstTime)
|
||||
{
|
||||
|
||||
imgStatus.setImageResource(R.drawable.toron);
|
||||
Editor pEdit = mPrefs.edit();
|
||||
|
||||
String lblMsg = getString(R.string.status_activated);
|
||||
lblStatus.setText(lblMsg);
|
||||
pEdit.putBoolean("connect_first_time",false);
|
||||
|
||||
if (mItemOnOff != null)
|
||||
mItemOnOff.setTitle(R.string.menu_stop);
|
||||
pEdit.commit();
|
||||
|
||||
|
||||
if (mTorServiceMsg != null && mTorServiceMsg.length() > 0)
|
||||
{
|
||||
appendLogTextAndScroll(mTorServiceMsg);
|
||||
}
|
||||
|
||||
boolean showFirstTime = mPrefs.getBoolean("connect_first_time",true);
|
||||
|
||||
if (showFirstTime)
|
||||
{
|
||||
|
||||
Editor pEdit = mPrefs.edit();
|
||||
|
||||
pEdit.putBoolean("connect_first_time",false);
|
||||
|
||||
pEdit.commit();
|
||||
|
||||
showAlert(getString(R.string.status_activated),getString(R.string.connect_first_time),true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (autoStartFromIntent)
|
||||
{
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
showAlert(getString(R.string.status_activated),getString(R.string.connect_first_time),true);
|
||||
|
||||
}
|
||||
else if (newTorStatus == TorServiceConstants.STATUS_CONNECTING)
|
||||
|
||||
|
||||
if (autoStartFromIntent)
|
||||
{
|
||||
|
||||
imgStatus.setImageResource(R.drawable.torstarting);
|
||||
|
||||
if (mItemOnOff != null)
|
||||
mItemOnOff.setTitle(R.string.menu_stop);
|
||||
|
||||
|
||||
if (lblStatus != null && mTorServiceMsg != null)
|
||||
if (mTorServiceMsg.indexOf('%')!=-1)
|
||||
lblStatus.setText(mTorServiceMsg);
|
||||
|
||||
appendLogTextAndScroll(mTorServiceMsg);
|
||||
|
||||
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
else if (newTorStatus == TorServiceConstants.STATUS_OFF)
|
||||
{
|
||||
imgStatus.setImageResource(R.drawable.toroff);
|
||||
lblStatus.setText(getString(R.string.status_disabled) + "\n" + getString(R.string.press_to_start));
|
||||
|
||||
if (mItemOnOff != null)
|
||||
mItemOnOff.setTitle(R.string.menu_start);
|
||||
|
||||
}
|
||||
}
|
||||
else if (newTorStatus == TorServiceConstants.STATUS_CONNECTING)
|
||||
{
|
||||
|
||||
imgStatus.setImageResource(R.drawable.torstarting);
|
||||
|
||||
if (mItemOnOff != null)
|
||||
mItemOnOff.setTitle(R.string.menu_stop);
|
||||
|
||||
|
||||
if (lblStatus != null && torServiceMsg != null)
|
||||
if (torServiceMsg.indexOf('%')!=-1)
|
||||
lblStatus.setText(torServiceMsg);
|
||||
|
||||
appendLogTextAndScroll(torServiceMsg);
|
||||
|
||||
|
||||
}
|
||||
else if (newTorStatus == TorServiceConstants.STATUS_OFF)
|
||||
{
|
||||
imgStatus.setImageResource(R.drawable.toroff);
|
||||
lblStatus.setText(getString(R.string.status_disabled) + "\n" + getString(R.string.press_to_start));
|
||||
|
||||
if (mItemOnOff != null)
|
||||
mItemOnOff.setTitle(R.string.menu_start);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
torStatus = newTorStatus;
|
||||
|
||||
}
|
||||
|
||||
torStatus = newTorStatus;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// guess what? this start's Tor! actually no it just requests via the local ITorService to the remote TorService instance
|
||||
// to start Tor
|
||||
private void startTor () throws RemoteException
|
||||
|
@ -1181,7 +1176,7 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
|||
// we should use this to activity monitor unbind so that we don't have to call
|
||||
// bindService() a million times
|
||||
|
||||
private ServiceConnection mConnection = new ServiceConnection() {
|
||||
private final ServiceConnection mConnection = new ServiceConnection() {
|
||||
public void onServiceConnected(ComponentName className,
|
||||
IBinder service) {
|
||||
|
||||
|
@ -1192,21 +1187,12 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
|||
// representation of that from the raw service object.
|
||||
mService = ITorService.Stub.asInterface(service);
|
||||
|
||||
|
||||
// We want to monitor the service for as long as we are
|
||||
// connected to it.
|
||||
try {
|
||||
torStatus = mService.getStatus();
|
||||
initUpdates();
|
||||
|
||||
if (autoStartFromIntent)
|
||||
{
|
||||
|
||||
startTor();
|
||||
|
||||
|
||||
}
|
||||
|
||||
handleIntents();
|
||||
|
||||
updateStatus("");
|
||||
|
@ -1220,8 +1206,6 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void onServiceDisconnected(ComponentName className) {
|
||||
|
@ -1233,6 +1217,8 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
|||
Log.d(TAG,"service was disconnected");
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
private void setLocale ()
|
||||
|
@ -1258,7 +1244,6 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
|
|||
if (mConnection != null && mService != null)
|
||||
{
|
||||
unbindService(mConnection);
|
||||
mConnection = null;
|
||||
mService = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,6 @@ public interface TorConstants {
|
|||
|
||||
public final static String NEWLINE = "\n";
|
||||
|
||||
/*
|
||||
public final static String TORRC_DEFAULT =
|
||||
"SocksPort 9050\nSocksListenAddress 127.0.0.1\nSafeSocks 1\nDNSPort 5400\nLog debug syslog\nDataDirectory /data/data/org.torproject.android/cache\n"
|
||||
+ "ControlPort 9051\nCookieAuthentication 1\nRelayBandwidthRate 20 KBytes\nRelayBandwidthBurst 20 KBytes\nAutomapHostsOnResolve 1\nTransPort 9040\n";
|
||||
*/
|
||||
|
||||
// public final static String INTENT_TOR_SERVICE = "org.torproject.android.service.TOR_SERVICE";
|
||||
|
||||
public final static String HANDLER_TOR_MSG = "torServiceMsg";
|
||||
|
|
|
@ -52,4 +52,6 @@ interface ITorService {
|
|||
String[] getLog ();
|
||||
|
||||
long[] getBandwidth ();
|
||||
|
||||
boolean flushTransProxy ();
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.io.PrintStream;
|
|||
import java.io.PrintWriter;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
@ -75,6 +76,7 @@ import android.support.v4.app.NotificationCompat;
|
|||
import android.support.v4.app.NotificationCompat.Builder;
|
||||
import android.util.Log;
|
||||
import android.widget.RemoteViews;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class TorService extends Service implements TorServiceConstants, TorConstants, EventHandler
|
||||
{
|
||||
|
@ -89,15 +91,17 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
private Socket torConnSocket = null;
|
||||
private int mLastProcessId = -1;
|
||||
|
||||
|
||||
private int mPortHTTP = 8118;
|
||||
private int mPortSOCKS = 9050;
|
||||
|
||||
|
||||
private static final int NOTIFY_ID = 1;
|
||||
private static final int TRANSPROXY_NOTIFY_ID = 2;
|
||||
private static final int ERROR_NOTIFY_ID = 3;
|
||||
private static final int HS_NOTIFY_ID = 4;
|
||||
|
||||
private boolean prefPersistNotifications = true;
|
||||
private static final String IPADDRESS_PATTERN =
|
||||
"(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)";
|
||||
private final static Pattern pattern = Pattern.compile(IPADDRESS_PATTERN);
|
||||
|
||||
private static final int MAX_START_TRIES = 3;
|
||||
|
||||
|
@ -179,10 +183,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
{
|
||||
sendCallbackLogMessage (getString(R.string.found_existing_tor_process));
|
||||
|
||||
String msg = conn.getInfo("status/circuit-established");
|
||||
sendCallbackLogMessage(msg);
|
||||
|
||||
currentStatus = STATUS_ON;
|
||||
currentStatus = STATUS_ON;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -339,6 +340,12 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
|
||||
try
|
||||
{
|
||||
|
||||
if (fileTor == null)
|
||||
initBinariesAndDirectories();
|
||||
|
||||
updateSettings ();
|
||||
|
||||
mExecutor.execute (new TorStarter(intent));
|
||||
|
||||
return Service.START_STICKY;
|
||||
|
@ -567,6 +574,24 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
try
|
||||
{
|
||||
initBinariesAndDirectories();
|
||||
updateSettings();
|
||||
|
||||
new Thread(new Runnable ()
|
||||
{
|
||||
public void run ()
|
||||
{
|
||||
try
|
||||
{
|
||||
findExistingProc ();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.e(TAG,"error onBind",e);
|
||||
}
|
||||
|
||||
}
|
||||
}).start();
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -575,21 +600,6 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
logNotice("There was an error installing Orbot binaries");
|
||||
}
|
||||
|
||||
mExecutor.execute(new Runnable ()
|
||||
{
|
||||
public void run ()
|
||||
{
|
||||
try
|
||||
{
|
||||
findExistingProc ();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.e(TAG,"error onBind",e);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
@ -646,12 +656,10 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
fileControlPort = new File(appBinHome,"control.txt");
|
||||
extraLines.append(TORRC_CONTROLPORT_FILE_KEY).append(' ').append(fileControlPort.getCanonicalPath()).append('\n');
|
||||
|
||||
String socksPort = prefs.getString(TorConstants.PREF_SOCKS, TorServiceConstants.PORT_SOCKS_DEFAULT);
|
||||
|
||||
String transPort = prefs.getString("pref_transport", TorServiceConstants.TOR_TRANSPROXY_PORT_DEFAULT+"");
|
||||
String dnsPort = prefs.getString("pref_dnsport", TorServiceConstants.TOR_DNS_PORT_DEFAULT+"");
|
||||
|
||||
|
||||
if (mTransProxyTethering)
|
||||
{
|
||||
extraLines.append("TransListenAddress 0.0.0.0").append('\n');
|
||||
|
@ -660,12 +668,9 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
}
|
||||
|
||||
extraLines.append("RunAsDaemon 1").append('\n');
|
||||
|
||||
extraLines.append("AvoidDiskWrites 1").append('\n');
|
||||
|
||||
extraLines.append("CircuitStreamTimeout 120").append('\n');
|
||||
|
||||
extraLines.append("SOCKSPort ").append(socksPort).append('\n');
|
||||
extraLines.append("SOCKSPort ").append("auto").append('\n');
|
||||
extraLines.append("SafeSocks 0").append('\n');
|
||||
extraLines.append("TestSocks 0").append('\n');
|
||||
extraLines.append("WarnUnsafeSocks 1").append('\n');
|
||||
|
@ -675,7 +680,6 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
extraLines.append("VirtualAddrNetwork 10.192.0.0/10").append('\n');
|
||||
extraLines.append("AutomapHostsOnResolve 1").append('\n');
|
||||
|
||||
|
||||
extraLines.append(prefs.getString("pref_custom_torrc", ""));
|
||||
|
||||
logNotice("updating torrc custom configuration...");
|
||||
|
@ -701,7 +705,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
if (!fileBin.canExecute())
|
||||
{
|
||||
logNotice("(re)Setting permission on binary: " + fileBin.getCanonicalPath());
|
||||
//Shell shell = Shell.startShell(new ArrayList<String>(), appBinHome.getCanonicalPath());
|
||||
|
||||
Shell shell = Shell.startShell();
|
||||
shell.add(new SimpleCommand("chmod " + CHMOD_EXE_VALUE + ' ' + fileBin.getCanonicalPath())).waitForFinish();
|
||||
|
||||
|
@ -717,6 +721,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
|
||||
private void updateSettings () throws TimeoutException, IOException
|
||||
{
|
||||
|
||||
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
||||
|
||||
mHasRoot = prefs.getBoolean(PREF_HAS_ROOT,false);
|
||||
|
@ -741,6 +746,8 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
|
||||
currentStatus = STATUS_CONNECTING;
|
||||
|
||||
if (fileTor == null)
|
||||
initBinariesAndDirectories();
|
||||
|
||||
enableBinExec(fileTor);
|
||||
enableBinExec(filePolipo);
|
||||
|
@ -756,13 +763,35 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
runPolipoShellCmd();
|
||||
|
||||
if (mHasRoot && mEnableTransparentProxy)
|
||||
enableTransparentProxy(mTransProxyAll, mTransProxyTethering);
|
||||
{
|
||||
disableTransparentProxy();
|
||||
enableTransparentProxy();
|
||||
}
|
||||
|
||||
getHiddenServiceHostname ();
|
||||
|
||||
//checkAddressAndCountry();
|
||||
}
|
||||
|
||||
private boolean flushTransparentProxyRules () throws Exception
|
||||
{
|
||||
|
||||
if (mHasRoot)
|
||||
{
|
||||
if (mTransProxy == null)
|
||||
{
|
||||
mTransProxy = new TorTransProxy(this, fileXtables);
|
||||
|
||||
}
|
||||
|
||||
mTransProxy.flushTransproxyRules(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* activate means whether to apply the users preferences
|
||||
|
@ -770,7 +799,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
*
|
||||
* the idea is that if Tor is off then transproxy is off
|
||||
*/
|
||||
private boolean enableTransparentProxy (boolean proxyAll, boolean enableTether) throws Exception
|
||||
private boolean enableTransparentProxy () throws Exception
|
||||
{
|
||||
|
||||
if (mTransProxy == null)
|
||||
|
@ -780,7 +809,6 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
}
|
||||
|
||||
|
||||
|
||||
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
||||
String transProxy = prefs.getString("pref_transport", TorServiceConstants.TOR_TRANSPROXY_PORT_DEFAULT+"");
|
||||
String dnsPort = prefs.getString("pref_dnsport", TorServiceConstants.TOR_TRANSPROXY_PORT_DEFAULT+"");
|
||||
|
@ -805,7 +833,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
//clear rules first
|
||||
// mTransProxy.clearTransparentProxyingAll(this);
|
||||
|
||||
if(proxyAll)
|
||||
if(mTransProxyAll)
|
||||
{
|
||||
// showToolbarNotification(getString(R.string.setting_up_full_transparent_proxying_), TRANSPROXY_NOTIFY_ID, R.drawable.ic_stat_tor);
|
||||
|
||||
|
@ -831,7 +859,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
if (code == 0)
|
||||
{
|
||||
|
||||
if (enableTether)
|
||||
if (mTransProxyTethering)
|
||||
{
|
||||
showToolbarNotification(getString(R.string.transproxy_enabled_for_tethering_), TRANSPROXY_NOTIFY_ID, R.drawable.ic_stat_tor);
|
||||
|
||||
|
@ -926,8 +954,6 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
private void updatePolipoConfig () throws FileNotFoundException, IOException
|
||||
{
|
||||
|
||||
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
||||
String socksPort = prefs.getString(TorConstants.PREF_SOCKS, TorServiceConstants.PORT_SOCKS_DEFAULT);
|
||||
|
||||
File file = new File(appBinHome, POLIPOCONFIG_ASSET_KEY);
|
||||
|
||||
|
@ -935,8 +961,8 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
|
||||
props.load(new FileReader(file));
|
||||
|
||||
props.put("socksParentProxy", "\"localhost:" + socksPort + "\"");
|
||||
props.put("proxyPort","8118");
|
||||
props.put("socksParentProxy", "\"localhost:" + mPortSOCKS + "\"");
|
||||
props.put("proxyPort",mPortHTTP+"");
|
||||
|
||||
props.store(new FileWriter(file), "updated");
|
||||
|
||||
|
@ -988,17 +1014,6 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
public String generateHashPassword ()
|
||||
{
|
||||
|
||||
PasswordDigest d = PasswordDigest.generateDigest();
|
||||
byte[] s = d.getSecret(); // pass this to authenticate
|
||||
String h = d.getHashedPassword(); // pass this to the Tor on startup.
|
||||
|
||||
return null;
|
||||
}*/
|
||||
|
||||
private synchronized int initControlConnection (int maxTries) throws Exception, RuntimeException
|
||||
{
|
||||
int i = 0;
|
||||
|
@ -1020,12 +1035,10 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
torConnSocket = new Socket(IP_LOCALHOST, controlPort);
|
||||
torConnSocket.setSoTimeout(CONTROL_SOCKET_TIMEOUT);
|
||||
|
||||
boolean oo = true;
|
||||
|
||||
conn = new TorControlConnection(torConnSocket);
|
||||
conn.launchThread(true);//is daemon
|
||||
|
||||
logNotice( "SUCCESS connected to Tor control port");
|
||||
logNotice( "SUCCESS connected to Tor control port.");
|
||||
|
||||
File fileCookie = new File(appCacheHome, TOR_CONTROL_COOKIE);
|
||||
|
||||
|
@ -1037,7 +1050,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
fis.close();
|
||||
conn.authenticate(cookie);
|
||||
|
||||
logNotice( "SUCCESS - authenticated to control port");
|
||||
logNotice( "SUCCESS - authenticated to control port.");
|
||||
|
||||
sendCallbackStatusMessage(getString(R.string.tor_process_starting) + ' ' + getString(R.string.tor_process_complete));
|
||||
|
||||
|
@ -1045,23 +1058,50 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
|
||||
String torProcId = conn.getInfo("process/pid");
|
||||
|
||||
//remove this for now until we can make a clean way to share logs from internal storage
|
||||
/**
|
||||
if (ENABLE_DEBUG_LOG)
|
||||
{
|
||||
//File fileLog = new File(getFilesDir(),"orbot-control-log.txt");
|
||||
//PrintWriter pr = new PrintWriter(new FileWriter(fileLog,true));
|
||||
//conn.setDebugging(pr);
|
||||
|
||||
File fileLog2 = new File(getFilesDir(),"orbot-tor-log.txt");
|
||||
fileLog2.setReadable(true);
|
||||
conn.setConf("Log", "debug file " + fileLog2.getCanonicalPath());
|
||||
}*/
|
||||
|
||||
currentStatus = STATUS_CONNECTING;
|
||||
|
||||
}
|
||||
String confSocks = conn.getInfo("net/listeners/socks");
|
||||
StringTokenizer st = new StringTokenizer(confSocks," ");
|
||||
|
||||
String state = conn.getInfo("dormant");
|
||||
if (state != null && Integer.parseInt(state) == 0)
|
||||
currentStatus = STATUS_ON;
|
||||
else
|
||||
currentStatus = STATUS_CONNECTING;
|
||||
confSocks = st.nextToken().split(":")[1];
|
||||
confSocks = confSocks.substring(0,confSocks.length()-1);
|
||||
mPortSOCKS = Integer.parseInt(confSocks);
|
||||
|
||||
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
||||
String socksPortPref = prefs.getString(TorConstants.PREF_SOCKS, TorServiceConstants.PORT_SOCKS_DEFAULT);
|
||||
|
||||
try
|
||||
{
|
||||
int newSocksPort = Integer.parseInt(socksPortPref);
|
||||
ServerSocket ss = new ServerSocket(newSocksPort);
|
||||
ss.close();
|
||||
|
||||
ArrayList<String> socksLines = new ArrayList<String>();
|
||||
socksLines.add("SOCKSPort " + mPortSOCKS);
|
||||
socksLines.add("SOCKSPort " + socksPortPref);
|
||||
|
||||
conn.setConf(socksLines);
|
||||
|
||||
mPortSOCKS = newSocksPort;
|
||||
|
||||
sendCallbackLogMessage("Local SOCKS port: " + socksPortPref);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//sendCallbackLogMessage("ERROR adding SOCKS on port: " + socksPortPref);
|
||||
sendCallbackLogMessage("Local SOCKS port: " + socksPortPref);
|
||||
|
||||
}
|
||||
|
||||
return Integer.parseInt(torProcId);
|
||||
|
||||
|
@ -1201,7 +1241,15 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
* Returns the port number that the HTTP proxy is running on
|
||||
*/
|
||||
public int getHTTPPort() throws RemoteException {
|
||||
return TorServiceConstants.PORT_HTTP;
|
||||
return mPortHTTP;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the port number that the HTTP proxy is running on
|
||||
*/
|
||||
public int getSOCKSPort() throws RemoteException {
|
||||
return mPortSOCKS;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1275,7 +1323,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
sb.append("): ");
|
||||
sb.append(status);
|
||||
|
||||
logNotice(sb.toString());
|
||||
debug(sb.toString());
|
||||
|
||||
}
|
||||
|
||||
|
@ -1391,7 +1439,22 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
sb.append (" > ");
|
||||
}
|
||||
|
||||
logNotice(sb.toString());
|
||||
if (ENABLE_DEBUG_LOG)
|
||||
debug(sb.toString());
|
||||
else if(status.equals("BUILT"))
|
||||
{
|
||||
|
||||
if (currentStatus == STATUS_CONNECTING)
|
||||
currentStatus = STATUS_ON;
|
||||
|
||||
logNotice(sb.toString());
|
||||
|
||||
}
|
||||
else if (status.equals("CLOSED"))
|
||||
{
|
||||
logNotice(sb.toString());
|
||||
|
||||
}
|
||||
|
||||
if (mShowExpandedNotifications)
|
||||
{
|
||||
|
@ -1408,16 +1471,6 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
{
|
||||
hmBuiltNodes.remove(node.id);
|
||||
|
||||
//how check the IP's of any other nodes we have
|
||||
for (String nodeId : hmBuiltNodes.keySet())
|
||||
{
|
||||
node = hmBuiltNodes.get(nodeId);
|
||||
|
||||
if (node.ipAddress == null)
|
||||
mExecutor.execute(new ExternalIPFetcher(node));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1449,15 +1502,12 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
public void run ()
|
||||
{
|
||||
|
||||
if (mNode.ipAddress != null)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < MAX_ATTEMPTS; i++)
|
||||
{
|
||||
if (conn != null)
|
||||
{
|
||||
try {
|
||||
//String nodeDetails = conn.getInfo("ns/id/"+nodes[0].id);
|
||||
|
||||
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 8118));
|
||||
|
||||
URLConnection conn = new URL(ONIONOO_BASE_URL + mNode.id).openConnection(proxy);
|
||||
|
@ -1480,15 +1530,13 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
JSONObject jsonNodeInfo = new org.json.JSONObject(json.toString());
|
||||
|
||||
JSONArray jsonRelays = jsonNodeInfo.getJSONArray("relays");
|
||||
|
||||
if (jsonRelays.length() > 0)
|
||||
{
|
||||
mNode.ipAddress = jsonRelays.getJSONObject(0).getJSONArray("or_addresses").getString(0).split(":")[0];
|
||||
|
||||
mNode.country = jsonRelays.getJSONObject(0).getString("country_name");
|
||||
mNode.organization = jsonRelays.getJSONObject(0).getString("as_name");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
reader.close();
|
||||
|
@ -1684,8 +1732,6 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
|
||||
conn.signal("NEWNYM");
|
||||
|
||||
//checkAddressAndCountry();
|
||||
|
||||
}
|
||||
catch (Exception ioe){
|
||||
debug("error requesting newnym: " + ioe.getLocalizedMessage());
|
||||
|
@ -1773,12 +1819,28 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long[] getBandwidth() throws RemoteException {
|
||||
|
||||
long[] bw = {lastRead,lastWritten,mTotalTrafficRead,mTotalTrafficWritten};
|
||||
return bw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean flushTransProxy () throws RemoteException {
|
||||
|
||||
try
|
||||
{
|
||||
return flushTransparentProxyRules();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.e(TAG,"error in transproxy",e);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
private ArrayList<String> mStatusBuffer = new ArrayList<String>();
|
||||
|
||||
|
@ -1853,7 +1915,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
if (mHasRoot && mEnableTransparentProxy && mTransProxyNetworkRefresh)
|
||||
{
|
||||
disableTransparentProxy();
|
||||
enableTransparentProxy(mTransProxyAll, mTransProxyTethering);
|
||||
enableTransparentProxy();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2184,7 +2246,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
{
|
||||
|
||||
case TRIM_MEMORY_BACKGROUND:
|
||||
logNotice("trim memory requested: app in the background");
|
||||
debug("trim memory requested: app in the background");
|
||||
return;
|
||||
|
||||
/**
|
||||
|
@ -2196,7 +2258,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
|
||||
case TRIM_MEMORY_COMPLETE:
|
||||
|
||||
logNotice("trim memory requested: cleanup all memory");
|
||||
debug("trim memory requested: cleanup all memory");
|
||||
return;
|
||||
/**
|
||||
public static final int TRIM_MEMORY_COMPLETE
|
||||
|
@ -2206,7 +2268,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
*/
|
||||
case TRIM_MEMORY_MODERATE:
|
||||
|
||||
logNotice("trim memory requested: clean up some memory");
|
||||
debug("trim memory requested: clean up some memory");
|
||||
return;
|
||||
|
||||
/**
|
||||
|
@ -2218,7 +2280,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
|
||||
case TRIM_MEMORY_RUNNING_CRITICAL:
|
||||
|
||||
logNotice("trim memory requested: memory on device is very low and critical");
|
||||
debug("trim memory requested: memory on device is very low and critical");
|
||||
return;
|
||||
/**
|
||||
public static final int TRIM_MEMORY_RUNNING_CRITICAL
|
||||
|
@ -2229,7 +2291,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
|
||||
case TRIM_MEMORY_RUNNING_LOW:
|
||||
|
||||
logNotice("trim memory requested: memory on device is running low");
|
||||
debug("trim memory requested: memory on device is running low");
|
||||
return;
|
||||
/**
|
||||
public static final int TRIM_MEMORY_RUNNING_LOW
|
||||
|
@ -2239,7 +2301,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
*/
|
||||
case TRIM_MEMORY_RUNNING_MODERATE:
|
||||
|
||||
logNotice("trim memory requested: memory on device is moderate");
|
||||
debug("trim memory requested: memory on device is moderate");
|
||||
return;
|
||||
/**
|
||||
public static final int TRIM_MEMORY_RUNNING_MODERATE
|
||||
|
@ -2249,7 +2311,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
|||
*/
|
||||
case TRIM_MEMORY_UI_HIDDEN:
|
||||
|
||||
logNotice("trim memory requested: app is not showing UI anymore");
|
||||
debug("trim memory requested: app is not showing UI anymore");
|
||||
return;
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,10 +48,11 @@ public interface TorServiceConstants {
|
|||
public final static int FILE_WRITE_BUFFER_SIZE = 1024;
|
||||
|
||||
//HTTP Proxy server port
|
||||
public final static int PORT_HTTP = 8118; //just like Privoxy!
|
||||
public static int PORT_HTTP = 8118; //just like Privoxy!
|
||||
|
||||
//Socks port client connects to, server is the Tor binary
|
||||
public final static String PORT_SOCKS_DEFAULT = "9050";
|
||||
public static String PORT_SOCKS_DEFAULT = "9050";
|
||||
|
||||
|
||||
//what is says!
|
||||
public final static String IP_LOCALHOST = "127.0.0.1";
|
||||
|
|
|
@ -30,7 +30,6 @@ public class TorTransProxy implements TorServiceConstants {
|
|||
{
|
||||
mTorService = torService;
|
||||
mFileXtables = fileXTables;
|
||||
|
||||
}
|
||||
|
||||
public void setTransProxyPort (int transProxyPort)
|
||||
|
@ -373,7 +372,7 @@ public class TorTransProxy implements TorServiceConstants {
|
|||
|
||||
logMessage("enabling transproxy for app: " + tApp.getUsername() + " (" + tApp.getUid() + ")");
|
||||
|
||||
dropAllIPv6Traffic(context, tApp.getUid());
|
||||
dropAllIPv6Traffic(context, tApp.getUid(),enableRule);
|
||||
|
||||
script = new StringBuilder();
|
||||
|
||||
|
@ -532,9 +531,15 @@ public class TorTransProxy implements TorServiceConstants {
|
|||
|
||||
}
|
||||
|
||||
public int dropAllIPv6Traffic (Context context, int appUid) throws Exception
|
||||
public int dropAllIPv6Traffic (Context context, int appUid, boolean enableDrop) throws Exception
|
||||
{
|
||||
|
||||
String action = " -A ";
|
||||
String chain = "OUTPUT";
|
||||
|
||||
if (!enableDrop)
|
||||
action = " -D ";
|
||||
|
||||
String ip6tablesPath = getIp6TablesPath(context);
|
||||
Shell shell = Shell.startRootShell();
|
||||
|
||||
|
@ -543,7 +548,8 @@ public class TorTransProxy implements TorServiceConstants {
|
|||
|
||||
script = new StringBuilder();
|
||||
script.append(ip6tablesPath);
|
||||
script.append(" -A OUTPUT");
|
||||
script.append(action);
|
||||
script.append(chain);
|
||||
|
||||
if (appUid != -1)
|
||||
{
|
||||
|
@ -560,13 +566,13 @@ public class TorTransProxy implements TorServiceConstants {
|
|||
return lastExit;
|
||||
}
|
||||
|
||||
/*
|
||||
public int clearAllIPv6Filters (Context context) throws Exception
|
||||
{
|
||||
|
||||
String ip6tablesPath = getIp6TablesPath(context);
|
||||
Shell shell = Shell.startRootShell();
|
||||
|
||||
|
||||
StringBuilder script;
|
||||
|
||||
script = new StringBuilder();
|
||||
|
@ -578,6 +584,29 @@ public class TorTransProxy implements TorServiceConstants {
|
|||
shell.close();
|
||||
|
||||
return lastExit;
|
||||
}*/
|
||||
|
||||
public int flushTransproxyRules (Context context) throws Exception
|
||||
{
|
||||
int exit = -1;
|
||||
String ipTablesPath = getIpTablesPath(context);
|
||||
|
||||
StringBuilder script = new StringBuilder();
|
||||
script.append(ipTablesPath);
|
||||
script.append(" -t nat");
|
||||
script.append(" -F ");
|
||||
|
||||
Shell shell = Shell.startRootShell();
|
||||
executeCommand (shell, script.toString());
|
||||
|
||||
script = new StringBuilder();
|
||||
script.append(ipTablesPath);
|
||||
script.append(" -t filter");
|
||||
script.append(" -F ");
|
||||
|
||||
dropAllIPv6Traffic(context,-1,false);
|
||||
|
||||
return exit;
|
||||
}
|
||||
|
||||
public int setTransparentProxyingAll(Context context, boolean enable) throws Exception
|
||||
|
@ -589,10 +618,7 @@ public class TorTransProxy implements TorServiceConstants {
|
|||
if (!enable)
|
||||
action = " -D ";
|
||||
|
||||
if (enable)
|
||||
dropAllIPv6Traffic(context,-1);
|
||||
else
|
||||
clearAllIPv6Filters(context);
|
||||
dropAllIPv6Traffic(context,-1,enable);
|
||||
|
||||
String ipTablesPath = getIpTablesPath(context);
|
||||
|
||||
|
@ -698,13 +724,13 @@ public class TorTransProxy implements TorServiceConstants {
|
|||
executeCommand (shell, script.toString());
|
||||
script = new StringBuilder();
|
||||
|
||||
//allow access to local SOCKS port
|
||||
//allow access to local HTTP port
|
||||
script.append(ipTablesPath);
|
||||
script.append(" -t filter");
|
||||
script.append(action).append(srcChainName);
|
||||
script.append(" -p tcp");
|
||||
script.append(" -m tcp");
|
||||
script.append(" --dport ").append(PORT_SOCKS_DEFAULT);
|
||||
script.append(" --dport ").append(mTorService.getHTTPPort());
|
||||
script.append(" -j ACCEPT");
|
||||
|
||||
executeCommand (shell, script.toString());
|
||||
|
@ -716,7 +742,7 @@ public class TorTransProxy implements TorServiceConstants {
|
|||
script.append(action).append(srcChainName);
|
||||
script.append(" -p tcp");
|
||||
script.append(" -m tcp");
|
||||
script.append(" --dport ").append(PORT_HTTP);
|
||||
script.append(" --dport ").append(mTorService.getSOCKSPort());
|
||||
script.append(" -j ACCEPT");
|
||||
|
||||
executeCommand (shell, script.toString());
|
||||
|
@ -734,19 +760,6 @@ public class TorTransProxy implements TorServiceConstants {
|
|||
executeCommand (shell, script.toString());
|
||||
script = new StringBuilder();
|
||||
|
||||
//allow access to local DNS port
|
||||
script.append(ipTablesPath);
|
||||
script.append(" -t filter");
|
||||
script.append(action).append(srcChainName);
|
||||
script.append(" -p udp");
|
||||
script.append(" -m udp");
|
||||
script.append(" --dport ").append(mDNSPort);
|
||||
script.append(" -j ACCEPT");
|
||||
|
||||
executeCommand (shell, script.toString());
|
||||
script = new StringBuilder();
|
||||
|
||||
|
||||
// Reject all other packets
|
||||
script.append(ipTablesPath);
|
||||
script.append(" -t filter");
|
||||
|
|
|
@ -28,6 +28,8 @@ public class SettingsPreferences
|
|||
|
||||
private CheckBoxPreference prefCBTransProxy = null;
|
||||
private CheckBoxPreference prefcBTransProxyAll = null;
|
||||
private Preference prefTransProxyFlush = null;
|
||||
|
||||
private Preference prefTransProxyApps = null;
|
||||
private CheckBoxPreference prefHiddenServices = null;
|
||||
private CheckBoxPreference prefRequestRoot = null;
|
||||
|
@ -37,6 +39,8 @@ public class SettingsPreferences
|
|||
|
||||
private final static int HIDDEN_SERVICE_PREF_IDX = 6;
|
||||
private final static int TRANSPROXY_GROUP_IDX = 1;
|
||||
private final static int DEBUG_GROUP_IDX = 8;
|
||||
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
|
@ -74,6 +78,23 @@ public class SettingsPreferences
|
|||
|
||||
prefCBTransProxy = ((CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX)).getPreference(0));
|
||||
prefcBTransProxyAll = (CheckBoxPreference)((PreferenceCategory)this.getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX)).getPreference(1);
|
||||
|
||||
prefTransProxyFlush = (Preference)((PreferenceCategory)this.getPreferenceScreen().getPreference(DEBUG_GROUP_IDX)).getPreference(8);
|
||||
prefTransProxyFlush.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference arg0) {
|
||||
|
||||
Intent data = new Intent();
|
||||
data.putExtra("transproxywipe", true);
|
||||
setResult(RESULT_OK,data);
|
||||
|
||||
finish();
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
prefTransProxyApps = ((PreferenceCategory)this.getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX)).getPreference(2);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue