summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2014-10-16 10:22:27 +0200
committerParménides GV <parmegv@sdf.org>2014-10-16 10:22:27 +0200
commit5e1d89482034c94f22547a12298bdf956761c0ba (patch)
treeed43db3b25588f77ab821265c0521995b886888c /app/src/main/java
parent948f984f6aa4660f849ca643d3b228beac6a1652 (diff)
Move blocking code to thread's run.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/VoidVpnService.java36
1 files changed, 15 insertions, 21 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/VoidVpnService.java b/app/src/main/java/se/leap/bitmaskclient/VoidVpnService.java
index b7289c23..7b597554 100644
--- a/app/src/main/java/se/leap/bitmaskclient/VoidVpnService.java
+++ b/app/src/main/java/se/leap/bitmaskclient/VoidVpnService.java
@@ -1,10 +1,11 @@
package se.leap.bitmaskclient;
import android.content.Intent;
+import android.os.Process;
import android.net.VpnService;
import android.util.Log;
-public class VoidVpnService extends VpnService {
+public class VoidVpnService extends VpnService {
static final String START_BLOCKING_VPN_PROFILE = "se.leap.bitmaskclient.START_BLOCKING_VPN_PROFILE";
static final String TAG = VoidVpnService.class.getSimpleName();
@@ -14,29 +15,22 @@ public class VoidVpnService extends VpnService {
String action = intent.getAction();
if (action == START_BLOCKING_VPN_PROFILE) {
new Thread(new Runnable() {
- public void run() {
- blockConnections();
+ public void run() {
+ Builder builder = new Builder();
+ builder.setSession("Blocking until running");
+ builder.addAddress("10.42.0.8",16);
+ builder.addRoute("0.0.0.0", 1);
+ builder.addRoute("192.168.1.0", 24);
+ builder.addDnsServer("10.42.0.1");
+ try {
+ builder.establish();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ android.util.Log.d(TAG, "VoidVpnService set up");
}
}).run();
}
return 0;
}
-
- public void blockConnections() {
- Builder builder = new Builder();
- builder.setSession("Blocking until running");
- builder.addAddress("10.42.0.8",16);
- builder.addRoute("0.0.0.0", 1);
- builder.addRoute("128.0.0.0", 1);
- builder.addRoute("192.168.1.0", 24);
- builder.addDnsServer("10.42.0.1");
- builder.establish();
- android.util.Log.d(TAG, "VoidVpnService set up");
- try {
- new java.net.Socket("sdf.org", 80);
- Log.d(TAG, "VoidVpnService doesn's stop traffic");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
}