[PATCH] wg: Fix show all endpoints output

Dmitry Selivanov dseliv at gmail.com
Wed Feb 8 06:30:16 UTC 2023


Currently "wg show all endpoints" prints interface name only once
while other "show all" commands print it on each line as man says.

Signed-off-by: Dmitry Selivanov <dseliv at gmail.com>
---
 src/show.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/show.c b/src/show.c
index 3fd3d9e..13777cf 100644
--- a/src/show.c
+++ b/src/show.c
@@ -312,9 +312,9 @@ static bool ugly_print(struct wgdevice *device, const char *param, bool with_int
 		else
 			printf("off\n");
 	} else if (!strcmp(param, "endpoints")) {
-		if (with_interface)
-			printf("%s\t", device->name);
 		for_each_wgpeer(device, peer) {
+			if (with_interface)
+				printf("%s\t", device->name);
 			printf("%s\t", key(peer->public_key));
 			if (peer->endpoint.addr.sa_family == AF_INET || peer->endpoint.addr.sa_family == AF_INET6)
 				printf("%s\n", endpoint(&peer->endpoint.addr));
-- 
2.30.2


More information about the WireGuard mailing list