mirror of
https://github.com/yggdrasil-network/yggdrasil-android.git
synced 2025-04-28 14:15:08 +03:00
Made fast reconnect when network becomes up. (#28)
* Made fast reconnect when network becomes up. * Use `retryPeersNow`
This commit is contained in:
parent
41569a9ee2
commit
c9476a7b00
5 changed files with 58 additions and 3 deletions
|
@ -21,6 +21,7 @@ class PacketTunnelProvider: VpnService() {
|
|||
|
||||
const val ACTION_START = "eu.neilalexander.yggdrasil.PacketTunnelProvider.START"
|
||||
const val ACTION_STOP = "eu.neilalexander.yggdrasil.PacketTunnelProvider.STOP"
|
||||
const val ACTION_CONNECT = "eu.neilalexander.yggdrasil.PacketTunnelProvider.CONNECT"
|
||||
}
|
||||
|
||||
private var yggdrasil = Yggdrasil()
|
||||
|
@ -56,6 +57,10 @@ class PacketTunnelProvider: VpnService() {
|
|||
Log.d(TAG, "Stopping...")
|
||||
stop(); START_NOT_STICKY
|
||||
}
|
||||
ACTION_CONNECT -> {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue