From c9476a7b00127c3464f6bef532e7f42cd3046aeb Mon Sep 17 00:00:00 2001
From: Revertron <105154+Revertron@users.noreply.github.com>
Date: Sat, 12 Nov 2022 12:37:40 +0100
Subject: [PATCH] Made fast reconnect when network becomes up. (#28)
* Made fast reconnect when network becomes up.
* Use `retryPeersNow`
---
app/build.gradle | 4 +-
app/src/main/AndroidManifest.xml | 1 +
.../yggdrasil/GlobalApplication.kt | 1 +
.../yggdrasil/NetworkStateCallback.kt | 41 +++++++++++++++++++
.../yggdrasil/PacketTunnelProvider.kt | 14 ++++++-
5 files changed, 58 insertions(+), 3 deletions(-)
create mode 100644 app/src/main/java/eu/neilalexander/yggdrasil/NetworkStateCallback.kt
diff --git a/app/build.gradle b/app/build.gradle
index 3586ae5..3107ca2 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -11,8 +11,8 @@ android {
applicationId "eu.neilalexander.yggdrasil"
minSdkVersion 21
targetSdkVersion 29
- versionCode 9
- versionName "0.1"
+ versionCode 10
+ versionName "0.1-010"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 9a1557c..edec37d 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -3,6 +3,7 @@
package="eu.neilalexander.yggdrasil">
+
{
+ Log.d(TAG, "Connecting...")
+ connect(); START_STICKY
+ }
else -> {
Log.d(TAG, "Starting...")
start(); START_STICKY
@@ -181,6 +186,13 @@ class PacketTunnelProvider: VpnService() {
stopSelf()
}
+ private fun connect() {
+ if (!started.get()) {
+ return
+ }
+ yggdrasil.retryPeersNow()
+ }
+
private fun updater() {
updates@ while (started.get()) {
if ((application as GlobalApplication).needUiUpdates()) {
@@ -260,4 +272,4 @@ class PacketTunnelProvider: VpnService() {
readerStream = null
}
}
-}
\ No newline at end of file
+}