diff options
author | Marius Bakke <marius@gnu.org> | 2022-12-28 01:02:47 +0100 |
---|---|---|
committer | Marius Bakke <marius@gnu.org> | 2022-12-28 01:02:47 +0100 |
commit | ec0fbb471dfc6f72796da9ebafbb0630daa91267 (patch) | |
tree | 3b42f3d0a6470d85fbb8421179634bb278883e4e /gnu/services/vpn.scm | |
parent | f5ef7d34e4deecb80aff585c108b0a2ab1f33ce4 (diff) | |
parent | 0cb8f7125b19264b01962c1249c3df4c5ce85aa9 (diff) |
Merge branch 'master' into staging
Diffstat (limited to 'gnu/services/vpn.scm')
-rw-r--r-- | gnu/services/vpn.scm | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gnu/services/vpn.scm b/gnu/services/vpn.scm index 7b3bb8903c..4103f89ecf 100644 --- a/gnu/services/vpn.scm +++ b/gnu/services/vpn.scm @@ -10,6 +10,7 @@ ;;; Copyright © 2021 jgart <jgart@dismail.de> ;;; Copyright © 2021 Nathan Dehnel <ncdehnel@gmail.com> ;;; Copyright © 2022 Cameron V Chaparro <cameron@cameronchaparro.com> +;;; Copyright © 2022 Timo Wilken <guix@twilken.net> ;;; ;;; This file is part of GNU Guix. ;;; @@ -61,6 +62,7 @@ wireguard-peer-endpoint wireguard-peer-allowed-ips wireguard-peer-public-key + wireguard-peer-preshared-key wireguard-peer-keep-alive wireguard-configuration @@ -709,6 +711,8 @@ strongSwan."))) (endpoint wireguard-peer-endpoint (default #f)) ;string (public-key wireguard-peer-public-key) ;string + (preshared-key wireguard-peer-preshared-key + (default #f)) ;string (allowed-ips wireguard-peer-allowed-ips) ;list of strings (keep-alive wireguard-peer-keep-alive (default #f))) ;integer @@ -762,10 +766,18 @@ AllowedIPs = ~a (format #f "PersistentKeepalive = ~a\n" keep-alive) "\n")))) + (define (peers->preshared-keys peer keys) + (let ((public-key (wireguard-peer-public-key peer)) + (preshared-key (wireguard-peer-preshared-key peer))) + (if preshared-key + (cons* public-key preshared-key keys) + keys))) + (match-record config <wireguard-configuration> (wireguard interface addresses port private-key peers dns pre-up post-up pre-down post-down table) (let* ((config-file (string-append interface ".conf")) + (peer-keys (fold peers->preshared-keys (list) peers)) (peers (map peer->config peers)) (config (computed-file @@ -780,7 +792,7 @@ AllowedIPs = ~a Address = ~a ~a ~a -PostUp = ~a set %i private-key ~a +PostUp = ~a set %i private-key ~a~{ peer ~a preshared-key ~a~} ~a ~a ~a @@ -800,6 +812,7 @@ PostUp = ~a set %i private-key ~a "\n")) #$(file-append wireguard "/bin/wg") #$private-key + '#$peer-keys #$(if (null? post-up) "" (string-join |