mirror of
https://github.com/wgtunnel/android.git
synced 2026-07-03 14:07:49 +02:00
fix: tunnel tile state
This commit is contained in:
+2
-1
@@ -5,6 +5,7 @@ import android.os.Build
|
||||
import android.os.IBinder
|
||||
import android.service.quicksettings.Tile
|
||||
import android.service.quicksettings.TileService
|
||||
import com.zaneschepke.wireguardautotunnel.R
|
||||
import com.zaneschepke.wireguardautotunnel.core.service.ServiceManager
|
||||
import com.zaneschepke.wireguardautotunnel.core.tunnel.TunnelManager
|
||||
import com.zaneschepke.wireguardautotunnel.di.ApplicationScope
|
||||
@@ -53,7 +54,7 @@ class TunnelControlTile : TileService() {
|
||||
fun updateTileState() = applicationScope.launch {
|
||||
if (appDataRepository.tunnels.getAll().isEmpty()) return@launch setUnavailable()
|
||||
with(tunnelManager.activeTunnels().value) {
|
||||
if (isNotEmpty()) return@launch updateTile(if (size == 1) first().tunName else "Multiple", true)
|
||||
if (isNotEmpty()) return@launch updateTile(if (size == 1) first().tunName else getString(R.string.multiple), true)
|
||||
}
|
||||
appDataRepository.getStartTunnelConfig()?.let {
|
||||
updateTile(it.tunName, false)
|
||||
|
||||
@@ -68,6 +68,7 @@ open class BaseTunnel(
|
||||
tunnelJobs[tun]?.cancelWithMessage("Canceling tunnel jobs for tunnel: ${tun.name}")
|
||||
tunnelJobs.remove(tun)
|
||||
}
|
||||
serviceManager.updateTunnelTile()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ data class TunnelConf(
|
||||
val state = MutableStateFlow(TunnelState())
|
||||
|
||||
fun toAmConfig(): org.amnezia.awg.config.Config {
|
||||
return configFromAmQuick(if (amQuick.isNotBlank()) amQuick else wgQuick)
|
||||
return configFromAmQuick(amQuick.ifBlank { wgQuick })
|
||||
}
|
||||
|
||||
fun toWgConfig(): Config {
|
||||
@@ -110,10 +110,10 @@ data class TunnelConf(
|
||||
return TunnelConf(tunName = name, wgQuick = wgQuick, amQuick = amQuick)
|
||||
}
|
||||
|
||||
const val IPV6_ALL_NETWORKS = "::/0"
|
||||
const val IPV4_ALL_NETWORKS = "0.0.0.0/0"
|
||||
private const val IPV6_ALL_NETWORKS = "::/0"
|
||||
private const val IPV4_ALL_NETWORKS = "0.0.0.0/0"
|
||||
val ALL_IPS = listOf(IPV4_ALL_NETWORKS, IPV6_ALL_NETWORKS)
|
||||
val IPV4_PUBLIC_NETWORKS = listOf(
|
||||
private val IPV4_PUBLIC_NETWORKS = listOf(
|
||||
"0.0.0.0/5", "8.0.0.0/7", "11.0.0.0/8", "12.0.0.0/6", "16.0.0.0/4", "32.0.0.0/3",
|
||||
"64.0.0.0/2", "128.0.0.0/3", "160.0.0.0/5", "168.0.0.0/6", "172.0.0.0/12",
|
||||
"172.32.0.0/11", "172.64.0.0/10", "172.128.0.0/9", "173.0.0.0/8", "174.0.0.0/7",
|
||||
|
||||
@@ -212,4 +212,5 @@
|
||||
<string name="start_failed_config">Failed to start tunnel with config error.</string>
|
||||
<string name="unauthorized">Failed to start tunnel, unauthorized.</string>
|
||||
<string name="tunne_start_failed_title">Tunnel failure</string>
|
||||
<string name="multiple">Multiple</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user