[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [orbot/master] multiple fixes for status check and new transproxy calls
commit 3e58ee9b75bbcef9006abef48a384d4513d1d7e3
Author: Nathan Freitas <nathan@xxxxxxxxxxx>
Date: Thu Aug 7 15:34:16 2014 -0400
multiple fixes for status check and new transproxy calls
- update to the new transproxy selective calls
- improve status resume/check code
---
src/org/torproject/android/service/TorService.java | 66 ++++++++++----------
1 file changed, 34 insertions(+), 32 deletions(-)
diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java
index 88806ac..963d52d 100644
--- a/src/org/torproject/android/service/TorService.java
+++ b/src/org/torproject/android/service/TorService.java
@@ -52,6 +52,7 @@ import org.torproject.android.R;
import org.torproject.android.TorConstants;
import org.torproject.android.Utils;
import org.torproject.android.settings.AppManager;
+import org.torproject.android.settings.TorifiedApp;
import android.annotation.SuppressLint;
import android.app.Application;
@@ -172,15 +173,14 @@ public class TorService extends Service implements TorServiceConstants, TorConst
mLastProcessId = initControlConnection(1);
- if (mLastProcessId != -1)
+ if (mLastProcessId != -1 && conn != null)
{
sendCallbackLogMessage (getString(R.string.found_existing_tor_process));
- String state = conn.getInfo("dormant");
- if (state != null && Integer.parseInt(state) == 0)
- currentStatus = STATUS_ON;
- else
- currentStatus = STATUS_CONNECTING;
+ String msg = conn.getInfo("status/circuit-established");
+ sendCallbackLogMessage(msg);
+
+ currentStatus = STATUS_ON;
return true;
}
@@ -799,19 +799,26 @@ public class TorService extends Service implements TorServiceConstants, TorConst
debug ("Transparent Proxying: clearing existing rules...");
//clear rules first
- mTransProxy.clearTransparentProxyingAll(this);
+ // mTransProxy.clearTransparentProxyingAll(this);
if(proxyAll)
{
// showToolbarNotification(getString(R.string.setting_up_full_transparent_proxying_), TRANSPROXY_NOTIFY_ID, R.drawable.ic_stat_tor);
- code = mTransProxy.setTransparentProxyingAll(this);
+ //clear existing rules
+ //code = mTransProxy.setTransparentProxyingAll(this, false);
+
+ code = mTransProxy.setTransparentProxyingAll(this, true);
}
else
{
//showToolbarNotification(getString(R.string.setting_up_app_based_transparent_proxying_), TRANSPROXY_NOTIFY_ID, R.drawable.ic_stat_tor);
+ ArrayList<TorifiedApp> apps = AppManager.getApps(this, TorServiceUtils.getSharedPrefs(getApplicationContext()));
+
+ //clear exiting rules
+ //code = mTransProxy.setTransparentProxyingByApp(this,apps, false);
- code = mTransProxy.setTransparentProxyingByApp(this,AppManager.getApps(this, TorServiceUtils.getSharedPrefs(getApplicationContext())));
+ code = mTransProxy.setTransparentProxyingByApp(this,apps, true);
}
@@ -856,7 +863,13 @@ public class TorService extends Service implements TorServiceConstants, TorConst
if (mTransProxy == null)
mTransProxy = new TorTransProxy(this, fileXtables);
- mTransProxy.clearTransparentProxyingAll(this);
+ if (mTransProxyAll)
+ mTransProxy.setTransparentProxyingAll(this, false);
+ else
+ {
+ ArrayList<TorifiedApp> apps = AppManager.getApps(this, TorServiceUtils.getSharedPrefs(getApplicationContext()));
+ mTransProxy.setTransparentProxyingByApp(this, apps, false);
+ }
return true;
}
@@ -986,24 +999,6 @@ public class TorService extends Service implements TorServiceConstants, TorConst
{
int i = 0;
int controlPort = -1;
- File fileCookie = new File(appCacheHome, TOR_CONTROL_COOKIE);
-
- if (conn != null)
- {
-
- if (fileCookie.exists())
- {
- byte[] cookie = new byte[(int)fileCookie.length()];
- DataInputStream fis = new DataInputStream(new FileInputStream(fileCookie));
- fis.read(cookie);
- fis.close();
- conn.authenticate(cookie);
-
- String torProcId = conn.getInfo("process/pid");
- return Integer.parseInt(torProcId);
-
- }
- }
int attempt = 0;
@@ -1025,7 +1020,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
logNotice( "SUCCESS connected to Tor control port");
- fileCookie = new File(appCacheHome, TOR_CONTROL_COOKIE);
+ File fileCookie = new File(appCacheHome, TOR_CONTROL_COOKIE);
if (fileCookie.exists())
{
@@ -1052,8 +1047,15 @@ public class TorService extends Service implements TorServiceConstants, TorConst
File fileLog2 = new File(getFilesDir(),"orbot-tor-log.txt");
conn.setConf("Log", "debug file " + fileLog2.getCanonicalPath());
+
}
+ String state = conn.getInfo("dormant");
+ if (state != null && Integer.parseInt(state) == 0)
+ currentStatus = STATUS_ON;
+ else
+ currentStatus = STATUS_CONNECTING;
+
return Integer.parseInt(torProcId);
}
@@ -1075,7 +1077,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
try {
logNotice("waiting...");
- Thread.sleep(5000); }
+ Thread.sleep(1000); }
catch (Exception e){}
}
@@ -1838,8 +1840,8 @@ public class TorService extends Service implements TorServiceConstants, TorConst
logNotice(context.getString(R.string.network_connectivity_is_good_waking_tor_up_));
showToolbarNotification(getString(R.string.status_activated),NOTIFY_ID,R.drawable.ic_stat_tor);
- if (mHasRoot && mEnableTransparentProxy)
- enableTransparentProxy(mTransProxyAll, mTransProxyTethering);
+ //if (mHasRoot && mEnableTransparentProxy)
+ //enableTransparentProxy(mTransProxyAll, mTransProxyTethering);
}
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits