From 00defd0a73e0cda6950f9a37766683a8c8d676e9 Mon Sep 17 00:00:00 2001 From: "opencode.siil.arti.ee" Date: Fri, 20 Nov 2026 04:44:28 +0000 Subject: [PATCH 01/10] fix: use configured tunnel nameserver before DNS autodetection --- .../org/xapek/andiodine/IodineVpnService.java | 128 +++++++++++------- src/main/res/values-de/strings.xml | 3 +- src/main/res/values-nl/strings.xml | 3 +- src/main/res/values/strings.xml | 3 +- 4 files changed, 88 insertions(+), 49 deletions(-) diff --git a/src/main/java/org/xapek/andiodine/IodineVpnService.java b/src/main/java/org/xapek/andiodine/IodineVpnService.java index 454f68a..1515f7d 100644 --- a/src/main/java/org/xapek/andiodine/IodineVpnService.java +++ b/src/main/java/org/xapek/andiodine/IodineVpnService.java @@ -1,6 +1,5 @@ package org.xapek.andiodine; -import android.annotation.TargetApi; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -8,10 +7,10 @@ import android.content.IntentFilter; import android.net.ConnectivityManager; import android.net.LinkProperties; import android.net.Network; -import android.net.NetworkInfo; +import android.net.NetworkCapabilities; import android.net.VpnService; -import android.os.Build; import android.os.ParcelFileDescriptor; +import android.text.TextUtils; import android.util.Log; import org.xapek.andiodine.config.ConfigDatabase; @@ -21,6 +20,7 @@ import java.io.IOException; import java.net.Inet4Address; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.ArrayList; import java.util.List; public class IodineVpnService extends VpnService implements Runnable { @@ -212,19 +212,34 @@ public class IodineVpnService extends VpnService implements Runnable { } } - private Network getActiveNetwork() { - ConnectivityManager cm = - (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); - NetworkInfo defaultNetworkInfo = cm.getActiveNetworkInfo(); - for (Network n : cm.getAllNetworks()) { - NetworkInfo info = cm.getNetworkInfo(n); - if (info.getType() == defaultNetworkInfo.getType() && - info.getSubtype() == defaultNetworkInfo.getSubtype() && - info.isConnected()) { - return n; + /** + * Networks whose DNS servers may be usable to reach the iodine server, + * with the active network first. + *

+ * The old implementation matched the active network by type/subtype using + * the deprecated {@link android.net.NetworkInfo} API. That misses networks + * when a VPN is active, and only looked at a single network. Older devices + * and IPv6-only carriers may expose no IPv4 DNS server on the default + * network at all, so we also inspect the other connected networks. + */ + private List getNetworksForDnsDetection(ConnectivityManager cm) { + List networks = new ArrayList<>(); + Network active = cm.getActiveNetwork(); + if (active != null) { + networks.add(active); + } + Network[] all = cm.getAllNetworks(); + for (Network n : all) { + if (n.equals(active)) { + continue; + } + NetworkCapabilities capabilities = cm.getNetworkCapabilities(n); + if (capabilities != null + && capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)) { + networks.add(n); } } - return null; + return networks; } @Override @@ -233,42 +248,63 @@ public class IodineVpnService extends VpnService implements Runnable { Log.d(TAG, "VPN Thread enter"); setStatus(ACTION_STATUS_CONNECT, mConfiguration.getId(), null); - String tunnelNameserver = ""; - - ConnectivityManager cm = - (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); - Network activeNetwork = getActiveNetwork(); - if (activeNetwork == null) { - String errorMessage = getString(R.string.vpnservice_error_no_active_network); - setStatus(ACTION_STATUS_ERROR, mConfiguration.getId(), errorMessage); - Log.e(TAG, "No active network. Aborting..."); - return; + // An explicitly configured tunnel nameserver always wins. It is the + // documented escape hatch when the network does not announce a + // usable IPv4 resolver (IPv6-only mobile networks, private DNS, + // another VPN being active, ...). Checking it after auto-detection + // made that option useless exactly when it was needed. + String tunnelNameserver = mConfiguration.getTunnelNameserver(); + if (tunnelNameserver == null) { + tunnelNameserver = ""; } - LinkProperties prop = cm.getLinkProperties(activeNetwork); - assert prop != null; - List servers = prop.getDnsServers(); - for (InetAddress candidate : servers) { - Log.d(TAG, "detected dns server: " + candidate); - if (candidate instanceof Inet4Address) { - tunnelNameserver = candidate.getHostAddress(); - break; + tunnelNameserver = tunnelNameserver.trim(); + + if (tunnelNameserver.isEmpty()) { + ConnectivityManager cm = + (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); + List networks = getNetworksForDnsDetection(cm); + if (networks.isEmpty()) { + String errorMessage = getString(R.string.vpnservice_error_no_active_network); + setStatus(ACTION_STATUS_ERROR, mConfiguration.getId(), errorMessage); + Log.e(TAG, "No active network. Aborting..."); + return; + } + + List detectedServers = new ArrayList<>(); + for (Network network : networks) { + LinkProperties prop = cm.getLinkProperties(network); + if (prop == null) { + continue; + } + for (InetAddress candidate : prop.getDnsServers()) { + String address = candidate.getHostAddress(); + Log.d(TAG, "detected dns server: " + address + " on " + network); + if (!detectedServers.contains(address)) { + detectedServers.add(address); + } + // The native iodine client only supports IPv4 + // nameservers, so skip IPv6 ones here. + if (tunnelNameserver.isEmpty() && candidate instanceof Inet4Address) { + tunnelNameserver = address; + } + } + } + + if (tunnelNameserver.isEmpty()) { + String detected = detectedServers.isEmpty() + ? getString(R.string.vpnservice_error_dns_none) + : TextUtils.join(", ", detectedServers); + String errorMessage = getString(R.string.vpnservice_error_dns_detect_failed, detected); + setStatus(ACTION_STATUS_ERROR, mConfiguration.getId(), errorMessage); + Log.e(TAG, "No valid IPv4 name servers detected (found: " + detected + + "). Aborting..."); + return; } } - - assert tunnelNameserver != null; - if (tunnelNameserver.isEmpty()) { - String errorMessage = getString(R.string.vpnservice_error_dns_detect_failed); - setStatus(ACTION_STATUS_ERROR, mConfiguration.getId(), errorMessage); - Log.e(TAG, "No valid IPv4 name servers detected. Aborting..."); - return; - } Log.d(TAG, "using name server: " + tunnelNameserver); - if (!"".equals(mConfiguration.getTunnelNameserver())) { - tunnelNameserver = mConfiguration.getTunnelNameserver(); - } - String password = ""; - if (!"".equals(mConfiguration.getPassword())) { - password = mConfiguration.getPassword(); + String password = mConfiguration.getPassword(); + if (password == null) { + password = ""; } int ret = IodineClient.connect(tunnelNameserver, mConfiguration.getTopDomain(), mConfiguration.getRawMode(), diff --git a/src/main/res/values-de/strings.xml b/src/main/res/values-de/strings.xml index 23a5c0c..5b6a9e7 100644 --- a/src/main/res/values-de/strings.xml +++ b/src/main/res/values-de/strings.xml @@ -49,7 +49,8 @@ Handshake fehlgeschlagen Unbekannter Fehler. Kode %d Unbekannter Fehler. Grund: %s - Es wurden keine gültigen IPv4-Nameserver erkannt + Kein IPv4-Nameserver verfügbar (gefunden: %1$s). Trage unter \"Tunnel Nameserver\" einen IPv4-Resolver wie 1.1.1.1 ein. + keine Das Tunnel-Netzwerkgerät konnte nicht erstellt werden Kein aktives Netzwerk Leerlauf diff --git a/src/main/res/values-nl/strings.xml b/src/main/res/values-nl/strings.xml index 22bd3e1..c4a4177 100644 --- a/src/main/res/values-nl/strings.xml +++ b/src/main/res/values-nl/strings.xml @@ -35,7 +35,8 @@ Inactief Het is niet verplicht om dit in the vullen. Alleen de eerste 32 letters zullen worden gebruikt. Indien aangevinkt zal Iodine proberen het publieke IP-adres van de Iodined server direct proberen te bereiken. Indien dat het geval is zal het dataverkeer direct naar de server worden verzonden i.p.v. de DNS relay. - Er zijn geen geldige IPv4 servers gedetecteerd. + Geen IPv4-nameserver beschikbaar (gevonden: %1$s). Stel \"Tunnel Nameserver\" in op een IPv4-resolver zoals 1.1.1.1. + geen Sluit Aangepast DNS request type. Normaal probeert Iodine automatisch het DNS request type met de hoogste bandbreedte te vinden en te gebruiken. Echter blijkt de DNS relay in sommige gevallen limieten op te leggen, waardoor andere DNS types onverwacht meer bandbreedte kunnen dragen. Als dat het geval is kunt u deze optie gebruiken om een ander type te selecteren. Van de meeste bandbreedte naar de minste zijn dit de ondersteunde DNS types: NULL, TXT, SRV, MX, CNAME en A. Het DNS verkeer zal als aanvragen van de subdomeinen onder _topdomain_ worden verzonden. Normaal gesproken is dit uw eigen domein. Gebruik een korte domeinnaam voor een hogere bandbreedte. Indien de gekozen nameserver die van Iodine is, kan elk tomdomein gekozen worden zolang hetzelfde domein op de server en de cliënt gekozen wordt. diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 21f2d8e..0871c1d 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -83,7 +83,8 @@ Handshake failed Unknown Error. Code %d Unknown Error. Reason: %s - No valid IPv4 name servers detected + No IPv4 name server available (found: %1$s). Set \"Tunnel Nameserver\" to an IPv4 resolver such as 1.1.1.1. + none Failed to create tunnel network device No active network Idle -- 2.47.3 From 449a702315b4d7183dfa8525cf442b87f8d7fd31 Mon Sep 17 00:00:00 2001 From: "opencode.siil.arti.ee" Date: Fri, 20 Nov 2026 04:44:28 +0000 Subject: [PATCH 02/10] docs: add debug log view design and plan --- .../plans/2026-11-20-debug-log-view.md | 525 ++++++++++++++++++ .../specs/2026-11-20-debug-log-view-design.md | 187 +++++++ 2 files changed, 712 insertions(+) create mode 100644 docs/superpowers/plans/2026-11-20-debug-log-view.md create mode 100644 docs/superpowers/specs/2026-11-20-debug-log-view-design.md diff --git a/docs/superpowers/plans/2026-11-20-debug-log-view.md b/docs/superpowers/plans/2026-11-20-debug-log-view.md new file mode 100644 index 0000000..83381fb --- /dev/null +++ b/docs/superpowers/plans/2026-11-20-debug-log-view.md @@ -0,0 +1,525 @@ +# Debug Log View Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Add a live debug log view with a post-connect debug toggle and periodic native tunnel statistics, so a connected-but-stalled tunnel can be diagnosed without reconnecting. + +**Architecture:** Extend the existing status fragment with a log buffer and controls, expose a native debug flag through JNI, and emit one compact stats line every 5 seconds from the native tunnel loop through the existing `fprintf` → broadcast path. + +**Tech Stack:** Java 8, Android SDK 35 / minSdk 26, platform widgets, JNI, NDK 27, Gradle 8.7, JUnit 4 for the pure-Java log buffer. + +**Spec:** `docs/superpowers/specs/2026-11-20-debug-log-view-design.md` + +## Global Constraints + +- minSdk 26, compileSdk 35, NDK `27.0.12077973`. +- Java source/target compatibility is 8; use `java.time` and anonymous inner classes consistent with the existing code. +- Debug stats are emitted every 5 seconds, plus once immediately when enabled. +- Log buffer is capped at 500 complete lines. +- No persistence, log files, export/share, logcat capture, per-packet traces, or per-profile verbose setting. +- The tunnel password must never appear in logs. +- `./gradlew build` must pass at the end of every task. +- Native log output must continue to use `fprintf(stderr, ...)` so `common.h` routes it through `android_printf` → `IodineClient.log_callback`. + +## Review Focus + +These are the failure modes most likely to bite a user, beyond what the automated tests cover: + +1. **Toggling Debug mid-tunnel** must not restart, disconnect, or perturb the tunnel; only a volatile logging flag changes. +2. **Rotation and reconnect** must keep the checkbox in sync with the native flag, while a new connection clears the buffer and leaves Debug off. +3. **Copy and Clear at any time**, including with an empty buffer or an open partial line, must not crash or lose the open line unexpectedly. +4. **A stalled tunnel** must keep printing stats while traffic is absent; `last-rx` grows, `tx` keeps increasing, and output continues until the client's 60-second shutdown. +5. **Secrets** must not leak: the copied log may contain the domain/server but never the password. + +Each is verified in the manual checklist in Task 3. This project has no Android +UI or native test harness, so those behaviors are checked on-device; the +pure-logic buffer behaviors are unit-tested in Task 1. + +--- + +## Before Task 1 + +- [ ] Commit the approved spec and this plan: + +```bash +git add docs/superpowers/specs/2026-11-20-debug-log-view-design.md docs/superpowers/plans/2026-11-20-debug-log-view.md +git commit -m "docs: add debug log view design and plan" +``` + +--- + +### Task 1: Timestamped, Capped Log Buffer + +**Files:** +- Modify: `build.gradle` +- Create: `src/main/java/org/xapek/andiodine/LogBuffer.java` +- Create: `src/test/java/org/xapek/andiodine/LogBufferTest.java` + +**Interfaces:** +- Consumes: nothing. +- Produces: + - `public LogBuffer(int maxLines, java.util.function.Supplier timestamp)` + - `public static LogBuffer withLocalTime(int maxLines)` + - `public void append(String chunk)` + - `public String getText()` + - `public void clear()` + - `public int getLineCount()` + +- [ ] **Step 1: Add the JUnit test dependency** + +In `build.gradle`, add a top-level dependencies block after the `android { ... }` block: + +```groovy +dependencies { + testImplementation 'junit:junit:4.13.2' +} +``` + +- [ ] **Step 2: Write the failing LogBuffer test** + +Create `src/test/java/org/xapek/andiodine/LogBufferTest.java`: + +```java +package org.xapek.andiodine; + +import org.junit.Test; + +import java.util.function.Supplier; + +import static org.junit.Assert.assertEquals; + +public class LogBufferTest { + private static final Supplier TS = () -> "12:00:00.000"; + + @Test + public void timestampsCompleteLines() { + LogBuffer buffer = new LogBuffer(10, TS); + buffer.append("hello\n"); + assertEquals("12:00:00.000 hello\n", buffer.getText()); + assertEquals(1, buffer.getLineCount()); + } + + @Test + public void assemblesPartialChunksIntoOneLine() { + LogBuffer buffer = new LogBuffer(10, TS); + buffer.append("Autodetect"); + buffer.append("ing"); + buffer.append(".\n"); + assertEquals("12:00:00.000 Autodetecting.\n", buffer.getText()); + assertEquals(1, buffer.getLineCount()); + } + + @Test + public void splitsMultipleLinesInOneChunk() { + LogBuffer buffer = new LogBuffer(10, TS); + buffer.append("one\ntwo\n"); + assertEquals("12:00:00.000 one\n12:00:00.000 two\n", buffer.getText()); + assertEquals(2, buffer.getLineCount()); + } + + @Test + public void dropsOldestLinesAtCapacity() { + LogBuffer buffer = new LogBuffer(2, TS); + buffer.append("one\n"); + buffer.append("two\n"); + buffer.append("three\n"); + assertEquals("12:00:00.000 two\n12:00:00.000 three\n", buffer.getText()); + assertEquals(2, buffer.getLineCount()); + } + + @Test + public void clearRemovesOpenPartialLine() { + LogBuffer buffer = new LogBuffer(10, TS); + buffer.append("partial"); + buffer.clear(); + assertEquals("", buffer.getText()); + assertEquals(0, buffer.getLineCount()); + } + + @Test + public void openLineAppearsWithoutTrailingNewline() { + LogBuffer buffer = new LogBuffer(10, TS); + buffer.append("partial"); + assertEquals("12:00:00.000 partial", buffer.getText()); + assertEquals(1, buffer.getLineCount()); + } +} +``` + +- [ ] **Step 3: Run the test and verify it fails** + +Run: + +```bash +export ANDROID_HOME=/home/arti/Android/Sdk +./gradlew testDebugUnitTest --tests "org.xapek.andiodine.LogBufferTest" +``` + +Expected: compilation failure, `cannot find symbol: class LogBuffer`. + +- [ ] **Step 4: Implement `LogBuffer`** + +Create `src/main/java/org/xapek/andiodine/LogBuffer.java` with the constructor and factory above, plus: + +- A private `List lines` and a `StringBuilder openLine`. +- `append`: ignore null/empty chunks; on the first character of a line append `timestamp.get() + " "`; add ordinary characters to `openLine`; on `\n`, finalize only if `openLine` has content, then trim oldest lines while `lines.size() > maxLines`. +- `getText`: join every completed line with `"\n"`, each followed by `\n`; append `openLine` without a trailing newline if it has content. +- `clear`: clear both `lines` and `openLine`. +- `getLineCount`: `lines.size()` plus 1 when `openLine` has content. +- `withLocalTime`: use `java.time.LocalTime.now()` and `java.time.format.DateTimeFormatter.ofPattern("HH:mm:ss.SSS")`. +- Reject `maxLines < 1` with `IllegalArgumentException`. + +Do not add Android imports; this class must run in a plain JVM test. + +- [ ] **Step 5: Run the test and verify it passes** + +Run: + +```bash +./gradlew testDebugUnitTest --tests "org.xapek.andiodine.LogBufferTest" +``` + +Expected: `BUILD SUCCESSFUL`, 6 tests passed. + +- [ ] **Step 6: Commit** + +```bash +git add build.gradle src/main/java/org/xapek/andiodine/LogBuffer.java src/test/java/org/xapek/andiodine/LogBufferTest.java +git commit -m "feat: add timestamped capped log buffer" +``` + +--- + +### Task 2: Native Debug Flag, Counters, Stats, and JNI + +**Files:** +- Modify: `jni/iodine/src/client.h` +- Modify: `jni/iodine/src/client.c` +- Modify: `jni/iodine-client.c` +- Modify: `src/main/java/org/xapek/andiodine/IodineClient.java` + +**Interfaces:** +- Consumes: the existing `android_printf` path and native client session. +- Produces: + - `void client_set_debug(int enabled)` + - `int client_get_debug(void)` + - `public static native void IodineClient.setDebug(boolean enabled)` + - `public static native boolean IodineClient.isDebug()` + - Stats lines in the form: + `[stats] elapsed=125s tx=612 rx=608 oos=2 servfail=0 last-rx=1s interval=2 lazy=1 resend=0` + +- [ ] **Step 1: Declare the native debug API** + +In `jni/iodine/src/client.h`, add: + +```c +void client_set_debug(int enabled); +int client_get_debug(void); +``` + +- [ ] **Step 2: Move tunnel counters to file scope and add the debug flag** + +In `jni/iodine/src/client.c`: + +- Add near the other file-scope statics: + +```c +static volatile int debug_stats; +static long debug_tx_queries; +static long packrecv; +static long packrecv_oos; +static long packrecv_servfail; +``` + +- Remove the function-local `static long packrecv`, `packrecv_oos`, and `packrecv_servfail` declarations from `tunnel_dns()`. The existing increments and reads keep working against the file-scope variables. +- In `client_init()`, reset `debug_stats`, `debug_tx_queries`, `packrecv`, `packrecv_oos`, and `packrecv_servfail` to 0. +- In `send_query()`, increment `debug_tx_queries` once per query sent. + +- [ ] **Step 3: Add the getter/setter and stats emitter** + +In `client.c`, add: + +```c +void +client_set_debug(int enabled) +{ + enabled = enabled ? 1 : 0; + if (debug_stats == enabled) + return; + debug_stats = enabled; + fprintf(stderr, "[stats] %s\n", enabled ? "enabled" : "disabled"); +} + +int +client_get_debug(void) +{ + return debug_stats; +} +``` + +In `client_tunnel_cb()`, before the `while` loop, add: + +```c +time_t tunnel_start = time(NULL); +time_t last_stats = 0; +debug_tx_queries = 0; +``` + +Resetting `debug_tx_queries` here makes the stats measure tunnel-phase queries, +not the handshake probes that ran before this loop. + +At the top of the `while` loop, before `select()` is prepared, add: + +```c +if (debug_stats) { + time_t now = time(NULL); + if (last_stats == 0 || now - last_stats >= 5) { + last_stats = now; + fprintf(stderr, + "[stats] elapsed=%lds tx=%ld rx=%ld oos=%ld servfail=%ld " + "last-rx=%lds interval=%d lazy=%d resend=%d\n", + (long)(now - tunnel_start), debug_tx_queries, packrecv, + packrecv_oos, packrecv_servfail, + (long)(now - lastdownstreamtime), selecttimeout, lazymode, + outchunkresent); + } +} +``` + +Use `time(NULL)`; `lastdownstreamtime` is already maintained by the tunnel loop. + +- [ ] **Step 4: Add the JNI methods** + +In `jni/iodine-client.c`, add: + +```c +JNIEXPORT void JNICALL Java_org_xapek_andiodine_IodineClient_setDebug( + JNIEnv *env, jclass klass, jboolean enabled) { + client_set_debug(enabled ? 1 : 0); +} + +JNIEXPORT jboolean JNICALL Java_org_xapek_andiodine_IodineClient_isDebug( + JNIEnv *env, jclass klass) { + return client_get_debug() ? JNI_TRUE : JNI_FALSE; +} +``` + +`client.h` is already included by `jni/iodine-client.c`. + +- [ ] **Step 5: Declare the Java native methods** + +In `src/main/java/org/xapek/andiodine/IodineClient.java`, add next to the other native declarations: + +```java +public static native void setDebug(boolean enabled); + +public static native boolean isDebug(); +``` + +- [ ] **Step 6: Build and verify the JNI symbols** + +Run: + +```bash +export ANDROID_HOME=/home/arti/Android/Sdk +./gradlew assembleDebug +LIB=$(find build -name 'libiodine-client.so' | head -1) +nm -D "$LIB" | grep -E 'Java_org_xapek_andiodine_IodineClient_(setDebug|isDebug)' +``` + +Expected: build succeeds and both symbols appear, each on +`Java_org_xapek_andiodine_IodineClient_setDebug` and +`Java_org_xapek_andiodine_IodineClient_isDebug`. + +- [ ] **Step 7: Commit** + +```bash +git add jni/iodine/src/client.h jni/iodine/src/client.c jni/iodine-client.c src/main/java/org/xapek/andiodine/IodineClient.java +git commit -m "feat: add native debug stats flag and JNI hooks" +``` + +--- + +### Task 3: Status Screen Controls and Log Integration + +**Files:** +- Modify: `src/main/res/layout/fragment_status.xml` +- Modify: `src/main/java/org/xapek/andiodine/FragmentStatus.java` +- Modify: `src/main/res/values/strings.xml` +- Modify: `src/main/res/values-de/strings.xml` +- Modify: `src/main/res/values-nl/strings.xml` + +**Interfaces:** +- Consumes: + - `LogBuffer.withLocalTime(500)`, `append`, `getText`, `clear` + - `IodineClient.setDebug(boolean)`, `IodineClient.isDebug()` +- Produces: the user-visible debug view; no later tasks depend on it. + +- [ ] **Step 1: Add the strings** + +In `src/main/res/values/strings.xml`: + +```xml +Debug +Auto-scroll +Copy +Clear +Log copied +``` + +Add German equivalents to `values-de/strings.xml`: +`Debug`, `Autom. scrollen`, `Kopieren`, `Leeren`, `Log kopiert`. + +Add Dutch equivalents to `values-nl/strings.xml`: +`Debug`, `Automatisch scrollen`, `Kopiëren`, `Wissen`, `Log gekopieerd`. + +- [ ] **Step 2: Add the controls to the layout** + +In `fragment_status.xml`, keep the existing `status_message` `TextView`, then insert +two horizontal rows before the inner `LinearLayout` that contains the +`ScrollView` and Close button: + +```xml + + + + + + + + + +