[PATCH] wireguard-tools: allow generating private_key

Adrian Schmutzler mail at adrianschmutzler.de
Fri Jan 8 07:09:32 EST 2021


Hi,

> -----Original Message-----
> From: openwrt-devel [mailto:openwrt-devel-bounces at lists.openwrt.org]
> On Behalf Of Leonardo Mörlein
> Sent: Freitag, 8. Januar 2021 02:25
> To: openwrt-devel at lists.openwrt.org
> Cc: Leonardo Mörlein <me at irrelefant.net>
> Subject: [PATCH] wireguard-tools: allow generating private_key
> 
> When the uci configuration is created automatically during a very early stage,
> where no entropy daemon is set up, generating the key directly is not an
> option. Therefore we allow to set the private_key to "generate"
> and generate the private key directly before the interface is taken up.

Please bump PKG_RELEASE.

Best

Adrian

> 
> Signed-off-by: Leonardo Mörlein <me at irrelefant.net>
> ---
>  package/network/utils/wireguard-tools/files/wireguard.sh | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/package/network/utils/wireguard-tools/files/wireguard.sh
> b/package/network/utils/wireguard-tools/files/wireguard.sh
> index 63261aea71..d874c4b5e6 100644
> --- a/package/network/utils/wireguard-tools/files/wireguard.sh
> +++ b/package/network/utils/wireguard-tools/files/wireguard.sh
> @@ -121,6 +121,11 @@ proto_wireguard_setup() {
>  		ip link set mtu "${mtu}" dev "${config}"
>  	fi
> 
> +	if [ "$private_key" == "generate" ]; then
> +		private_key=`"${WG}" genkey`
> +		uci -q set network."$config".private_key="$private_key" &&
> uci -q commit network
> +	fi
> +
>  	proto_init_update "${config}" 1
> 
>  	umask 077
> --
> 2.30.0
> 
> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openpgp-digital-signature.asc
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.openwrt.org/pipermail/openwrt-devel/attachments/20210108/ae3eb5b1/attachment.sig>


More information about the openwrt-devel mailing list