merge socket to master and fix httpdns cache has default

This commit is contained in:
zhongchao
2022-03-24 20:21:15 +08:00
parent ab9e9aa716
commit d041028308
2 changed files with 3 additions and 3 deletions

View File

@@ -118,7 +118,7 @@ internal class HttpDnsHelper(private val builder: MogoHttpDnsConfig) : Handler.C
return defaultUrl ?: host return defaultUrl ?: host
} }
override fun getHttpDnsCachedAddress(type: Int, _host: String): String? { override fun getHttpDnsCachedAddress(type: Int, _host: String): String {
val host = _host.toLowerCase(Locale.getDefault()) val host = _host.toLowerCase(Locale.getDefault())
httpDnsCache?.let { httpDnsCache?.let {
val currentLoc = builder.getCurrentLocation()?.getCurrentLocation() val currentLoc = builder.getCurrentLocation()?.getCurrentLocation()
@@ -140,7 +140,7 @@ internal class HttpDnsHelper(private val builder: MogoHttpDnsConfig) : Handler.C
} }
} }
val default = defaultUrl ?: host val default = defaultUrl ?: host
return addressMap?.get("$type-$host") return addressMap?.get("$type-$host") ?: default
} }
override fun getAllAddress(): Map<String, String>? { override fun getAllAddress(): Map<String, String>? {

View File

@@ -18,7 +18,7 @@ object MogoHttpDnsClient : IMogoHttpDns {
* 先从本地缓存中根据type和host获取ip:port如果本地缓存中没有再通过网络获取 * 先从本地缓存中根据type和host获取ip:port如果本地缓存中没有再通过网络获取
*/ */
fun getHttpDnsAddressUseCacheIfNecessary(type: Int, _host: String): String? { fun getHttpDnsAddressUseCacheIfNecessary(type: Int, _host: String): String? {
return getHttpDnsCachedAddress(type, _host) ?: return getHttpDnsAddress(type, _host) return getHttpDnsCachedAddress(type, _host)
} }
override fun addressChangedListener(addressChangedListener: OnAddressChangedListener) { override fun addressChangedListener(addressChangedListener: OnAddressChangedListener) {