File tree Expand file tree Collapse file tree 3 files changed +7
-8
lines changed
core/src/main/java/com/github/kr328/clash/core
service/src/main/java/com/github/kr328/clash/service Expand file tree Collapse file tree 3 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ object Clash {
49
49
}
50
50
51
51
fun notifyDnsChanged (dns : List <String >) {
52
- Bridge .nativeNotifyDnsChanged(dns.joinToString(separator = " ," ))
52
+ Bridge .nativeNotifyDnsChanged(dns.toSet(). joinToString(separator = " ," ))
53
53
}
54
54
55
55
fun notifyTimeZoneChanged (name : String , offset : Int ) {
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import android.os.Build
6
6
import androidx.core.content.getSystemService
7
7
import com.github.kr328.clash.common.log.Log
8
8
import com.github.kr328.clash.core.Clash
9
- import com.github.kr328.clash.service.util.resolvePrimaryDns
9
+ import com.github.kr328.clash.service.util.resolveDns
10
10
import kotlinx.coroutines.NonCancellable
11
11
import kotlinx.coroutines.channels.Channel
12
12
import kotlinx.coroutines.channels.trySendBlocking
@@ -69,8 +69,8 @@ class NetworkObserveModule(service: Service) : Module<Network?>(service) {
69
69
}
70
70
}
71
71
72
- val dns = networks.mapNotNull {
73
- connectivity.resolvePrimaryDns(it )
72
+ val dns = networks.flatMap { network ->
73
+ connectivity?.resolveDns(network) ? : emptyList( )
74
74
}
75
75
76
76
Clash .notifyDnsChanged(dns)
Original file line number Diff line number Diff line change @@ -3,8 +3,7 @@ package com.github.kr328.clash.service.util
3
3
import android.net.ConnectivityManager
4
4
import android.net.Network
5
5
6
- fun ConnectivityManager.resolvePrimaryDns (network : Network ? ): String? {
7
- val properties = getLinkProperties(network) ? : return null
8
-
9
- return properties.dnsServers.firstOrNull()?.asSocketAddressText(53 )
6
+ fun ConnectivityManager.resolveDns (network : Network ? ): List <String > {
7
+ val properties = getLinkProperties(network) ? : return listOf ()
8
+ return properties.dnsServers.map { it.asSocketAddressText(53 ) }
10
9
}
You can’t perform that action at this time.
0 commit comments