diff options
Diffstat (limited to 'app/src/main/java/org/pacien/tincapp/service/TincVpnService.java')
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/service/TincVpnService.java | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/service/TincVpnService.java b/app/src/main/java/org/pacien/tincapp/service/TincVpnService.java deleted file mode 100644 index 1a6f58f..0000000 --- a/app/src/main/java/org/pacien/tincapp/service/TincVpnService.java +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | package org.pacien.tincapp.service; | ||
2 | |||
3 | import android.app.Service; | ||
4 | import android.content.Intent; | ||
5 | import android.net.VpnService; | ||
6 | |||
7 | import org.pacien.tincapp.BuildConfig; | ||
8 | import org.pacien.tincapp.commands.Tinc; | ||
9 | import org.pacien.tincapp.commands.Tincd; | ||
10 | import org.pacien.tincapp.context.AppPaths; | ||
11 | |||
12 | import java.io.IOException; | ||
13 | |||
14 | import static org.pacien.tincapp.util.Function.applyIgnoringExcept; | ||
15 | |||
16 | /** | ||
17 | * @author pacien | ||
18 | */ | ||
19 | public class TincVpnService extends VpnService { | ||
20 | |||
21 | static final public String INTENT_EXTRA_NET_NAME = "netName"; | ||
22 | |||
23 | private String netName; | ||
24 | |||
25 | @Override | ||
26 | public int onStartCommand(Intent intent, int flags, int startId) { | ||
27 | this.netName = intent.getStringExtra(INTENT_EXTRA_NET_NAME); | ||
28 | |||
29 | Builder net = new Builder().setSession(this.netName); | ||
30 | VpnInterfaceConfigurator.applyConfiguration(net, AppPaths.netConfFile(this, this.netName)); | ||
31 | applyIgnoringExcept(net::addDisallowedApplication, BuildConfig.APPLICATION_ID); | ||
32 | |||
33 | try { | ||
34 | Tincd.start(this, this.netName, net.establish().detachFd()); | ||
35 | } catch (IOException e) { | ||
36 | e.printStackTrace(); | ||
37 | } | ||
38 | |||
39 | return Service.START_STICKY; | ||
40 | } | ||
41 | |||
42 | @Override | ||
43 | public void onDestroy() { | ||
44 | try { | ||
45 | Tinc.stop(this, this.netName); | ||
46 | } catch (IOException e) { | ||
47 | e.printStackTrace(); | ||
48 | } | ||
49 | } | ||
50 | |||
51 | } | ||