unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#73467] [PATCH] Wireguard: Add autostart? field.
@ 2024-09-25  8:37 Apoorv Singh
  2024-09-26 17:45 ` Sergey Trofimov
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Apoorv Singh @ 2024-09-25  8:37 UTC (permalink / raw)
  To: 73467

[-- Attachment #1: Type: text/plain, Size: 596 bytes --]

The following patch adds a record field autostart? which can be 
used by the user to configure weather the wireguard service should 
start automatically. This field is helpful for people who might 
have limited bandwidth and/or they don't want the wireguard 
service to start at boot which in turn starts the VPN without them 
knowing as it can result in un-desired usage of their bandwidth 
etc.

I personally have limited bandwidth on the VPS I am running the wireguard VPN on and don't want to use it all the time, and this options will fix that, as I sometimes forget that I have it turned on

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Wireguard: Add autostart? field patch. --]
[-- Type: text/x-patch, Size: 2149 bytes --]

From 378f72413697e418061fe359acddf24d6afe1add Mon Sep 17 00:00:00 2001
From: apoorv569 <apoorvs569@gmail.com>
Date: Wed, 25 Sep 2024 09:10:36 +0530
Subject: [PATCH 2/2] Wireguard add autostart? field

---
 gnu/services/vpn.scm | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/gnu/services/vpn.scm b/gnu/services/vpn.scm
index 449909e34d..eee7e78c6d 100644
--- a/gnu/services/vpn.scm
+++ b/gnu/services/vpn.scm
@@ -86,6 +86,7 @@ (define-module (gnu services vpn)
             wireguard-configuration-pre-down
             wireguard-configuration-post-down
             wireguard-configuration-table
+            wireguard-configuration-autostart?
 
             wireguard-service-type))
 
@@ -760,7 +761,9 @@ (define-record-type* <wireguard-configuration>
   (post-down          wireguard-configuration-post-down ;list of strings
                       (default '()))
   (table              wireguard-configuration-table ;string
-                      (default "auto")))
+                      (default "auto"))
+  (autostart?         wireguard-configuration-autostart?
+                      (default #f)))
 
 (define (wireguard-configuration-file config)
   (define (peer->config peer)
@@ -907,7 +910,8 @@ (define (wireguard-shepherd-service config)
   (match-record config <wireguard-configuration>
     (wireguard interface)
     (let ((wg-quick (file-append wireguard "/bin/wg-quick"))
-          (config (wireguard-configuration-file config)))
+          (config (wireguard-configuration-file config))
+          (autostart (wireguard-configuration-autostart? config)))
       (list (shepherd-service
              (requirement '(networking))
              (provision (list (wireguard-service-name interface)))
@@ -916,6 +920,7 @@ (define (wireguard-shepherd-service config)
              (stop #~(lambda _
                        (invoke #$wg-quick "down" #$config)
                        #f))                       ;stopped!
+             (auto-start? autostart)
              (actions (list (shepherd-configuration-action config)))
              (documentation "Run the Wireguard VPN tunnel"))))))
 
-- 
2.46.0


[-- Attachment #3: Type: text/plain, Size: 41 bytes --]

.

-- 
- Apoorv Singh
- Sent from Emacs.

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-10-04  4:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-25  8:37 [bug#73467] [PATCH] Wireguard: Add autostart? field Apoorv Singh
2024-09-26 17:45 ` Sergey Trofimov
2024-10-03 12:53   ` Maxim Cournoyer
2024-10-03  5:30 ` [bug#73467] Wireguard: Add auto-start? field Apoorv Singh
2024-10-03 12:47   ` Maxim Cournoyer
2024-10-03 12:37 ` [bug#73467] [PATCH] Wireguard: Add autostart? field Maxim Cournoyer
2024-10-03 17:43 ` [bug#73467] PATCH V3 for Wireguard: Add auto-start? field Apoorv Singh

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).