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 {
4949 }
5050
5151 fun notifyDnsChanged (dns : List <String >) {
52- Bridge .nativeNotifyDnsChanged(dns.joinToString(separator = " ," ))
52+ Bridge .nativeNotifyDnsChanged(dns.toSet(). joinToString(separator = " ," ))
5353 }
5454
5555 fun notifyTimeZoneChanged (name : String , offset : Int ) {
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import android.os.Build
66import androidx.core.content.getSystemService
77import com.github.kr328.clash.common.log.Log
88import com.github.kr328.clash.core.Clash
9- import com.github.kr328.clash.service.util.resolvePrimaryDns
9+ import com.github.kr328.clash.service.util.resolveDns
1010import kotlinx.coroutines.NonCancellable
1111import kotlinx.coroutines.channels.Channel
1212import kotlinx.coroutines.channels.trySendBlocking
@@ -69,8 +69,8 @@ class NetworkObserveModule(service: Service) : Module<Network?>(service) {
6969 }
7070 }
7171
72- val dns = networks.mapNotNull {
73- connectivity.resolvePrimaryDns(it )
72+ val dns = networks.flatMap { network ->
73+ connectivity?.resolveDns(network) ? : emptyList( )
7474 }
7575
7676 Clash .notifyDnsChanged(dns)
Original file line number Diff line number Diff line change @@ -3,8 +3,7 @@ package com.github.kr328.clash.service.util
33import android.net.ConnectivityManager
44import android.net.Network
55
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 ) }
109}
You can’t perform that action at this time.
0 commit comments