aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorW. Kosior <koszko@koszko.org>2025-03-04 17:25:02 +0100
committerW. Kosior <koszko@koszko.org>2025-03-21 13:59:34 +0100
commit49f2f0667bccf4fe224db5d51df513d7eaa0b922 (patch)
treebd3ca0c59d980ae723c4ed9a969ade55f590fc6b
parent6c7cd4143a9bcec5be7e95aff85866243e82ccf6 (diff)
downloadguix-49f2f0667bccf4fe224db5d51df513d7eaa0b922.tar.gz
guix-49f2f0667bccf4fe224db5d51df513d7eaa0b922.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.scm16
1 files changed, 16 insertions, 0 deletions
diff --git a/gnu/services/vpn.scm b/gnu/services/vpn.scm
index d3caafb363..e3e3313902 100644
--- a/gnu/services/vpn.scm
+++ b/gnu/services/vpn.scm
@@ -149,6 +149,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)
@@ -457,6 +469,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."))