From 3065653545adb60a081bc2cf816919563f30508b Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Thu, 25 May 2023 22:00:16 +0200 Subject: Bind git daemon to IPv6 address as well --- tw/system.scm | 16 ++++++++++------ tw/system/lud.scm | 3 ++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tw/system.scm b/tw/system.scm index 4df665f8..9d53af73 100644 --- a/tw/system.scm +++ b/tw/system.scm @@ -44,12 +44,16 @@ ("pi3.twilken.net" . 51022))) (export server-wireguard-address) -(define* (server-wireguard-address host-name #:optional port) - (string-replace-substring - (car ; get the IPv4 address - (wireguard-peer-allowed-ips - (assoc-ref %wireguard-peers host-name))) - "/32" (if port (format #f ":~a" port) ""))) +(define* (server-wireguard-address host-name #:optional port #:key (ipv6? #f)) + (let ((ip (string-replace-substring + ((if ipv6? cadr car) + (wireguard-peer-allowed-ips + (assoc-ref %wireguard-peers host-name))) + (if ipv6? "/128" "/32") ""))) + (cond + ((and port ipv6?) (format #f "[~a]:~a" ip port)) + (port (format #f "~a:~a" ip port)) + (else ip)))) (define-public (server-base-services host-name) (cons* diff --git a/tw/system/lud.scm b/tw/system/lud.scm index 1fa2ca57..17b16795 100644 --- a/tw/system/lud.scm +++ b/tw/system/lud.scm @@ -91,7 +91,8 @@ SSLSessionCacheTimeout 1200 ;; Repos are only published if they contain a `git-daemon-export-ok' file. (service git-daemon-service-type (git-daemon-configuration - (listen (list (server-wireguard-address host-name))) + (listen (list (server-wireguard-address host-name #:ipv6? #t) + (server-wireguard-address host-name))) ;; git://lud.wg/~user/repo.git => /home/user/src/repo.git (user-path "src"))) -- cgit v1.2.3