aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org/pacien
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/org/pacien')
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt114
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt145
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt201
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt196
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/ViewLogActivity.kt164
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Command.kt46
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Executor.kt85
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tinc.kt72
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/TincApp.kt74
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tincd.kt37
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/App.kt85
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppInfo.kt47
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppLogger.kt63
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppNotificationManager.kt84
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppPaths.kt71
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/CrashRecorder.kt48
-rw-r--r--app/src/main/java/org/pacien/tincapp/data/CidrAddress.kt39
-rw-r--r--app/src/main/java/org/pacien/tincapp/data/TincConfiguration.kt41
-rw-r--r--app/src/main/java/org/pacien/tincapp/data/VpnInterfaceConfiguration.kt92
-rw-r--r--app/src/main/java/org/pacien/tincapp/extensions/Android.kt41
-rw-r--r--app/src/main/java/org/pacien/tincapp/extensions/ApacheConfiguration.kt33
-rw-r--r--app/src/main/java/org/pacien/tincapp/extensions/Java.kt38
-rw-r--r--app/src/main/java/org/pacien/tincapp/extensions/VpnServiceBuilder.kt80
-rw-r--r--app/src/main/java/org/pacien/tincapp/intent/Actions.kt39
-rw-r--r--app/src/main/java/org/pacien/tincapp/intent/BroadcastMapper.kt38
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt236
-rw-r--r--app/src/main/java/org/pacien/tincapp/utils/PemUtils.kt94
-rw-r--r--app/src/main/java/org/pacien/tincapp/utils/ProgressModal.kt49
-rw-r--r--app/src/main/java/org/pacien/tincapp/utils/TincKeyring.kt44
29 files changed, 2396 insertions, 0 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt
new file mode 100644
index 0000000..4dc2381
--- /dev/null
+++ b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt
@@ -0,0 +1,114 @@
1/*
2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon
3 * Copyright (C) 2017-2018 Pacien TRAN-GIRARD
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19package org.pacien.tincapp.activities
20
21import android.os.Bundle
22import android.support.annotation.StringRes
23import android.support.design.widget.Snackbar
24import android.support.v7.app.AlertDialog
25import android.support.v7.app.AppCompatActivity
26import android.view.Menu
27import android.view.MenuItem
28import kotlinx.android.synthetic.main.base.*
29import org.pacien.tincapp.R
30import org.pacien.tincapp.context.App
31import org.pacien.tincapp.context.AppInfo
32import org.pacien.tincapp.context.AppPaths
33import org.pacien.tincapp.context.CrashRecorder
34import org.pacien.tincapp.utils.ProgressModal
35
36/**
37 * @author pacien
38 */
39abstract class BaseActivity : AppCompatActivity() {
40 private var active = false
41
42 override fun onCreate(savedInstanceState: Bundle?) {
43 super.onCreate(savedInstanceState)
44 setContentView(R.layout.base)
45 }
46
47 override fun onCreateOptionsMenu(m: Menu): Boolean {
48 menuInflater.inflate(R.menu.menu_base, m)
49 return true
50 }
51
52 override fun onStart() {
53 super.onStart()
54 active = true
55 }
56
57 override fun onResume() {
58 super.onResume()
59 active = true
60 }
61
62 override fun onPause() {
63 active = false
64 super.onPause()
65 }
66
67 override fun onStop() {
68 active = false
69 super.onStop()
70 }
71
72 fun aboutDialog(@Suppress("UNUSED_PARAMETER") i: MenuItem) {
73 AlertDialog.Builder(this)
74 .setTitle(resources.getString(R.string.app_name))
75 .setMessage(resources.getString(R.string.app_short_desc) + "\n\n" +
76 resources.getString(R.string.app_copyright) + " " +
77 resources.getString(R.string.app_license) + "\n\n" +
78 AppInfo.all())
79 .setNeutralButton(R.string.action_open_project_website) { _, _ -> App.openURL(resources.getString(R.string.app_website_url)) }
80 .setPositiveButton(R.string.action_close) { _, _ -> Unit }
81 .show()
82 }
83
84 fun runOnUiThread(action: () -> Unit) {
85 if (active) super.runOnUiThread(action)
86 }
87
88 fun handleRecentCrash() {
89 if (!CrashRecorder.hasPreviouslyCrashed()) return
90 CrashRecorder.dismissPreviousCrash()
91
92 AlertDialog.Builder(this)
93 .setTitle(R.string.title_app_crash)
94 .setMessage(listOf(
95 resources.getString(R.string.message_app_crash),
96 resources.getString(R.string.message_crash_logged, AppPaths.appLogFile().absolutePath)
97 ).joinToString("\n\n"))
98 .setNeutralButton(R.string.action_send_report) { _, _ ->
99 App.sendMail(
100 resources.getString(R.string.app_dev_email),
101 listOf(R.string.app_name, R.string.title_app_crash).joinToString(" / ", transform = resources::getString),
102 AppPaths.appLogFile().let { if (it.exists()) it.readText() else "" })
103 }
104 .setPositiveButton(R.string.action_close) { _, _ -> Unit }
105 .show()
106 }
107
108 protected fun notify(@StringRes msg: Int) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show()
109 protected fun notify(msg: String) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show()
110 protected fun showProgressDialog(@StringRes msg: Int): AlertDialog = ProgressModal.show(this, getString(msg))
111 protected fun showErrorDialog(msg: String): AlertDialog = AlertDialog.Builder(this)
112 .setTitle(R.string.title_error).setMessage(msg)
113 .setPositiveButton(R.string.action_close) { _, _ -> Unit }.show()
114}
diff --git a/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt
new file mode 100644
index 0000000..2aab304
--- /dev/null
+++ b/app/src/main/java/org/pacien/tincapp/activities/ConfigureActivity.kt
@@ -0,0 +1,145 @@
1/*
2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon
3 * Copyright (C) 2017-2018 Pacien TRAN-GIRARD
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19package org.pacien.tincapp.activities
20
21import android.content.Intent
22import android.os.Bundle
23import android.support.annotation.StringRes
24import android.support.v7.app.AlertDialog
25import android.view.View
26import com.google.zxing.integration.android.IntentIntegrator
27import com.google.zxing.integration.android.IntentResult
28import java8.util.concurrent.CompletableFuture
29import kotlinx.android.synthetic.main.base.*
30import kotlinx.android.synthetic.main.dialog_encrypt_decrypt_keys.view.*
31import kotlinx.android.synthetic.main.dialog_network_generate.view.*
32import kotlinx.android.synthetic.main.dialog_network_join.view.*
33import kotlinx.android.synthetic.main.page_configure.*
34import org.pacien.tincapp.R
35import org.pacien.tincapp.commands.Tinc
36import org.pacien.tincapp.commands.TincApp
37import org.pacien.tincapp.context.AppPaths
38import org.pacien.tincapp.extensions.Java.exceptionallyAccept
39import java.util.regex.Pattern
40
41/**
42 * @author pacien
43 */