blob: 5f7c0ab1c61b8d94e983f7e9f3a2e4b26ff43335 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
package se.leap.bitmaskclient;
import android.content.Intent;
import android.net.VpnService;
import android.util.Log;
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();
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
String action = intent.getAction();
if (action == START_BLOCKING_VPN_PROFILE) {
new Thread(new Runnable() {
public void run() {
blockConnections();
}
}).run();
}
return 0;
}
public void blockConnections() {
Builder builder = new Builder();
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();
}
}
}
|