summaryrefslogtreecommitdiffhomepage
path: root/android/src
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-11-17 01:02:06 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-12-10 12:55:06 +0000
commit1eb16a48eea0d7f66883b1eb678400481887370a (patch)
tree94f1b635fa90bf1341258e8626e37afdf6f88b8b /android/src
parenta1e567295c218e48dc2ed46340709cfa460cdafb (diff)
downloadmullvadvpn-1eb16a48eea0d7f66883b1eb678400481887370a.tar.xz
mullvadvpn-1eb16a48eea0d7f66883b1eb678400481887370a.zip
Prevent loopback addresses from being added
Diffstat (limited to 'android/src')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt16
1 files changed, 10 insertions, 6 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt
index 2993bd71c3..4ffdebe0ec 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt
@@ -230,9 +230,11 @@ class CustomDnsAdapter(val customDns: CustomDns) : Adapter<CustomDnsItemHolder>(
if (inetAddressValidator.isValid(addressText)) {
val address = InetAddress.getByName(addressText)
- if (customDns.addDnsServer(address)) {
- cachedCustomDnsServers.add(address)
- added = true
+ if (!address.isLoopbackAddress()) {
+ if (customDns.addDnsServer(address)) {
+ cachedCustomDnsServers.add(address)
+ added = true
+ }
}
}
}
@@ -257,9 +259,11 @@ class CustomDnsAdapter(val customDns: CustomDns) : Adapter<CustomDnsItemHolder>(
val newAddress = InetAddress.getByName(address)
val oldAddress = cachedCustomDnsServers[position]
- if (customDns.replaceDnsServer(oldAddress, newAddress)) {
- cachedCustomDnsServers[position] = newAddress
- replaced = true
+ if (!newAddress.isLoopbackAddress()) {
+ if (customDns.replaceDnsServer(oldAddress, newAddress)) {
+ cachedCustomDnsServers[position] = newAddress
+ replaced = true
+ }
}
}
}