CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: wiz Date: Mon Jan 15 08:29:14 UTC 2024 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Fix typo in wgconfig(8) >From rudolf in PR 57663 To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.8 diff -u src/usr.sbin/wgconfig/wgconfig.8:1.10 src/usr.sbin/wgconfig/wgconfig.8:1.11 --- src/usr.sbin/wgconfig/wgconfig.8:1.10 Wed Aug 26 16:03:42 2020 +++ src/usr.sbin/wgconfig/wgconfig.8 Mon Jan 15 08:29:14 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: wgconfig.8,v 1.10 2020/08/26 16:03:42 riastradh Exp $ +.\" $NetBSD: wgconfig.8,v 1.11 2024/01/15 08:29:14 wiz Exp $ .\" .\" Copyright (C) Ryota Ozaki .\" All rights reserved. @@ -138,7 +138,7 @@ is the peer's base64-encoded public key, .Pp The following options may be specified: .Bl -tag -width abcd -.It Fl Fl preshared-key-file Ns Li \&= Ns Ar filename +.It Fl Fl preshared-key Ns Li \&= Ns Ar filename Set a secret preshared key generated by .Nm wg-keygen .Fl Fl psk .
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: wiz Date: Mon Jan 15 08:29:14 UTC 2024 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Fix typo in wgconfig(8) >From rudolf in PR 57663 To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: oster Date: Sun May 7 16:05:07 UTC 2023 Modified Files: src/usr.sbin/wgconfig: wgconfig.c Log Message: Don't allow "wgconfig add peer ..." to accept invalid options. Addresses PR bin/57392 . To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/wgconfig/wgconfig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: oster Date: Sun May 7 16:05:07 UTC 2023 Modified Files: src/usr.sbin/wgconfig: wgconfig.c Log Message: Don't allow "wgconfig add peer ..." to accept invalid options. Addresses PR bin/57392 . To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/wgconfig/wgconfig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.c diff -u src/usr.sbin/wgconfig/wgconfig.c:1.5 src/usr.sbin/wgconfig/wgconfig.c:1.6 --- src/usr.sbin/wgconfig/wgconfig.c:1.5 Fri Aug 28 17:17:53 2020 +++ src/usr.sbin/wgconfig/wgconfig.c Sun May 7 16:05:07 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: wgconfig.c,v 1.5 2020/08/28 17:17:53 tih Exp $ */ +/* $NetBSD: wgconfig.c,v 1.6 2023/05/07 16:05:07 oster Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: wgconfig.c,v 1.5 2020/08/28 17:17:53 tih Exp $"); +__RCSID("$NetBSD: wgconfig.c,v 1.6 2023/05/07 16:05:07 oster Exp $"); #include @@ -680,14 +680,18 @@ handle_options(int argc, char *argv[], p { while (argc > 0) { + int found = 0; for (size_t i = 0; i < __arraycount(options); i++) { const struct option *opt = [i]; size_t optlen = strlen(opt->option); if (strncmp(argv[0], opt->option, optlen) == 0) { opt->func(argv[0] + optlen, prop_dict); +found = 1; break; } } + if (found == 0) + errx(EXIT_FAILURE, "invalid option: %s", argv[0]); argc -= 1; argv += 1; }
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: tih Date: Fri Aug 28 17:17:53 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.c Log Message: Show the time of the latest handshake properly formatted. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/wgconfig/wgconfig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: tih Date: Fri Aug 28 17:17:53 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.c Log Message: Show the time of the latest handshake properly formatted. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/wgconfig/wgconfig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.c diff -u src/usr.sbin/wgconfig/wgconfig.c:1.4 src/usr.sbin/wgconfig/wgconfig.c:1.5 --- src/usr.sbin/wgconfig/wgconfig.c:1.4 Fri Aug 21 17:51:31 2020 +++ src/usr.sbin/wgconfig/wgconfig.c Fri Aug 28 17:17:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: wgconfig.c,v 1.4 2020/08/21 17:51:31 martin Exp $ */ +/* $NetBSD: wgconfig.c,v 1.5 2020/08/28 17:17:53 tih Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: wgconfig.c,v 1.4 2020/08/21 17:51:31 martin Exp $"); +__RCSID("$NetBSD: wgconfig.c,v 1.5 2020/08/28 17:17:53 tih Exp $"); #include @@ -241,7 +241,7 @@ static void show_peer(prop_dictionary_t peer, const char *prefix, bool show_psk) { prop_object_t prop_obj; - uint64_t sec; + time_t sec; prop_obj = prop_dictionary_get(peer, "public_key"); if (prop_obj == NULL) { @@ -265,10 +265,14 @@ show_peer(prop_dictionary_t peer, const handle_allowed_ips(peer, prefix); - if (prop_dictionary_get_uint64(peer, "last_handshake_time_sec", )) - printf("%slatest-handshake: %"PRIu64"\n", prefix, sec); - else + if (prop_dictionary_get_int64(peer, "last_handshake_time_sec", )) { + if (sec > 0) + printf("%slatest-handshake: %s", prefix, ctime()); + else + printf("%slatest-handshake: (never)\n", prefix); + } else { printf("%slatest-handshake: (none)\n", prefix); + } } static int
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Wed Aug 26 15:49:07 UTC 2020 Modified Files: src/usr.sbin/wgconfig: Makefile Log Message: wgconfig does not need libcrypt. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/wgconfig/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/Makefile diff -u src/usr.sbin/wgconfig/Makefile:1.1 src/usr.sbin/wgconfig/Makefile:1.2 --- src/usr.sbin/wgconfig/Makefile:1.1 Thu Aug 20 21:28:02 2020 +++ src/usr.sbin/wgconfig/Makefile Wed Aug 26 15:49:07 2020 @@ -1,9 +1,9 @@ -# $NetBSD: Makefile,v 1.1 2020/08/20 21:28:02 riastradh Exp $ +# $NetBSD: Makefile,v 1.2 2020/08/26 15:49:07 riastradh Exp $ PROG= wgconfig MAN= wgconfig.8 -DPADD+= ${LIBPROP} ${LIBCRYPT} ${LIBUTIL} -LDADD+= -lprop -lcrypt -lutil +DPADD+= ${LIBPROP} ${LIBUTIL} +LDADD+= -lprop -lutil .include
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Wed Aug 26 15:49:07 UTC 2020 Modified Files: src/usr.sbin/wgconfig: Makefile Log Message: wgconfig does not need libcrypt. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/wgconfig/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: martin Date: Fri Aug 21 17:51:31 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.c Log Message: Use %zu for size_t To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/wgconfig/wgconfig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.c diff -u src/usr.sbin/wgconfig/wgconfig.c:1.3 src/usr.sbin/wgconfig/wgconfig.c:1.4 --- src/usr.sbin/wgconfig/wgconfig.c:1.3 Thu Aug 20 21:34:51 2020 +++ src/usr.sbin/wgconfig/wgconfig.c Fri Aug 21 17:51:31 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: wgconfig.c,v 1.3 2020/08/20 21:34:51 riastradh Exp $ */ +/* $NetBSD: wgconfig.c,v 1.4 2020/08/21 17:51:31 martin Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: wgconfig.c,v 1.3 2020/08/20 21:34:51 riastradh Exp $"); +__RCSID("$NetBSD: wgconfig.c,v 1.4 2020/08/21 17:51:31 martin Exp $"); #include @@ -92,7 +92,7 @@ format_key(prop_object_t key_prop) key = prop_data_value(key_prop); key_len = prop_data_size(key_prop); if (key_len != KEY_LEN) - errx(EXIT_FAILURE, "invalid key len: %lu", key_len); + errx(EXIT_FAILURE, "invalid key len: %zu", key_len); error = b64_ntop(key, key_len, key_b64, KEY_BASE64_LEN + 1); if (error == -1) errx(EXIT_FAILURE, "b64_ntop failed"); @@ -425,7 +425,7 @@ read_key(const char *path, unsigned char n = fread(keyb64buf, 1, KEY_BASE64_LEN, fp); if (n != KEY_BASE64_LEN) - errx(EXIT_FAILURE, "base64 key len is short: %lu", n); + errx(EXIT_FAILURE, "base64 key len is short: %zu", n); keyb64buf[KEY_BASE64_LEN] = '\0'; base64_decode(keyb64buf, keybuf);
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: martin Date: Fri Aug 21 17:51:31 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.c Log Message: Use %zu for size_t To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/wgconfig/wgconfig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: uwe Date: Fri Aug 21 03:44:58 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Mark up a few missed equal signs as literal. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.8 diff -u src/usr.sbin/wgconfig/wgconfig.8:1.8 src/usr.sbin/wgconfig/wgconfig.8:1.9 --- src/usr.sbin/wgconfig/wgconfig.8:1.8 Fri Aug 21 03:13:30 2020 +++ src/usr.sbin/wgconfig/wgconfig.8 Fri Aug 21 03:44:58 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: wgconfig.8,v 1.8 2020/08/21 03:13:30 uwe Exp $ +.\" $NetBSD: wgconfig.8,v 1.9 2020/08/21 03:44:58 uwe Exp $ .\" .\" Copyright (C) Ryota Ozaki .\" All rights reserved. @@ -60,8 +60,8 @@ .Nm .Li wg Ns Ar N\| .Cm "add peer" Ar name Ar pubkey -.Op Fl Fl preshared-key Ns = Ns Ar filename -.Op Fl Fl endpoint Ns = Ns Ar ip Ns Li \&: Ns Ar port +.Op Fl Fl preshared-key Ns Li \&= Ns Ar filename +.Oo Fl Fl endpoint Ns Li \&= Ns Ar ip Ns Li \&: Ns Ar port Oc .Oo .Fl Fl allowed-ips Ns Li \&= Ns Ar ip1 Ns Li \&/ Ns Ar cidr1 Ns .Op Li \&, Ns Ar ip2 Ns Li \&/ Ns Ar cidr2 Ns Li \&, Ns Ar ... @@ -138,7 +138,7 @@ is the peer's base64-encoded public key, .Pp The following options may be specified: .Bl -tag -width abcd -.It Fl Fl preshared-key-file Ns = Ns Ar filename +.It Fl Fl preshared-key-file Ns Li \&= Ns Ar filename Set a secret preshared key generated by .Nm wg-keygen .Fl Fl psk .
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: uwe Date: Fri Aug 21 03:44:58 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Mark up a few missed equal signs as literal. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: uwe Date: Fri Aug 21 03:13:30 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Markup fixes. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.8 diff -u src/usr.sbin/wgconfig/wgconfig.8:1.7 src/usr.sbin/wgconfig/wgconfig.8:1.8 --- src/usr.sbin/wgconfig/wgconfig.8:1.7 Fri Aug 21 02:45:33 2020 +++ src/usr.sbin/wgconfig/wgconfig.8 Fri Aug 21 03:13:30 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: wgconfig.8,v 1.7 2020/08/21 02:45:33 uwe Exp $ +.\" $NetBSD: wgconfig.8,v 1.8 2020/08/21 03:13:30 uwe Exp $ .\" .\" Copyright (C) Ryota Ozaki .\" All rights reserved. @@ -37,30 +37,39 @@ .\" .Sh SYNOPSIS .Nm -.Ar wgN +.Li wg Ns Ar N\| .Op Cm "show all" .\" .Nm -.Ar wgN Cm "show peer" Ar name +.Li wg Ns Ar N\| +.Cm "show peer" Ar name .Op Fl Fl show-preshared-key .\" .Nm -.Ar wgN Cm "show private-key" +.Li wg Ns Ar N\| +.Cm "show private-key" .\" .Nm -.Ar wgN Cm "set private-key" Ar "filename" +.Li wg Ns Ar N\| +.Cm "set private-key" Ar "filename" .\" .Nm -.Ar wgN Cm "set listen-port" Ar port +.Li wg Ns Ar N\| +.Cm "set listen-port" Ar port .\" .Nm -.Ar wgN Cm "add peer" Ar name Ar pubkey +.Li wg Ns Ar N\| +.Cm "add peer" Ar name Ar pubkey .Op Fl Fl preshared-key Ns = Ns Ar filename -.Op Fl Fl endpoint Ns = Ns Ar ip : Ns Ar port -.Op Fl Fl allowed-ips Ns = Ns Ar ip1 Ns / Ns Ar cidr1 Ns Op , Ns Ar ip2 Ns / Ns Ar cidr2 Ns ,... +.Op Fl Fl endpoint Ns = Ns Ar ip Ns Li \&: Ns Ar port +.Oo +.Fl Fl allowed-ips Ns Li \&= Ns Ar ip1 Ns Li \&/ Ns Ar cidr1 Ns +.Op Li \&, Ns Ar ip2 Ns Li \&/ Ns Ar cidr2 Ns Li \&, Ns Ar ... +.Oc .\" .Nm -.Ar wgN Cm "delete peer" Ar name +.Li wg Ns Ar N\| +.Cm "delete peer" Ar name .\" .Sh DESCRIPTION The @@ -94,39 +103,45 @@ also display the secret preshared key th have with the .Fl Fl preshared-key option to -.Nm Ar wgN Cm "add peer" . +.Nm +.Li wg Ns Ar N Cm "add peer" . .It Cm "show private-key" Show the private key that was set with -.Nm Ar wgN Cm "set private-key" . +.Nm +.Li wg Ns Ar N Cm "set private-key" . .It Cm "set private-key" Ar filename Set the private key of -.Ar wgN +.Li wg Ns Ar N\| to the base64-encoded private key in the file at .Ar filename . .It Cm "set listen-port" Ar port Set the UDP port number that -.Ar wgN +.Li wg Ns Ar N\| listens for incoming WireGuard sessions on. This allows a peer to start a new session without having a specific endpoint IP address configured. -.It Cm "add peer" Ar name Ar pubkey Op Ar options... +.It Cm "add peer" Ar name Ar pubkey Op Ar options ... Add a peer. The argument .Ar name may be passed to -.Nm Ar wgN Cm "show peer" +.Nm +.Li wg Ns Ar N Cm "show peer" and -.Nm Ar wgN Cm "delete peer" . +.Nm +.Li wg Ns Ar N Cm "delete peer" . The argument .Ar pubkey is the peer's base64-encoded public key, as printed by -.Nm wg-keygen Fl Fl pub . +.Nm wg-keygen +.Fl Fl pub . .Pp The following options may be specified: .Bl -tag -width abcd .It Fl Fl preshared-key-file Ns = Ns Ar filename Set a secret preshared key generated by -.Nm wg-keygen Fl Fl psk . +.Nm wg-keygen +.Fl Fl psk . .Pp If the preshared key can be arranged in advance on a medium not subject to eavesdropping, then it defends against possible future quantum @@ -135,11 +150,12 @@ WireGuard still uses X25519 key agreemen session keys so that past session transcripts remain secret should one of the endpoints be compromised in the future; the preshared key is an additional measure on top. -.It Fl Fl endpoint Ns = Ns Ar ip : Ns Ar port +.It Fl Fl endpoint Ns Li \&= Ns Ar ip Ns Li \&: Ns Ar port Set the peer's endpoint address outside the tunnel. This is optional for a VPN server if the WireGuard interface is configured to listen on a port number. -.It Fl Fl allowed-ips Ns = Ns Ar ip1 Ns / Ns Ar cidr1 Ns Op , Ns Ar ip2 Ns / Ns Ar cidr2 Ns ,... +.It Fl Fl allowed-ips Ns Li \&= Ns Ar ip1 Ns Li \&/ Ns Ar cidr1 Ns \ +Op Li \&, Ns Ar ip2 Ns Li \&/ Ns Ar cidr2 Ns Li \&, Ns Ar ... Set the IP address ranges that the peer is allowed to select inside the tunnel. .El @@ -147,7 +163,8 @@ tunnel. Delete the peer .Ar name previously added with -.Nm Ar wgN Cm "add peer" Ar name . +.Nm +.Li wg Ns Ar N Cm "add peer" Ar name . .El .\" .Sh EXAMPLES
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: uwe Date: Fri Aug 21 03:13:30 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Markup fixes. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: uwe Date: Fri Aug 21 02:45:34 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Fix synopsis. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.8 diff -u src/usr.sbin/wgconfig/wgconfig.8:1.6 src/usr.sbin/wgconfig/wgconfig.8:1.7 --- src/usr.sbin/wgconfig/wgconfig.8:1.6 Fri Aug 21 01:36:04 2020 +++ src/usr.sbin/wgconfig/wgconfig.8 Fri Aug 21 02:45:33 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: wgconfig.8,v 1.6 2020/08/21 01:36:04 riastradh Exp $ +.\" $NetBSD: wgconfig.8,v 1.7 2020/08/21 02:45:33 uwe Exp $ .\" .\" Copyright (C) Ryota Ozaki .\" All rights reserved. @@ -36,24 +36,31 @@ .Nd configure WireGuard interface parameters .\" .Sh SYNOPSIS -.Nm Ar wgN +.Nm +.Ar wgN .Op Cm "show all" .\" -.Nm Ar wgN Cm "show peer" Ar name +.Nm +.Ar wgN Cm "show peer" Ar name .Op Fl Fl show-preshared-key .\" -.Nm Ar wgN Cm "show private-key" +.Nm +.Ar wgN Cm "show private-key" .\" -.Nm Ar wgN Cm "set private-key" Ar "filename" +.Nm +.Ar wgN Cm "set private-key" Ar "filename" .\" -.Nm Ar wgN Cm "set listen-port" Ar port +.Nm +.Ar wgN Cm "set listen-port" Ar port .\" -.Nm Ar wgN Cm "add peer" Ar name Ar pubkey +.Nm +.Ar wgN Cm "add peer" Ar name Ar pubkey .Op Fl Fl preshared-key Ns = Ns Ar filename .Op Fl Fl endpoint Ns = Ns Ar ip : Ns Ar port .Op Fl Fl allowed-ips Ns = Ns Ar ip1 Ns / Ns Ar cidr1 Ns Op , Ns Ar ip2 Ns / Ns Ar cidr2 Ns ,... .\" -.Nm Ar wgN Cm "delete peer" Ar name +.Nm +.Ar wgN Cm "delete peer" Ar name .\" .Sh DESCRIPTION The
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: uwe Date: Fri Aug 21 02:45:34 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Fix synopsis. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Fri Aug 21 01:36:05 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Fix markup around optional command name. Avoids emboldened brackets. I remain fuzzy on how grouping in roff works, or doesn't work. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.8 diff -u src/usr.sbin/wgconfig/wgconfig.8:1.5 src/usr.sbin/wgconfig/wgconfig.8:1.6 --- src/usr.sbin/wgconfig/wgconfig.8:1.5 Thu Aug 20 23:03:08 2020 +++ src/usr.sbin/wgconfig/wgconfig.8 Fri Aug 21 01:36:04 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: wgconfig.8,v 1.5 2020/08/20 23:03:08 riastradh Exp $ +.\" $NetBSD: wgconfig.8,v 1.6 2020/08/21 01:36:04 riastradh Exp $ .\" .\" Copyright (C) Ryota Ozaki .\" All rights reserved. @@ -36,7 +36,8 @@ .Nd configure WireGuard interface parameters .\" .Sh SYNOPSIS -.Nm Ar wgN Op Cm "show all" +.Nm Ar wgN +.Op Cm "show all" .\" .Nm Ar wgN Cm "show peer" Ar name .Op Fl Fl show-preshared-key
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Fri Aug 21 01:36:05 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Fix markup around optional command name. Avoids emboldened brackets. I remain fuzzy on how grouping in roff works, or doesn't work. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Thu Aug 20 23:03:08 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Add missing description for wgconfig `set private-key' command. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Thu Aug 20 23:03:08 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Add missing description for wgconfig `set private-key' command. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.8 diff -u src/usr.sbin/wgconfig/wgconfig.8:1.4 src/usr.sbin/wgconfig/wgconfig.8:1.5 --- src/usr.sbin/wgconfig/wgconfig.8:1.4 Thu Aug 20 23:01:20 2020 +++ src/usr.sbin/wgconfig/wgconfig.8 Thu Aug 20 23:03:08 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: wgconfig.8,v 1.4 2020/08/20 23:01:20 riastradh Exp $ +.\" $NetBSD: wgconfig.8,v 1.5 2020/08/20 23:03:08 riastradh Exp $ .\" .\" Copyright (C) Ryota Ozaki .\" All rights reserved. @@ -90,6 +90,11 @@ option to .It Cm "show private-key" Show the private key that was set with .Nm Ar wgN Cm "set private-key" . +.It Cm "set private-key" Ar filename +Set the private key of +.Ar wgN +to the base64-encoded private key in the file at +.Ar filename . .It Cm "set listen-port" Ar port Set the UDP port number that .Ar wgN
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Thu Aug 20 23:01:20 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Mark up argument as such and write out wgconfig command correctly. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.8 diff -u src/usr.sbin/wgconfig/wgconfig.8:1.3 src/usr.sbin/wgconfig/wgconfig.8:1.4 --- src/usr.sbin/wgconfig/wgconfig.8:1.3 Thu Aug 20 22:58:06 2020 +++ src/usr.sbin/wgconfig/wgconfig.8 Thu Aug 20 23:01:20 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: wgconfig.8,v 1.3 2020/08/20 22:58:06 riastradh Exp $ +.\" $NetBSD: wgconfig.8,v 1.4 2020/08/20 23:01:20 riastradh Exp $ .\" .\" Copyright (C) Ryota Ozaki .\" All rights reserved. @@ -96,7 +96,7 @@ Set the UDP port number that listens for incoming WireGuard sessions on. This allows a peer to start a new session without having a specific endpoint IP address configured. -.It Cm "add peer" Ar name Ar pubkey Op options... +.It Cm "add peer" Ar name Ar pubkey Op Ar options... Add a peer. The argument .Ar name @@ -134,7 +134,7 @@ tunnel. Delete the peer .Ar name previously added with -.Nm Cm "add peer" Ar name . +.Nm Ar wgN Cm "add peer" Ar name . .El .\" .Sh EXAMPLES
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Thu Aug 20 23:01:20 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Mark up argument as such and write out wgconfig command correctly. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Thu Aug 20 22:58:06 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Tweak markup so the square brackets don't become bold. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.8 diff -u src/usr.sbin/wgconfig/wgconfig.8:1.2 src/usr.sbin/wgconfig/wgconfig.8:1.3 --- src/usr.sbin/wgconfig/wgconfig.8:1.2 Thu Aug 20 21:36:00 2020 +++ src/usr.sbin/wgconfig/wgconfig.8 Thu Aug 20 22:58:06 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: wgconfig.8,v 1.2 2020/08/20 21:36:00 riastradh Exp $ +.\" $NetBSD: wgconfig.8,v 1.3 2020/08/20 22:58:06 riastradh Exp $ .\" .\" Copyright (C) Ryota Ozaki .\" All rights reserved. @@ -38,7 +38,8 @@ .Sh SYNOPSIS .Nm Ar wgN Op Cm "show all" .\" -.Nm Ar wgN Cm "show peer" Ar name Op Fl Fl show-preshared-key +.Nm Ar wgN Cm "show peer" Ar name +.Op Fl Fl show-preshared-key .\" .Nm Ar wgN Cm "show private-key" .\"
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Thu Aug 20 22:58:06 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.8 Log Message: Tweak markup so the square brackets don't become bold. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/wgconfig/wgconfig.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:34:51 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.c Log Message: Update wgconfig(8) for proplib API changes. Also check type tags before conversion. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/wgconfig/wgconfig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:34:51 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.c Log Message: Update wgconfig(8) for proplib API changes. Also check type tags before conversion. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/wgconfig/wgconfig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.c diff -u src/usr.sbin/wgconfig/wgconfig.c:1.2 src/usr.sbin/wgconfig/wgconfig.c:1.3 --- src/usr.sbin/wgconfig/wgconfig.c:1.2 Thu Aug 20 21:31:26 2020 +++ src/usr.sbin/wgconfig/wgconfig.c Thu Aug 20 21:34:51 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: wgconfig.c,v 1.2 2020/08/20 21:31:26 riastradh Exp $ */ +/* $NetBSD: wgconfig.c,v 1.3 2020/08/20 21:34:51 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: wgconfig.c,v 1.2 2020/08/20 21:31:26 riastradh Exp $"); +__RCSID("$NetBSD: wgconfig.c,v 1.3 2020/08/20 21:34:51 riastradh Exp $"); #include @@ -80,15 +80,16 @@ static const char * format_key(prop_object_t key_prop) { int error; - unsigned char *key; + const void *key; size_t key_len; static char key_b64[KEY_BASE64_LEN + 1]; - static const char *none = "(none)"; if (key_prop == NULL) - return none; + return "(none)"; + if (prop_object_type(key_prop) != PROP_TYPE_DATA) + errx(EXIT_FAILURE, "invalid key"); - key = prop_data_data(key_prop); + key = prop_data_value(key_prop); key_len = prop_data_size(key_prop); if (key_len != KEY_LEN) errx(EXIT_FAILURE, "invalid key len: %lu", key_len); @@ -106,10 +107,13 @@ format_endpoint(prop_object_t endpoint_p int error; static char buf[INET6_ADDRSTRLEN]; struct sockaddr_storage sockaddr; - char *addr; + const void *addr; size_t addr_len; - addr = prop_data_data(endpoint_prop); + if (prop_object_type(endpoint_prop) != PROP_TYPE_DATA) + errx(EXIT_FAILURE, "invalid endpoint"); + + addr = prop_data_value(endpoint_prop); addr_len = prop_data_size(endpoint_prop); memcpy(, addr, addr_len); @@ -124,48 +128,68 @@ format_endpoint(prop_object_t endpoint_p static void handle_allowed_ips(prop_dictionary_t peer, const char *prefix) { + prop_object_t prop_obj; prop_array_t allowedips; prop_object_iterator_t it; prop_dictionary_t allowedip; bool first = true; - allowedips = prop_dictionary_get(peer, "allowedips"); - if (allowedips == NULL) + prop_obj = prop_dictionary_get(peer, "allowedips"); + if (prop_obj == NULL) return; + if (prop_object_type(prop_obj) != PROP_TYPE_ARRAY) + errx(EXIT_FAILURE, "invalid allowedips"); + allowedips = prop_obj; printf("%sallowed-ips: ", prefix); it = prop_array_iterator(allowedips); - while ((allowedip = prop_object_iterator_next(it)) != NULL) { - prop_object_t prop_obj; + while ((prop_obj = prop_object_iterator_next(it)) != NULL) { uint8_t family; uint8_t cidr; - char *addr; + const void *addr; + size_t addrlen, famaddrlen; char ntopbuf[INET6_ADDRSTRLEN]; const char *ntopret; - prop_obj = prop_dictionary_get(allowedip, "family"); - if (prop_obj == NULL) { - warnx("allowed-ip without family"); + if (prop_object_type(prop_obj) != PROP_TYPE_DICTIONARY) { + warnx("invalid allowedip"); continue; } + allowedip = prop_obj; - family = (uint8_t)prop_number_unsigned_integer_value(prop_obj); + if (!prop_dictionary_get_uint8(allowedip, "family", )) { + warnx("allowed-ip without family"); + continue; + } - prop_obj = prop_dictionary_get(allowedip, "cidr"); - if (prop_obj == NULL) { + if (!prop_dictionary_get_uint8(allowedip, "cidr", )) { warnx("allowed-ip without cidr"); continue; } - cidr = (uint8_t)prop_number_unsigned_integer_value(prop_obj); - prop_obj = prop_dictionary_get(allowedip, "ip"); - if (prop_obj == NULL) { + if (!prop_dictionary_get_data(allowedip, "ip", + , )) { warnx("allowed-ip without ip"); continue; } - addr = prop_data_data(prop_obj); + switch (family) { + case AF_INET: + famaddrlen = sizeof(struct in_addr); + break; + case AF_INET6: + famaddrlen = sizeof(struct in6_addr); + break; + default: + warnx("unknown family %d", family); + continue; + } + if (addrlen != famaddrlen) { + warnx("allowed-ip bad ip length"); + continue; + } + ntopret = inet_ntop(family, addr, ntopbuf, sizeof(ntopbuf)); if (ntopret == NULL) errx(EXIT_FAILURE, "inet_ntop failed"); @@ -217,6 +241,7 @@ static void show_peer(prop_dictionary_t peer, const char *prefix, bool show_psk) { prop_object_t prop_obj; + uint64_t sec; prop_obj = prop_dictionary_get(peer, "public_key"); if (prop_obj == NULL) { @@ -240,15 +265,10 @@ show_peer(prop_dictionary_t peer, const handle_allowed_ips(peer, prefix); - prop_obj = prop_dictionary_get(peer, "last_handshake_time_sec"); - if (prop_obj != NULL) { - uint64_t sec =
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:31:26 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.c Log Message: Make `wgconfig --help' and variations work. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/wgconfig/wgconfig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/wgconfig/wgconfig.c diff -u src/usr.sbin/wgconfig/wgconfig.c:1.1 src/usr.sbin/wgconfig/wgconfig.c:1.2 --- src/usr.sbin/wgconfig/wgconfig.c:1.1 Thu Aug 20 21:28:02 2020 +++ src/usr.sbin/wgconfig/wgconfig.c Thu Aug 20 21:31:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: wgconfig.c,v 1.1 2020/08/20 21:28:02 riastradh Exp $ */ +/* $NetBSD: wgconfig.c,v 1.2 2020/08/20 21:31:26 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: wgconfig.c,v 1.1 2020/08/20 21:28:02 riastradh Exp $"); +__RCSID("$NetBSD: wgconfig.c,v 1.2 2020/08/20 21:31:26 riastradh Exp $"); #include @@ -729,7 +729,10 @@ main(int argc, char *argv[]) const char *command; const char *target; - if (argc < 2) { + if (argc < 2 || + strcmp(argv[1], "-h") == 0 || + strcmp(argv[1], "-?") == 0 || + strcmp(argv[1], "--help") == 0) { usage(); }
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Thu Aug 20 21:31:26 UTC 2020 Modified Files: src/usr.sbin/wgconfig: wgconfig.c Log Message: Make `wgconfig --help' and variations work. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/wgconfig/wgconfig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.