diff options
author | W. Kosior <koszko@koszko.org> | 2025-02-17 12:25:32 +0100 |
---|---|---|
committer | W. Kosior <koszko@koszko.org> | 2025-02-17 14:19:03 +0100 |
commit | 44b02354682fee584c92603ffcc927e4c2cdbec9 (patch) | |
tree | 10e01f41c411701f144e5b72129fe6ee1121311e | |
parent | 5a4ccb32b5cc2f5551c45bc9f233382cf8cfea19 (diff) | |
download | guix-44b02354682fee584c92603ffcc927e4c2cdbec9.tar.gz guix-44b02354682fee584c92603ffcc927e4c2cdbec9.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.scm | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gnu/services/vpn.scm b/gnu/services/vpn.scm index 71ab5bda1c..97c7e275bd 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. ;;; ;;; This file is part of GNU Guix. ;;; @@ -138,6 +141,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) @@ -173,6 +182,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 pull-dns? boolean?) (define serialize-pull-dns empty-serializer) @@ -421,6 +434,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) + "Apply IP routing rules sent by the server.") + + (route + (maybe-ip-mask #f) + "Network routed through the VPN.") + (pull-dns? (pull-dns #f) "Install resolv.conf entries pulled from the server.")) |