From 3935a369b866c67705f3e27944be56b94ea2b245 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sat, 25 Sep 2021 22:22:09 -0600 Subject: ui,tunnel: support DNS search domains wg-quick has supported this for a while, but not the config layer, and not the Go backend, so wire this all up. Requested-by: Alexis Geoffrey Signed-off-by: Jason A. Donenfeld --- .../android/databinding/BindingAdapters.kt | 6 ++++ .../wireguard/android/viewmodel/InterfaceProxy.kt | 2 +- ui/src/main/res/layout/tunnel_detail_fragment.xml | 37 +++++++++++++++++++--- ui/src/main/res/values/strings.xml | 1 + 4 files changed, 40 insertions(+), 6 deletions(-) (limited to 'ui/src/main') diff --git a/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt b/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt index adc42e7b..e5ff4bc9 100644 --- a/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt +++ b/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt @@ -152,6 +152,12 @@ object BindingAdapters { view.text = if (addresses != null) Attribute.join(addresses.map { it?.hostAddress }) else "" } + @JvmStatic + @BindingAdapter("android:text") + fun setStringSetText(view: TextView, strings: Iterable?) { + view.text = if (strings != null) Attribute.join(strings) else "" + } + @JvmStatic fun tryParseInt(s: String?): Int { if (s == null) diff --git a/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.kt b/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.kt index bd2a9831..16af043c 100644 --- a/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.kt +++ b/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.kt @@ -81,7 +81,7 @@ class InterfaceProxy : BaseObservable, Parcelable { constructor(other: Interface) { addresses = Attribute.join(other.addresses) - val dnsServerStrings = other.dnsServers.map { it.hostAddress } + val dnsServerStrings = other.dnsServers.map { it.hostAddress }.plus(other.dnsSearchDomains) dnsServers = Attribute.join(dnsServerStrings) excludedApplications.addAll(other.excludedApplications) includedApplications.addAll(other.includedApplications) diff --git a/ui/src/main/res/layout/tunnel_detail_fragment.xml b/ui/src/main/res/layout/tunnel_detail_fragment.xml index 16bc2ddb..8e34f082 100644 --- a/ui/src/main/res/layout/tunnel_detail_fragment.xml +++ b/ui/src/main/res/layout/tunnel_detail_fragment.xml @@ -167,8 +167,8 @@ android:layout_height="wrap_content" android:contentDescription="@string/dns_servers" android:nextFocusUp="@id/addresses_text" - android:nextFocusDown="@id/listen_port_text" - android:nextFocusForward="@id/listen_port_text" + android:nextFocusDown="@id/dns_search_domains_text" + android:nextFocusForward="@id/dns_search_domains_text" android:onClick="@{ClipboardUtils::copyTextView}" android:text="@{config.interface.dnsServers}" android:visibility="@{config.interface.dnsServers.isEmpty() ? android.view.View.GONE : android.view.View.VISIBLE}" @@ -176,6 +176,33 @@ app:layout_constraintTop_toBottomOf="@+id/dns_servers_label" tools:text="8.8.8.8, 8.8.4.4" /> + + + + + app:layout_constraintTop_toBottomOf="@id/dns_search_domains_text" /> + app:layout_constraintTop_toBottomOf="@id/dns_search_domains_text" /> Disable config exporting Disabling config exporting makes private keys less accessible DNS servers + Search domains Edit Endpoint Error bringing down tunnel: %s -- cgit v1.2.3-59-g8ed1b