From patchwork Mon Dec 20 23:51:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Dehnel X-Patchwork-Id: 35493 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 14D3F27BBEA; Tue, 21 Dec 2021 01:48:44 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 9910B27BBE9 for ; Tue, 21 Dec 2021 01:48:43 +0000 (GMT) Received: from localhost ([::1]:39148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzUGg-00037s-Ny for patchwork@mira.cbaines.net; Mon, 20 Dec 2021 20:48:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzSSl-0001Le-2F for guix-patches@gnu.org; Mon, 20 Dec 2021 18:53:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:40193) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mzSSk-0000AY-Pq for guix-patches@gnu.org; Mon, 20 Dec 2021 18:53:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mzSSk-0002d4-GT for guix-patches@gnu.org; Mon, 20 Dec 2021 18:53:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#52689] [PATCH] services: wireguard: Add DNS config field. Resent-From: Nathan Dehnel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 20 Dec 2021 23:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 52689 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 52689@debbugs.gnu.org Cc: Nathan Dehnel <5498361+Gooberpatrol66@users.noreply.github.com> X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.164004433610052 (code B ref -1); Mon, 20 Dec 2021 23:53:02 +0000 Received: (at submit) by debbugs.gnu.org; 20 Dec 2021 23:52:16 +0000 Received: from localhost ([127.0.0.1]:51739 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mzSS0-0002c4-7j for submit@debbugs.gnu.org; Mon, 20 Dec 2021 18:52:16 -0500 Received: from lists.gnu.org ([209.51.188.17]:41726) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mzSRv-0002bu-Rq for submit@debbugs.gnu.org; Mon, 20 Dec 2021 18:52:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzSRv-0001Jc-IB for guix-patches@gnu.org; Mon, 20 Dec 2021 18:52:11 -0500 Received: from [2607:f8b0:4864:20::334] (port=44651 helo=mail-ot1-x334.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mzSRt-00007A-Qd for guix-patches@gnu.org; Mon, 20 Dec 2021 18:52:11 -0500 Received: by mail-ot1-x334.google.com with SMTP id u18-20020a9d7212000000b00560cb1dc10bso14490435otj.11 for ; Mon, 20 Dec 2021 15:52:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wpt+A0y/zx4JKAcA1cOGo8XaXGoiB/RnbBOrh8WEHYU=; b=qakjr2mQz9qP2WGtFfsq3o6i6VX54m1RuMefqvlaw4mx12Pg8BlaYi1sesmrEQBS4W 0rl0HkLdSIAlPm8halmBvTNe5dcC4YXWNSk0I9Nsg5/C/aD7N+plxTP2JcUf6+zHpH9O NkDkI1vh7iLgaUbLOKZ7dGtVIR9Qg5LazGNX1hn9HEbD/X1RUEm5d4oV1Iec8OxHPKpe cSt+PSlDqPY0PLiy9zdKegIZ1mG4NuUCzTH++BoRtEySlxmu6OGBfCi28yse97sfC+2v gVO/k7pz7ByawN+HdcQUkD3ZIKcrPsEZMcEfD+2iyfvgx62SAnRT8lNvYZRs67LB7/f6 oLqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wpt+A0y/zx4JKAcA1cOGo8XaXGoiB/RnbBOrh8WEHYU=; b=cyJwaUgTR8MWs/VBH2tdpz1yUAke9bfUS0WhzCVoxvcGZOKFlwx6xBJ/UgB2GNDAXq nUHOexcO7vXXLyUqrcezG+GWuinMixSHMJeZRjMGT1Ay3tRFRuWAbUUj9SzMtkOhQ5MM E+g/gB2OeRk65/fRQY/Ul0xiIycRSJtmVfd+5vmfrvWb8Dd4HKbMmPxHaAya8uw2I1Zo lZLrZ6tDCEZaEBTRkL4KNSYcKdl145ljGaMwETB/X+4FvJN/UZRhjW/R1ibrRZOQI2ai 4prIBk1Wv/Y9YwlsWNqWyLu3IFdoAMs3pGuiQSCJwmRM3UkPUTw6Nch6MWk3cxdFRWzN Olhg== X-Gm-Message-State: AOAM533FlAwFP2pr7w5x9jGctjgcStrErowMD16xrxUStkIt3JbMhnR4 APRb04CNqSC/h0yGWs+Qv+nYuEs/zsQ= X-Google-Smtp-Source: ABdhPJw8zRoK8Z6r+Pa/MPYaS4IZ6AbL/BK98snltyL5hbGEe6PKyXYsessJoCZEC0xkh9Jq/Ftc+Q== X-Received: by 2002:a05:6830:4119:: with SMTP id w25mr407050ott.98.1640044326085; Mon, 20 Dec 2021 15:52:06 -0800 (PST) Received: from guixlaptop.austin.rr.com (cpe-70-123-155-155.austin.res.rr.com. [70.123.155.155]) by smtp.googlemail.com with ESMTPSA id p14sm3284675oou.31.2021.12.20.15.52.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 15:52:05 -0800 (PST) From: Nathan Dehnel Date: Mon, 20 Dec 2021 17:51:53 -0600 Message-Id: <20211220235153.20101-1-ncdehnel@gmail.com> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::334 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::334; envelope-from=ncdehnel@gmail.com; helo=mail-ot1-x334.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Mailman-Approved-At: Mon, 20 Dec 2021 20:48:35 -0500 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches From: Nathan Dehnel <5498361+Gooberpatrol66@users.noreply.github.com> * gnu/services/vpn.scm (wireguard-configuration): Add dns field * doc/guix.texi: Document dns field --- doc/guix.texi | 3 +++ gnu/services/vpn.scm | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index aca88cdada..8e9cd8df18 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -28601,6 +28601,9 @@ The IP addresses to be assigned to the above interface. @item @code{port} (default: @code{51820}) The port on which to listen for incoming connections. +@item @code{dns} (default: @code{#f}) +The DNS server(s) to announce to VPN clients via DHCP. + @item @code{private-key} (default: @code{"/etc/wireguard/private.key"}) The private key file for the interface. It is automatically generated if the file does not exist. diff --git a/gnu/services/vpn.scm b/gnu/services/vpn.scm index 6004e41d8d..1a8f2c8d6a 100644 --- a/gnu/services/vpn.scm +++ b/gnu/services/vpn.scm @@ -67,6 +67,7 @@ (define-module (gnu services vpn) wireguard-configuration-interface wireguard-configuration-addresses wireguard-configuration-port + wireguard-configuration-dns wireguard-configuration-private-key wireguard-configuration-peers @@ -715,7 +716,9 @@ (define-record-type* (private-key wireguard-configuration-private-key ;string (default "/etc/wireguard/private.key")) (peers wireguard-configuration-peers ;list of - (default '()))) + (default '())) + (dns wireguard-configuration-dns ;string + (default #f))) (define (wireguard-configuration-file config) (define (peer->config peer) @@ -739,7 +742,7 @@ (define (peer->config peer) "\n")))) (match-record config - (wireguard interface addresses port private-key peers) + (wireguard interface addresses port private-key peers dns) (let* ((config-file (string-append interface ".conf")) (peers (map peer->config peers)) (config @@ -755,6 +758,7 @@ (define (peer->config peer) Address = ~a PostUp = ~a set %i private-key ~a ~a +~a ~{~a~^~%~}" #$(string-join addresses ",") #$(file-append wireguard "/bin/wg") @@ -762,6 +766,9 @@ (define (peer->config peer) #$(if port (format #f "ListenPort = ~a" port) "") + #$(if dns + (format #f "DNS = ~a" (string-join dns ",")) + "") (list #$@peers))))))))) (file-append config "/" config-file))))