Skip to contentSkip to conversation

Fix show all endpoints output

PATCH Applied Dmitry Selivanov 2 participants 4 messages Feb 7, 2023 – Feb 8, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix show all endpoints output

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

---
 src/show.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/show.c +2 -2
index 3fd3d9e..13777cf 100644
@@ -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));
Signature · 1 line
2.30.2
#1 lore raw

Thanks.

Can you send this with a Signed-off-by: line like every commit in that repository does, please? Then I'll apply this.

Jason

#2 lore raw

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

---
 src/show.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/show.c +2 -2
index 3fd3d9e..13777cf 100644
@@ -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));
Signature · 1 line
2.30.2