aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/showconf.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-05-15 23:24:48 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-05-17 18:13:14 +0200
commit945fae0c7cfa787785833f0335e97c3fd30a79a8 (patch)
tree85fb0751296a712a706fa2b9b1183756c2610154 /src/showconf.c
parentwg: check for proto error on set too (diff)
downloadwireguard-tools-945fae0c7cfa787785833f0335e97c3fd30a79a8.tar.xz
wireguard-tools-945fae0c7cfa787785833f0335e97c3fd30a79a8.zip
wg: support text-based ipc
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/showconf.c')
-rw-r--r--src/showconf.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/showconf.c b/src/showconf.c
index 039abee..2453c86 100644
--- a/src/showconf.c
+++ b/src/showconf.c
@@ -10,7 +10,7 @@
#include <netdb.h>
#include "subcommands.h"
-#include "base64.h"
+#include "encoding.h"
#include "ipc.h"
#include "../uapi.h"
@@ -79,16 +79,16 @@ int showconf_main(int argc, char *argv[])
if (peer->endpoint.addr.sa_family == AF_INET || peer->endpoint.addr.sa_family == AF_INET6) {
char host[4096 + 1];
char service[512 + 1];
- static char buf[sizeof(host) + sizeof(service) + 4];
socklen_t addr_len = 0;
- memset(buf, 0, sizeof(buf));
if (peer->endpoint.addr.sa_family == AF_INET)
addr_len = sizeof(struct sockaddr_in);
else if (peer->endpoint.addr.sa_family == AF_INET6)
addr_len = sizeof(struct sockaddr_in6);
if (!getnameinfo(&peer->endpoint.addr, addr_len, host, sizeof(host), service, sizeof(service), NI_DGRAM | NI_NUMERICSERV | NI_NUMERICHOST)) {
- snprintf(buf, sizeof(buf) - 1, (peer->endpoint.addr.sa_family == AF_INET6 && strchr(host, ':')) ? "[%s]:%s" : "%s:%s", host, service);
- printf("Endpoint = %s\n", buf);
+ if (peer->endpoint.addr.sa_family == AF_INET6 && strchr(host, ':'))
+ printf("Endpoint = [%s]:%s\n", host, service);
+ else
+ printf("Endpoint = %s:%s\n", host, service);
}
}