Commit a88565b1 authored by Mygod's avatar Mygod

Filter out link local addresses in IPv6 check

parent 0fa349ea
...@@ -98,8 +98,8 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro ...@@ -98,8 +98,8 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
if (profile.host.parseNumericAddress() == null) { if (profile.host.parseNumericAddress() == null) {
// if fails/null, use IPv4 only, otherwise pick a random IPv4/IPv6 address // if fails/null, use IPv4 only, otherwise pick a random IPv4/IPv6 address
val hasIpv6 = service.getActiveNetwork()?.let { Core.connectivity.getLinkProperties(it) }?.linkAddresses val hasIpv6 = service.getActiveNetwork()?.let { Core.connectivity.getLinkProperties(it) }?.linkAddresses
?.any { it.address is Inet6Address } == true ?.any { it.address.run { this is Inet6Address && !isLinkLocalAddress && !isIPv4CompatibleAddress } }
profile.host = (hosts.resolve(profile.host, if (hasIpv6) null else false).firstOrNull() ?: try { profile.host = (hosts.resolve(profile.host, if (hasIpv6 == true) null else false).firstOrNull() ?: try {
service.resolver(profile.host).firstOrNull() service.resolver(profile.host).firstOrNull()
} catch (_: IOException) { } catch (_: IOException) {
null null
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment