* [PATCH 1/6] wg-quick: linux: add restart command
2020-05-28 18:45 [PATCH] wg-quick: add restart command Garrit Franke
@ 2020-05-28 18:45 ` Garrit Franke
2020-05-28 18:45 ` [PATCH 2/6] wg-quick: add restart man page Garrit Franke
` (5 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Garrit Franke @ 2020-05-28 18:45 UTC (permalink / raw)
To: wireguard; +Cc: Garrit Franke
---
src/wg-quick/linux.bash | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/wg-quick/linux.bash b/src/wg-quick/linux.bash
index e4d4c4f..6f42b7f 100755
--- a/src/wg-quick/linux.bash
+++ b/src/wg-quick/linux.bash
@@ -298,7 +298,7 @@ execute_hooks() {
cmd_usage() {
cat >&2 <<-_EOF
- Usage: $PROGRAM [ up | down | save | strip ] [ CONFIG_FILE | INTERFACE ]
+ Usage: $PROGRAM [ up | down | restart | save | strip ] [ CONFIG_FILE | INTERFACE ]
CONFIG_FILE is a configuration file, whose filename is the interface name
followed by \`.conf'. Otherwise, INTERFACE is an interface name, with
@@ -352,6 +352,11 @@ cmd_down() {
execute_hooks "${POST_DOWN[@]}"
}
+cmd_restart() {
+ cmd_down
+ cmd_up
+}
+
cmd_save() {
[[ " $(wg show interfaces) " == *" $INTERFACE "* ]] || die "\`$INTERFACE' is not a WireGuard interface"
save_config
@@ -373,6 +378,10 @@ elif [[ $# -eq 2 && $1 == down ]]; then
auto_su
parse_options "$2"
cmd_down
+elif [[ $# -eq 2 && $1 == restart ]]; then
+ auto_su
+ parse_options "$2"
+ cmd_restart
elif [[ $# -eq 2 && $1 == save ]]; then
auto_su
parse_options "$2"
--
2.24.3 (Apple Git-128)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 2/6] wg-quick: add restart man page
2020-05-28 18:45 [PATCH] wg-quick: add restart command Garrit Franke
2020-05-28 18:45 ` [PATCH 1/6] wg-quick: linux: " Garrit Franke
@ 2020-05-28 18:45 ` Garrit Franke
2020-05-28 18:45 ` [PATCH 3/6] wg-quick: freebsd: add restart command Garrit Franke
` (4 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Garrit Franke @ 2020-05-28 18:45 UTC (permalink / raw)
To: wireguard; +Cc: Garrit Franke
---
src/man/wg-quick.8 | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/man/wg-quick.8 b/src/man/wg-quick.8
index c693a89..01b99ff 100644
--- a/src/man/wg-quick.8
+++ b/src/man/wg-quick.8
@@ -10,6 +10,8 @@ wg-quick - set up a WireGuard interface simply
|
.I down
|
+.I restart
+|
.I save
|
.I strip
@@ -24,11 +26,11 @@ wg-quick - set up a WireGuard interface simply
This is an extremely simple script for easily bringing up a WireGuard interface,
suitable for a few common use cases.
-Use \fIup\fP to add and set up an interface, and use \fIdown\fP to tear down and remove
-an interface. Running \fIup\fP adds a WireGuard interface, brings up the interface with the
+Use \fIup\fP to add and set up an interface, use \fIdown\fP to tear down and remove
+an interface, and use \fIrestart\fP to restart an interface. Running \fIup\fP adds a WireGuard interface, brings up the interface with the
supplied IP addresses, sets up mtu and routes, and optionally runs pre/post up scripts. Running \fIdown\fP
optionally saves the current configuration, removes the WireGuard interface, and optionally
-runs pre/post down scripts. Running \fIsave\fP saves the configuration of an existing
+runs pre/post down scripts. \fIrestart\fP simply combines the \fIup\fP and \fIdown\fP command. Running \fIsave\fP saves the configuration of an existing
interface without bringing the interface down. Use \fIstrip\fP to output a configuration file
with all
.BR wg-quick (8)-specific
--
2.24.3 (Apple Git-128)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 3/6] wg-quick: freebsd: add restart command
2020-05-28 18:45 [PATCH] wg-quick: add restart command Garrit Franke
2020-05-28 18:45 ` [PATCH 1/6] wg-quick: linux: " Garrit Franke
2020-05-28 18:45 ` [PATCH 2/6] wg-quick: add restart man page Garrit Franke
@ 2020-05-28 18:45 ` Garrit Franke
2020-05-28 18:45 ` [PATCH 4/6] wg-quick: linux: add notice to " Garrit Franke
` (3 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Garrit Franke @ 2020-05-28 18:45 UTC (permalink / raw)
To: wireguard; +Cc: Garrit Franke
---
src/wg-quick/freebsd.bash | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/wg-quick/freebsd.bash b/src/wg-quick/freebsd.bash
index e1ee67f..81c341b 100755
--- a/src/wg-quick/freebsd.bash
+++ b/src/wg-quick/freebsd.bash
@@ -387,7 +387,7 @@ execute_hooks() {
cmd_usage() {
cat >&2 <<-_EOF
- Usage: $PROGRAM [ up | down | save | strip ] [ CONFIG_FILE | INTERFACE ]
+ Usage: $PROGRAM [ up | down | restart | save | strip ] [ CONFIG_FILE | INTERFACE ]
CONFIG_FILE is a configuration file, whose filename is the interface name
followed by \`.conf'. Otherwise, INTERFACE is an interface name, with
@@ -445,6 +445,12 @@ cmd_down() {
execute_hooks "${POST_DOWN[@]}"
}
+cmd_restart() {
+ [[ " $(wg show interfaces) " == *" $INTERFACE "* ]] || die "\`$INTERFACE' is not a WireGuard interface"
+ cmd_down
+ cmd_up
+}
+
cmd_save() {
[[ " $(wg show interfaces) " == *" $INTERFACE "* ]] || die "\`$INTERFACE' is not a WireGuard interface"
save_config
@@ -469,6 +475,10 @@ elif [[ $# -eq 2 && $1 == down ]]; then
auto_su
parse_options "$2"
cmd_down
+elif [[ $# -eq 2 && $1 == restart ]]; then
+ auto_su
+ parse_options "$2"
+ cmd_restart
elif [[ $# -eq 2 && $1 == save ]]; then
auto_su
parse_options "$2"
--
2.24.3 (Apple Git-128)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 4/6] wg-quick: linux: add notice to restart command
2020-05-28 18:45 [PATCH] wg-quick: add restart command Garrit Franke
` (2 preceding siblings ...)
2020-05-28 18:45 ` [PATCH 3/6] wg-quick: freebsd: add restart command Garrit Franke
@ 2020-05-28 18:45 ` Garrit Franke
2020-05-28 18:45 ` [PATCH 5/6] wg-quick: openbsd: add " Garrit Franke
` (2 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Garrit Franke @ 2020-05-28 18:45 UTC (permalink / raw)
To: wireguard; +Cc: Garrit Franke
---
src/wg-quick/linux.bash | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/wg-quick/linux.bash b/src/wg-quick/linux.bash
index 6f42b7f..b888d63 100755
--- a/src/wg-quick/linux.bash
+++ b/src/wg-quick/linux.bash
@@ -353,6 +353,7 @@ cmd_down() {
}
cmd_restart() {
+ [[ " $(wg show interfaces) " == *" $INTERFACE "* ]] || die "\`$INTERFACE' is not a WireGuard interface"
cmd_down
cmd_up
}
--
2.24.3 (Apple Git-128)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 5/6] wg-quick: openbsd: add restart command
2020-05-28 18:45 [PATCH] wg-quick: add restart command Garrit Franke
` (3 preceding siblings ...)
2020-05-28 18:45 ` [PATCH 4/6] wg-quick: linux: add notice to " Garrit Franke
@ 2020-05-28 18:45 ` Garrit Franke
2020-05-28 18:45 ` [PATCH 6/6] wg-quick: darwin: " Garrit Franke
2020-06-17 7:47 ` [PATCH] wg-quick: " Jason A. Donenfeld
6 siblings, 0 replies; 15+ messages in thread
From: Garrit Franke @ 2020-05-28 18:45 UTC (permalink / raw)
To: wireguard; +Cc: Garrit Franke
---
src/wg-quick/openbsd.bash | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/wg-quick/openbsd.bash b/src/wg-quick/openbsd.bash
index ffd1834..5ccba03 100755
--- a/src/wg-quick/openbsd.bash
+++ b/src/wg-quick/openbsd.bash
@@ -390,7 +390,7 @@ execute_hooks() {
cmd_usage() {
cat >&2 <<-_EOF
- Usage: $PROGRAM [ up | down | save | strip ] [ CONFIG_FILE | INTERFACE ]
+ Usage: $PROGRAM [ up | down | restart | save | strip ] [ CONFIG_FILE | INTERFACE ]
CONFIG_FILE is a configuration file, whose filename is the interface name
followed by \`.conf'. Otherwise, INTERFACE is an interface name, with
@@ -448,6 +448,14 @@ cmd_down() {
execute_hooks "${POST_DOWN[@]}"
}
+cmd_restart() {
+ if ! get_real_interface || [[ " $(wg show interfaces) " != *" $REAL_INTERFACE "* ]]; then
+ die "\`$INTERFACE' is not a WireGuard interface"
+ fi
+ cmd_down
+ cmd_up
+}
+
cmd_save() {
if ! get_real_interface || [[ " $(wg show interfaces) " != *" $REAL_INTERFACE "* ]]; then
die "\`$INTERFACE' is not a WireGuard interface"
@@ -471,6 +479,10 @@ elif [[ $# -eq 2 && $1 == down ]]; then
auto_su
parse_options "$2"
cmd_down
+elif [[ $# -eq 2 && $1 == restart ]]; then
+ auto_su
+ parse_options "$2"
+ cmd_restart
elif [[ $# -eq 2 && $1 == save ]]; then
auto_su
parse_options "$2"
--
2.24.3 (Apple Git-128)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 6/6] wg-quick: darwin: add restart command
2020-05-28 18:45 [PATCH] wg-quick: add restart command Garrit Franke
` (4 preceding siblings ...)
2020-05-28 18:45 ` [PATCH 5/6] wg-quick: openbsd: add " Garrit Franke
@ 2020-05-28 18:45 ` Garrit Franke
2020-06-17 7:47 ` [PATCH] wg-quick: " Jason A. Donenfeld
6 siblings, 0 replies; 15+ messages in thread
From: Garrit Franke @ 2020-05-28 18:45 UTC (permalink / raw)
To: wireguard; +Cc: Garrit Franke
---
src/wg-quick/darwin.bash | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/wg-quick/darwin.bash b/src/wg-quick/darwin.bash
index cde1b54..1d32fbe 100755
--- a/src/wg-quick/darwin.bash
+++ b/src/wg-quick/darwin.bash
@@ -418,7 +418,7 @@ execute_hooks() {
cmd_usage() {
cat >&2 <<-_EOF
- Usage: $PROGRAM [ up | down | save | strip ] [ CONFIG_FILE | INTERFACE ]
+ Usage: $PROGRAM [ up | down | restart | save | strip ] [ CONFIG_FILE | INTERFACE ]
CONFIG_FILE is a configuration file, whose filename is the interface name
followed by \`.conf'. Otherwise, INTERFACE is an interface name, with
@@ -478,6 +478,14 @@ cmd_down() {
execute_hooks "${POST_DOWN[@]}"
}
+cmd_restart() {
+ if ! get_real_interface || [[ " $(wg show interfaces) " != *" $REAL_INTERFACE "* ]]; then
+ die "\`$INTERFACE' is not a WireGuard interface"
+ fi
+ cmd_down
+ cmd_up
+}
+
cmd_save() {
if ! get_real_interface || [[ " $(wg show interfaces) " != *" $REAL_INTERFACE "* ]]; then
die "\`$INTERFACE' is not a WireGuard interface"
@@ -502,6 +510,10 @@ elif [[ $# -eq 2 && $1 == down ]]; then
auto_su
parse_options "$2"
cmd_down
+elif [[ $# -eq 2 && $1 == restart ]]; then
+ auto_su
+ parse_options "$2"
+ cmd_restart
elif [[ $# -eq 2 && $1 == save ]]; then
auto_su
parse_options "$2"
--
2.24.3 (Apple Git-128)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] wg-quick: add restart command
2020-05-28 18:45 [PATCH] wg-quick: add restart command Garrit Franke
` (5 preceding siblings ...)
2020-05-28 18:45 ` [PATCH 6/6] wg-quick: darwin: " Garrit Franke
@ 2020-06-17 7:47 ` Jason A. Donenfeld
2020-06-17 8:16 ` Eric Light
6 siblings, 1 reply; 15+ messages in thread
From: Jason A. Donenfeld @ 2020-06-17 7:47 UTC (permalink / raw)
To: Garrit Franke; +Cc: WireGuard mailing list, Luis Ressel
Thanks for the patchset. I'm wondering what the intended use case of
this is. When do you need to set the interface down and then
immediately up again? Most changes to the config file can be reflected
with a more simple:
wg syncconf wg0 <(wg-quick strip wg0)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] wg-quick: add restart command
2020-06-17 7:47 ` [PATCH] wg-quick: " Jason A. Donenfeld
@ 2020-06-17 8:16 ` Eric Light
2020-06-17 8:18 ` Eric Light
2020-06-17 8:19 ` Jason A. Donenfeld
0 siblings, 2 replies; 15+ messages in thread
From: Eric Light @ 2020-06-17 8:16 UTC (permalink / raw)
To: wireguard
As a purely Debian user, the 'service x restart' pattern is far more memorable than the syncconf method. I know personal preference isn't a great reason to add a knob, but Garrit's method is probably going to be much more familiar to many users.
As to _when_ you'd need this... during a config update as you mentioned, but possibly also to easily generate logs for troubleshooting a config I suppose?
E
--------------------------------------------
Q: Why is this email five sentences or less?
A: http://five.sentenc.es
On Wed, 17 Jun 2020, at 19:47, Jason A. Donenfeld wrote:
> Thanks for the patchset. I'm wondering what the intended use case of
> this is. When do you need to set the interface down and then
> immediately up again? Most changes to the config file can be reflected
> with a more simple:
>
> wg syncconf wg0 <(wg-quick strip wg0)
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] wg-quick: add restart command
2020-06-17 8:16 ` Eric Light
@ 2020-06-17 8:18 ` Eric Light
2020-06-17 8:19 ` Jason A. Donenfeld
1 sibling, 0 replies; 15+ messages in thread
From: Eric Light @ 2020-06-17 8:18 UTC (permalink / raw)
To: wireguard
Sorry, failure to complete my thought before I sent:
"wg-quick wg0 restart" fits much more tightly with the familiar "service x restart" pattern.
E
--------------------------------------------
Q: Why is this email five sentences or less?
A: http://five.sentenc.es
On Wed, 17 Jun 2020, at 20:16, Eric Light wrote:
> As a purely Debian user, the 'service x restart' pattern is far more
> memorable than the syncconf method. I know personal preference isn't a
> great reason to add a knob, but Garrit's method is probably going to be
> much more familiar to many users.
>
> As to _when_ you'd need this... during a config update as you
> mentioned, but possibly also to easily generate logs for
> troubleshooting a config I suppose?
>
> E
>
> --------------------------------------------
> Q: Why is this email five sentences or less?
> A: http://five.sentenc.es
>
> On Wed, 17 Jun 2020, at 19:47, Jason A. Donenfeld wrote:
> > Thanks for the patchset. I'm wondering what the intended use case of
> > this is. When do you need to set the interface down and then
> > immediately up again? Most changes to the config file can be reflected
> > with a more simple:
> >
> > wg syncconf wg0 <(wg-quick strip wg0)
> >
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] wg-quick: add restart command
2020-06-17 8:16 ` Eric Light
2020-06-17 8:18 ` Eric Light
@ 2020-06-17 8:19 ` Jason A. Donenfeld
2020-06-17 8:30 ` Eric Light
2020-06-20 7:02 ` Tore Anderson
1 sibling, 2 replies; 15+ messages in thread
From: Jason A. Donenfeld @ 2020-06-17 8:19 UTC (permalink / raw)
To: Eric Light; +Cc: WireGuard mailing list
On Wed, Jun 17, 2020 at 2:17 AM Eric Light <eric@ericlight.com> wrote:
>
> As a purely Debian user, the 'service x restart' pattern is far more memorable than the syncconf method. I know personal preference isn't a great reason to add a knob, but Garrit's method is probably going to be much more familiar to many users.
For users who want service management patterns like that, it'd
certainly be possible to map the wg-quick strip stuff to `systemctl
reload wg-quick@wg0.service`, for that purpose. Maybe that's something
we should consider?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] wg-quick: add restart command
2020-06-17 8:19 ` Jason A. Donenfeld
@ 2020-06-17 8:30 ` Eric Light
2020-06-17 12:25 ` Garrit Franke
2020-06-20 7:02 ` Tore Anderson
1 sibling, 1 reply; 15+ messages in thread
From: Eric Light @ 2020-06-17 8:30 UTC (permalink / raw)
To: Jason A. Donenfeld; +Cc: WireGuard mailing list
Oh hey that sounds like a great way to do it. Seems like it'd be simpler than this patch set as well, which is always good.
E
--------------------------------------------
Q: Why is this email five sentences or less?
A: http://five.sentenc.es
On Wed, 17 Jun 2020, at 20:19, Jason A. Donenfeld wrote:
> On Wed, Jun 17, 2020 at 2:17 AM Eric Light <eric@ericlight.com> wrote:
> >
> > As a purely Debian user, the 'service x restart' pattern is far more memorable than the syncconf method. I know personal preference isn't a great reason to add a knob, but Garrit's method is probably going to be much more familiar to many users.
>
> For users who want service management patterns like that, it'd
> certainly be possible to map the wg-quick strip stuff to `systemctl
> reload wg-quick@wg0.service`, for that purpose. Maybe that's something
> we should consider?
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] wg-quick: add restart command
2020-06-17 8:30 ` Eric Light
@ 2020-06-17 12:25 ` Garrit Franke
0 siblings, 0 replies; 15+ messages in thread
From: Garrit Franke @ 2020-06-17 12:25 UTC (permalink / raw)
To: Eric Light; +Cc: Jason A. Donenfeld, WireGuard mailing list
Thanks for your comments!
I really like the systemctl reload approach. My main intention with
this patchset was to add this feature to wg-quicks arsenal because (at
least for me) it's the most obvious approach. I mainly use `wg-quick
down wg0 && wg0 up wg0`, I think you guys see where I'm coming from.
I haven't dealt with systemd units yet, but I can certainly look into
it and submit a corresponding patch soon.
Am Mi., 17. Juni 2020 um 10:32 Uhr schrieb Eric Light <eric@ericlight.com>:
>
> Oh hey that sounds like a great way to do it. Seems like it'd be simpler than this patch set as well, which is always good.
>
> E
>
> --------------------------------------------
> Q: Why is this email five sentences or less?
> A: http://five.sentenc.es
>
> On Wed, 17 Jun 2020, at 20:19, Jason A. Donenfeld wrote:
> > On Wed, Jun 17, 2020 at 2:17 AM Eric Light <eric@ericlight.com> wrote:
> > >
> > > As a purely Debian user, the 'service x restart' pattern is far more memorable than the syncconf method. I know personal preference isn't a great reason to add a knob, but Garrit's method is probably going to be much more familiar to many users.
> >
> > For users who want service management patterns like that, it'd
> > certainly be possible to map the wg-quick strip stuff to `systemctl
> > reload wg-quick@wg0.service`, for that purpose. Maybe that's something
> > we should consider?
> >
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] wg-quick: add restart command
2020-06-17 8:19 ` Jason A. Donenfeld
2020-06-17 8:30 ` Eric Light
@ 2020-06-20 7:02 ` Tore Anderson
[not found] ` <CAD16O87AEvaP3Y0TKPvrps=MVdzw-34+=rBOmF_c7s=Eu9kSQw@mail.gmail.com>
1 sibling, 1 reply; 15+ messages in thread
From: Tore Anderson @ 2020-06-20 7:02 UTC (permalink / raw)
To: Jason A. Donenfeld, Eric Light; +Cc: WireGuard mailing list
* Jason A. Donenfeld
> On Wed, Jun 17, 2020 at 2:17 AM Eric Light <eric@ericlight.com> wrote:
> > As a purely Debian user, the 'service x restart' pattern is far more memorable than the syncconf method. I know personal preference isn't a great reason to add a knob, but Garrit's method is probably going to be much more familiar to many users.
>
> For users who want service management patterns like that, it'd
> certainly be possible to map the wg-quick strip stuff to `systemctl
> reload wg-quick@wg0.service`, for that purpose. Maybe that's something
> we should consider?
For what it is worth, I posted a patch that does exactly this back in
March:
https://lists.zx2c4.com/pipermail/wireguard/2020-March/005222.html
Reviews or user tests would be greatly appreciated.
You can also pull from https://github.com/toreanderson/wireguard-tools
if you prefer. The commit in question is here:
https://github.com/toreanderson/wireguard-tools/commit/8305a267ec4259206c0de7f1d3f9cfb8522a3223
There is one bugfix in GitHub compared to the patch I posted to the
list in March - using $REAL_INTERFACE instead of $INTERFACE in wg-
quick/openbsd.bash. I can post the updated patch to the list as well if
you want, just let me know.
Tore
^ permalink raw reply [flat|nested] 15+ messages in thread