From affd3bad7d9c026d0c1186614489d4752e986651 Mon Sep 17 00:00:00 2001 From: Bernhard Froehlich Date: Mon, 30 Mar 2020 19:18:03 +0000 Subject: [PATCH] net/wireguard: Implement reload command in rc.d script to reload all peer and key settings without restarting the daemon to avoid interface up/down and loosing traffic. This does not work if you change the Address= line in the [Interface] section which needs a real restart. PR: 244862 Submitted by: david@isnic.is --- net/wireguard/Makefile | 2 +- net/wireguard/files/wireguard.in | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/net/wireguard/Makefile b/net/wireguard/Makefile index 475b5081ddf0..3b112a05682a 100644 --- a/net/wireguard/Makefile +++ b/net/wireguard/Makefile @@ -2,7 +2,7 @@ PORTNAME= wireguard PORTVERSION= 1.0.20200319 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= net net-vpn MASTER_SITES= https://git.zx2c4.com/wireguard-tools/snapshot/ DISTNAME= wireguard-tools-${PORTVERSION} diff --git a/net/wireguard/files/wireguard.in b/net/wireguard/files/wireguard.in index 32e08a8ab13c..3440f048dfab 100644 --- a/net/wireguard/files/wireguard.in +++ b/net/wireguard/files/wireguard.in @@ -19,9 +19,11 @@ name=wireguard rcvar=wireguard_enable +extra_commands="reload" start_cmd="${name}_start" stop_cmd="${name}_stop" +reload_cmd="${name}_reload" wireguard_start() { @@ -39,6 +41,18 @@ wireguard_stop() done } +wireguard_reload() +{ + ${wireguard_env:+eval export $wireguard_env} + + for interface in ${wireguard_interfaces}; do + tmpfile="`mktemp`" + %%PREFIX%%/bin/wg-quick strip ${interface} > ${tmpfile} + %%PREFIX%%/bin/wg syncconf ${interface} ${tmpfile} + rm -f ${tmpfile} + done +} + load_rc_config $name : ${wireguard_enable="NO"}