[tor-commits] [orbot/master] Small VPN and socket monitoring related fixes
n8fr8 at torproject.org
n8fr8 at torproject.org
Mon Apr 13 12:38:26 UTC 2015
commit 933b2e9b4ec4dd3d683953d2c5a7caba93f3effc
Author: Nathan Freitas <nathan at freitas.net>
Date: Fri Apr 10 22:29:13 2015 -0400
Small VPN and socket monitoring related fixes
---
src/org/torproject/android/service/TorService.java | 24 +++-----
.../torproject/android/vpn/OrbotVpnService.java | 61 ++++++++++++++++++--
2 files changed, 64 insertions(+), 21 deletions(-)
diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java
index 3e7edc6..e26dca2 100644
--- a/src/org/torproject/android/service/TorService.java
+++ b/src/org/torproject/android/service/TorService.java
@@ -727,7 +727,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
extraLines.append("AutomapHostsOnResolve 1").append('\n');
extraLines.append("DisableNetwork 0").append('\n');
-
+
//.extraLines.append("CircuitStreamTimeout 60").append('\n');
processSettingsImpl(extraLines);
@@ -974,7 +974,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
return true;
}
- private boolean runTorShellCmd(Shell shell) throws Exception
+ private boolean runTorShellCmd(final Shell shell) throws Exception
{
String torrcPath = new File(appBinHome, TORRC_ASSET_KEY).getCanonicalPath();
@@ -1005,18 +1005,16 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
shellTorCommand = new SimpleCommand(torCmdString);
shell.add(shellTorCommand).waitForFinish();
-
exitCode = shellTorCommand.getExitCode();
output = shellTorCommand.getOutput();
-
if (exitCode != 0 && output != null && output.length() > 0)
{
logNotice("Tor (" + exitCode + "): " + output);
//throw new Exception ("unable to start");
return false;
}
-
+
//now try to connect
mLastProcessId = initControlConnection (100,false);
@@ -1031,7 +1029,6 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
{
logNotice("Tor started; process id=" + mLastProcessId);
-
}
@@ -1749,7 +1746,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
Proxy proxy = null;
- if (mUseVPN)
+ if (!mUseVPN) //if not on the VPN then we should proxy
{
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 8118));
conn = new URL(ONIONOO_BASE_URL + mNode.id).openConnection(proxy);
@@ -2211,13 +2208,14 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
if (mUseVPN) //set the proxy here if we aren't using a bridge
{
+ /*
if (!mIsLollipop)
{
String proxyType = "socks5";
String proxyHost = "127.0.0.1";
extraLines.append(proxyType + "Proxy" + ' ' + proxyHost + ':' + mVpnProxyPort).append('\n');
};
-
+ */
}
else
{
@@ -2294,14 +2292,6 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
}
- /**
- extraLines.append("Bridge obfs3 192.36.31.74:35870 FEB63CA5EBD805C42DC0E5FBDDE82F3B1CDD80B4\n");
- extraLines.append("Bridge obfs3 131.72.136.85:52447 1AC601EA50397948DD5FB5B453922EB8A69A5EF6\n");
- extraLines.append("Bridge obfs3 192.36.31.76:33439 54C59DF0FCEE2D08F789CA04E5B57519071C232B\n");
- */
-
- // extraLines.append("Bridge obfs4 54.66.226.196:18965 95151988DC29FCCB4F610A1C700A1DDF7D5FFBD4 cert=3wYo19iAMNbfO7snEeqVBmsIat+RMmMDV5BV4jDvXuz9BaACXt7XffC8Dz8J1MUvLKHKaQ iat-mode=0\n");
-
}
else
{
@@ -2617,5 +2607,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
// TODO Auto-generated method stub
return null;
}
+
+
}
diff --git a/src/org/torproject/android/vpn/OrbotVpnService.java b/src/org/torproject/android/vpn/OrbotVpnService.java
index bc06f43..4c214ed 100644
--- a/src/org/torproject/android/vpn/OrbotVpnService.java
+++ b/src/org/torproject/android/vpn/OrbotVpnService.java
@@ -16,7 +16,6 @@
package org.torproject.android.vpn;
-import java.io.IOException;
import java.net.InetAddress;
import java.util.Locale;
@@ -86,7 +85,9 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
}
if (!isLollipop)
+ {
startSocksBypass();
+ }
setupTun2Socks();
}
@@ -114,8 +115,7 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
return START_STICKY;
}
-
-
+
private void startSocksBypass()
{
@@ -183,7 +183,7 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
Tun2Socks.Stop();
- stopSocksBypass ();
+ //stopSocksBypass ();
if (mInterface != null){
try
@@ -203,6 +203,9 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
Log.d(TAG,"error stopping tun2socks",e);
}
}
+
+ mThreadVPN = null;
+
}
@Override
@@ -310,5 +313,53 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
super.onRevoke();
}
-
+ /*
+ private void monitorSocketsFD ()
+ {
+
+ final String fdPath = "/proc/self/fd/";
+
+ new Thread ()
+ {
+ public void run ()
+ {
+ while (mThreadVPN != null)
+ {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ try
+ {
+
+ File fileDir = new File(fdPath);
+ File[] files = fileDir.listFiles();
+ if (files != null)
+ for (File file : files)
+ {
+ String cPath = file.getCanonicalPath();
+
+ if (cPath.contains("socket"))
+ {
+ Log.d(TAG,"found FD for socket: " + file.getAbsolutePath());
+
+ protect(Integer.parseInt(file.getName()));
+
+ }
+
+ }
+ }
+ catch (Exception e)
+ {
+ Log.e(TAG,"error getting fd: " + fdPath,e);
+ }
+ }
+ }
+ }.start();
+
+ }
+ */
}
More information about the tor-commits
mailing list