Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions app/src/main/java/com/github/kr328/clash/ProxyActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class ProxyActivity : BaseActivity<ProxyDesign>() {
override suspend fun main() {
val mode = withClash { queryOverride(Clash.OverrideSlot.Session).mode }
val names = withClash { queryProxyGroupNames(uiStore.proxyExcludeNotSelectable) }
val states = List(names.size) { ProxyState("?") }
val unorderedStates = names.indices.associate { names[it] to states[it] }
val mutableStates = MutableList(names.size) { ProxyState("?") }
val unorderedStates = names.indices.associate { names[it] to mutableStates[it] }
val reloadLock = Semaphore(10)

val design = ProxyDesign(this, mode, names, uiStore)
Expand Down Expand Up @@ -59,9 +59,8 @@ class ProxyActivity : BaseActivity<ProxyDesign>() {
val group = reloadLock.withPermit {
withClash { queryProxyGroup(names[it.index], uiStore.proxySort) }
}
val state = states[it.index]

state.now = group.now
val state = mutableStates[it.index].copy(now = group.now)
mutableStates[it.index] = state

design.updateGroup(
it.index,
Expand All @@ -76,7 +75,7 @@ class ProxyActivity : BaseActivity<ProxyDesign>() {
withClash {
patchSelector(names[it.index], it.name)

states[it.index].now = it.name
mutableStates[it.index] = mutableStates[it.index].copy(now = it.name)
}

design.requestRedrawVisible()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package com.github.kr328.clash.design.model

data class ProxyState(var now: String)
data class ProxyState(val now: String)
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ class NetworkObserveModule(service: Service) : Module<Network>(service) {

override fun onLosing(network: Network, maxMsToLive: Int) {
Log.i("NetworkObserve onLosing network=$network")
networkInfos[network]?.losingMs = System.currentTimeMillis() + maxMsToLive
networkInfos.computeIfPresent(network) { _, info ->
info.copy(losingMs = System.currentTimeMillis() + maxMsToLive)
}
notifyDnsChange()

networks.trySend(network)
Expand All @@ -67,7 +69,9 @@ class NetworkObserveModule(service: Service) : Module<Network>(service) {

override fun onLinkPropertiesChanged(network: Network, linkProperties: LinkProperties) {
Log.i("NetworkObserve onLinkPropertiesChanged network=$network $linkProperties")
networkInfos[network]?.dnsList = linkProperties.dnsServers
networkInfos.computeIfPresent(network) { _, info ->
info.copy(dnsList = linkProperties.dnsServers)
}
notifyDnsChange()

networks.trySend(network)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import kotlinx.coroutines.withContext
class TunModule(private val vpn: VpnService) : Module<Unit>(vpn) {
data class TunDevice(
val fd: Int,
var stack: String,
val stack: String,
val gateway: String,
val portal: String,
val dns: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ data class Profile(
val active: Boolean,
val interval: Long,
val upload: Long,
var download: Long,
val download: Long,
val total: Long,
val expire: Long,
val updatedAt: Long,
Expand Down