diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-08-02 11:40:56 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-08-02 22:13:23 +0000 |
| commit | d5aedd9ea8b2e52b303f9d498189cf9a2c9539ef (patch) | |
| tree | 1a6e6241d7c6782720b05352028984984d28cdb1 | |
| parent | c4839a5a82b9f3fcc82533c1c2c6e44ef9b88e58 (diff) | |
| download | mullvadvpn-d5aedd9ea8b2e52b303f9d498189cf9a2c9539ef.tar.xz mullvadvpn-d5aedd9ea8b2e52b303f9d498189cf9a2c9539ef.zip | |
Show relay out IP address
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt | 27 | ||||
| -rw-r--r-- | android/src/main/res/values/strings.xml | 1 |
2 files changed, 28 insertions, 0 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt index ed47c38a2b..5c47257f86 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt @@ -15,6 +15,7 @@ class LocationInfo(val parentView: View, val context: Context) { private val hostname: TextView = parentView.findViewById(R.id.hostname) private val protocol: TextView = parentView.findViewById(R.id.tunnel_protocol) private val inAddress: TextView = parentView.findViewById(R.id.in_address) + private val outAddress: TextView = parentView.findViewById(R.id.out_address) private var endpoint: Endpoint? = null private var isTunnelInfoVisible = false @@ -24,6 +25,8 @@ class LocationInfo(val parentView: View, val context: Context) { country.text = value?.country ?: "" city.text = value?.city ?: "" hostname.text = value?.hostname ?: "" + + updateOutAddress(value) } var state: TunnelState = TunnelState.Disconnected() @@ -59,11 +62,13 @@ class LocationInfo(val parentView: View, val context: Context) { private fun hideTunnelInfo() { protocol.text = "" inAddress.text = "" + outAddress.text = "" } private fun showTunnelInfo() { protocol.setText(R.string.wireguard) showInAddress(endpoint) + updateOutAddress(location) } private fun showInAddress(endpoint: Endpoint?) { @@ -83,4 +88,26 @@ class LocationInfo(val parentView: View, val context: Context) { inAddress.text = "" } } + + private fun updateOutAddress(location: GeoIpLocation?) { + val addressAvailable = location != null && (location.ipv4 != null || location.ipv6 != null) + + if (isTunnelInfoVisible && addressAvailable) { + val ipv4 = location!!.ipv4 + val ipv6 = location.ipv6 + val ipAddress: String + + if (ipv6 == null) { + ipAddress = ipv4!!.hostAddress + } else if (ipv4 == null) { + ipAddress = ipv6.hostAddress + } else { + ipAddress = "${ipv4.hostAddress} / ${ipv6.hostAddress}" + } + + outAddress.text = context.getString(R.string.out_address, ipAddress) + } else { + outAddress.text = "" + } + } } diff --git a/android/src/main/res/values/strings.xml b/android/src/main/res/values/strings.xml index 80f86bf565..6b605a7bc2 100644 --- a/android/src/main/res/values/strings.xml +++ b/android/src/main/res/values/strings.xml @@ -64,6 +64,7 @@ <string name="tcp">TCP</string> <string name="udp">UDP</string> <string name="in_address">In %1$s:%2$d %3$s</string> + <string name="out_address">Out %1$s</string> <string name="blocking_internet">Blocking internet</string> <string name="auth_failed">Account authentication failed.</string> |
