Skip to content

Commit

Permalink
fix: tunnel tile state
Browse files Browse the repository at this point in the history
  • Loading branch information
zaneschepke committed Feb 15, 2025
1 parent ae665d3 commit f52efd9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ open class BaseTunnel(
tunnelJobs[tun]?.cancelWithMessage("Canceling tunnel jobs for tunnel: ${tun.name}")
tunnelJobs.remove(tun)
}
serviceManager.updateTunnelTile()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit f52efd9

Please sign in to comment.