[tor-commits] [orbot/master] continued re-integration of VPN feature
n8fr8 at torproject.org
n8fr8 at torproject.org
Thu Oct 13 19:38:51 UTC 2016
commit ca238c652169bda44cedbe0b1db8ad8793dd0f3d
Author: Nathan Freitas <nathan at freitas.net>
Date: Tue Oct 4 23:46:17 2016 -0400
continued re-integration of VPN feature
---
.../main/java/org/torproject/android/OrbotApp.java | 1 -
orbotservice/build.gradle | 11 ++++++++---
.../org/torproject/android/service/TorService.java | 12 +++++++-----
.../android/service/vpn/OrbotVpnManager.java | 20 +++++++++-----------
.../torproject/android/service/vpn/Tun2Socks.java | 15 ++++++---------
orbotservice/src/main/jni/Application.mk | 2 +-
6 files changed, 31 insertions(+), 30 deletions(-)
diff --git a/app/src/main/java/org/torproject/android/OrbotApp.java b/app/src/main/java/org/torproject/android/OrbotApp.java
index cbf118b..e6fd014 100644
--- a/app/src/main/java/org/torproject/android/OrbotApp.java
+++ b/app/src/main/java/org/torproject/android/OrbotApp.java
@@ -30,7 +30,6 @@ public class OrbotApp extends Application implements OrbotConstants
Languages.setup(OrbotMainActivity.class, R.string.menu_settings);
Languages.setLanguage(this, Prefs.getDefaultLocale(), true);
-
}
@Override
diff --git a/orbotservice/build.gradle b/orbotservice/build.gradle
index d8296ba..cfc0a53 100644
--- a/orbotservice/build.gradle
+++ b/orbotservice/build.gradle
@@ -4,13 +4,18 @@ android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
- sourceSets.main.jni.srcDirs = []
+ sourceSets {
+ main {
+ jni.srcDirs = []
+ }
+ }
defaultConfig {
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName "1.0"
+
}
buildTypes {
release {
@@ -22,7 +27,7 @@ android {
dependencies {
compile project(':jsocksAndroid')
- compile 'com.android.support:appcompat-v7:23.+'
- compile fileTree(dir: 'libs', include: ['*.jar'])
+ compile 'com.android.support:appcompat-v7:23.4.0'
+ compile fileTree(dir: 'libs', include: ['*.jar','*.so'])
testCompile 'junit:junit:4.12'
}
diff --git a/orbotservice/src/main/java/org/torproject/android/service/TorService.java b/orbotservice/src/main/java/org/torproject/android/service/TorService.java
index b50b00f..2cff209 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/TorService.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/TorService.java
@@ -182,8 +182,9 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
if (mNotificationManager != null)
mNotificationManager.cancelAll();
+ if (mEventHandler != null)
+ mEventHandler.getNodes().clear();
- mEventHandler.getNodes().clear();
mNotificationShowing = false;
}
@@ -243,7 +244,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
expandedView.setTextViewText(R.id.info, notifyMsg);
}
- if (mEventHandler.getNodes().size() > 0)
+ if (mEventHandler != null && mEventHandler.getNodes().size() > 0)
{
Set<String> itBuiltNodes = mEventHandler.getNodes().keySet();
for (String key : itBuiltNodes)
@@ -532,6 +533,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
fileTorRc = new File(appBinHome, TorServiceConstants.TORRC_ASSET_KEY);
filePdnsd = new File(appBinHome, TorServiceConstants.PDNSD_ASSET_KEY);
+ mEventHandler = new TorEventHandler(this);
if (mNotificationManager == null)
{
@@ -735,7 +737,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
try {
// make sure there are no stray daemons running
- killAllDaemons();
+// killAllDaemons();
sendCallbackStatus(STATUS_STARTING);
sendCallbackLogMessage(getString(R.string.status_starting_up));
@@ -1146,15 +1148,15 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
return result;
}
- public void addEventHandler () throws Exception
+ public synchronized void addEventHandler () throws Exception
{
// We extend NullEventHandler so that we don't need to provide empty
// implementations for all the events we don't care about.
// ...
logNotice( "adding control port event handler");
- mEventHandler = new TorEventHandler(this);
conn.setEventHandler(mEventHandler);
+
conn.setEvents(Arrays.asList(new String[]{
"ORCONN", "CIRC", "NOTICE", "WARN", "ERR","BW"}));
diff --git a/orbotservice/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java b/orbotservice/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java
index f2e8d4c..ae03881 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java
@@ -17,6 +17,7 @@
package org.torproject.android.service.vpn;
import android.annotation.TargetApi;
+import android.app.Application;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
@@ -73,20 +74,21 @@ public class OrbotVpnManager implements Handler.Callback {
//this is the actual DNS server we talk to over UDP or TCP (now using Tor's DNS port)
private final static String DEFAULT_ACTUAL_DNS_HOST = "127.0.0.1";
private final static int DEFAULT_ACTUAL_DNS_PORT = TorServiceConstants.TOR_DNS_PORT_DEFAULT;
-
- private boolean isRestart = false;
+
+
+ File filePdnsd = null;
+
+ private boolean isRestart = false;
private VpnService mService;
- static{
- System.loadLibrary("tun2socks");
- }
-
public OrbotVpnManager (VpnService service)
{
mService = service;
- }
+ filePdnsd = mService.getDir(TorServiceConstants.DIRECTORY_TOR_BINARY, Application.MODE_PRIVATE);
+
+ }
//public int onStartCommand(Intent intent, int flags, int startId) {
public int handleIntent(Builder builder, Intent intent) {
@@ -394,12 +396,8 @@ public class OrbotVpnManager implements Handler.Callback {
}
- File filePdnsd = null;
-
private void startDNS (String dns, int port) throws IOException, TimeoutException
{
- File filePdnsd = null;//getDir(TorServiceConstants.DIRECTORY_TOR_BINARY, Application.MODE_PRIVATE);
-
makePdnsdConf(mService, dns, port,filePdnsd.getParentFile() );
ArrayList<String> customEnv = new ArrayList<String>();
diff --git a/orbotservice/src/main/java/org/torproject/android/service/vpn/Tun2Socks.java b/orbotservice/src/main/java/org/torproject/android/service/vpn/Tun2Socks.java
index 6f61bb4..cff4c1c 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/vpn/Tun2Socks.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/vpn/Tun2Socks.java
@@ -30,6 +30,11 @@ import java.net.Socket;
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
public class Tun2Socks
{
+
+ static{
+ System.loadLibrary("tun2socks");
+ }
+
public static interface IProtectSocket
{
boolean doVpnProtect(Socket socket);
@@ -51,9 +56,7 @@ public class Tun2Socks
// Note: this class isn't a singleton, but you can't run more
// than one instance due to the use of global state (the lwip
// module, etc.) in the native code.
-
- private static boolean mLibLoaded = false;
-
+
public static void Start(
ParcelFileDescriptor vpnInterfaceFileDescriptor,
int vpnInterfaceMTU,
@@ -63,12 +66,6 @@ public class Tun2Socks
String udpgwServerAddress,
boolean udpgwTransparentDNS)
{
-
- if (!mLibLoaded)
- {
- System.loadLibrary("tun2socks");
- mLibLoaded = true;
- }
mVpnInterfaceFileDescriptor = vpnInterfaceFileDescriptor;
mVpnInterfaceMTU = vpnInterfaceMTU;
diff --git a/orbotservice/src/main/jni/Application.mk b/orbotservice/src/main/jni/Application.mk
index 2fab495..25058c1 100644
--- a/orbotservice/src/main/jni/Application.mk
+++ b/orbotservice/src/main/jni/Application.mk
@@ -1,5 +1,5 @@
#APP_ABI := armeabi x86
APP_ABI := armeabi
-APP_PLATFORM := android-10
+APP_PLATFORM := android-14
APP_STL := stlport_static
NDK_TOOLCHAIN_VERSION := 4.8
More information about the tor-commits
mailing list