aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorW. Kosior <koszko@koszko.org>2025-02-17 12:25:32 +0100
committerW. Kosior <koszko@koszko.org>2025-05-26 14:07:29 +0200
commit25bef3d8ca0cfd03f2c4f7846162ca42956831ec (patch)
tree9e4ee83d9c3f246ad45b2c20dd7571aa3cbc4657
parent330fa06c0240101c67bfd974bf6a3e81e8aad2bd (diff)
downloadguix-25bef3d8ca0cfd03f2c4f7846162ca42956831ec.tar.gz
guix-25bef3d8ca0cfd03f2c4f7846162ca42956831ec.zip
services: openvpn: Allow OpenVPN client to dictate route(s) it sets.
* gnu/services/vpn.scm (maybe-ip-mask?): New variable. (serialize-maybe-ip-mask): New variable. (pull-route?): New variable. (serialize-pull-route): New variable. (openvpn-client-configuration)[pull-route?]: New field. (openvpn-client-configuration)[route]: New field. Change-Id: Ief6390e905612420ad249c9ecd80a46caad2e378
-rw-r--r--gnu/services/vpn.scm21
1 files changed, 21 insertions, 0 deletions
diff --git a/gnu/services/vpn.scm b/gnu/services/vpn.scm
index 361e67fe5e..4d9a12608a 100644
--- a/gnu/services/vpn.scm
+++ b/gnu/services/vpn.scm
@@ -13,6 +13,9 @@
;;; Copyright © 2022 Timo Wilken <guix@twilken.net>
;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2024 Richard Sent <richard@freakingpenguin.com>
+;;; Copyright © 2024-2025 Wojtek Kosior <koszko@koszko.org>
+;;; Additions and modifications by Wojtek Kosior are additionally
+;;; dual-licensed under the Creative Commons Zero v1.0.
;;; Copyright © 2025 Carlo Zancanaro <carlo@zancanaro.id.au>
;;;
;;; This file is part of GNU Guix.
@@ -141,6 +144,12 @@
#f)))
(define serialize-ip-mask serialize-string)
+(define (maybe-ip-mask? value)
+ (or (not value) (ip-mask? value)))
+(define (serialize-maybe-ip-mask field-name value)
+ (when value
+ (serialize-ip-mask field-name value)))
+
(define-syntax define-enumerated-field-type
(lambda (x)
(define (id-append ctx . parts)
@@ -176,6 +185,10 @@
(format #t "resolv-retry infinite\n")
#f))
+(define pull-route? boolean?)
+(define (serialize-pull-route field-name value)
+ (format #t "~:[route-nopull~%~;~]" value))
+
(define use-up-down-scripts? boolean?)
(define serialize-use-up-down-scripts empty-serializer)
@@ -430,6 +443,14 @@ would be added to the store and readable by any user.")
(openvpn-remote-list '())
"A list of remote servers to connect to.")
+ (pull-route?
+ (pull-route #t)
+ "Respect IP routing rules and DHCP options sent by the server.")
+
+ (route
+ (maybe-ip-mask #f)
+ "Network routed through the VPN.")
+
(use-up-down-scripts?
(use-up-down-scripts #f)
"Run client.up and client.down scripts included with OpenVPN."))