diff options
author | W. Kosior <koszko@koszko.org> | 2025-03-04 17:25:02 +0100 |
---|---|---|
committer | W. Kosior <koszko@koszko.org> | 2025-05-26 14:07:29 +0200 |
commit | 0ba7acf648e77b33150260d4e0e1db974a4447df (patch) | |
tree | 75fef3fb769c98183c8ffd0f8ec33d3b86fc8491 | |
parent | aa5224cb3e7265cfb42bf739ebec7f9aa6f72d1c (diff) | |
download | guix-0ba7acf648e77b33150260d4e0e1db974a4447df.tar.gz guix-0ba7acf648e77b33150260d4e0e1db974a4447df.zip |
services: openvpn: Allow the client to hardcode DNS servers to use.
* gnu/services/vpn.scm (%ipv4-regex): New variable.
(dhcp-option-dns-list?): New variable.
(serialize-dhcp-option-dns-list): New variable.
(openvpn-client-configuration)[dns]: New field.
Change-Id: Ic4e8184f47bf3f1d5b683c4dc737f6abba8d2f9e
-rw-r--r-- | gnu/services/vpn.scm | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gnu/services/vpn.scm b/gnu/services/vpn.scm index 27644ca970..ae54ba799c 100644 --- a/gnu/services/vpn.scm +++ b/gnu/services/vpn.scm @@ -150,6 +150,18 @@ (when value (serialize-ip-mask field-name value))) +(define %ipv4-regex + (let ((ipv4-octet-group "(25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])")) + (make-regexp (format #f "^(~a\\.){3}~@*~a$" ipv4-octet-group)))) +(define (dhcp-option-dns-list? value) + (and (list? value) + (and-map (lambda (elem) + (and (string? elem) + (regexp-exec %ipv4-regex elem))) + value))) +(define (serialize-dhcp-option-dns-list field-name value) + (format #t "~{dhcp-option DNS ~a~%~}" value)) + (define-syntax define-enumerated-field-type (lambda (x) (define (id-append ctx . parts) @@ -458,6 +470,10 @@ would be added to the store and readable by any user.") (maybe-ip-mask #f) "Network routed through the VPN.") + (dns + (dhcp-option-dns-list '()) + "DNS") + (use-up-down-scripts? (use-up-down-scripts #f) "Run client.up and client.down scripts included with OpenVPN.")) |