aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Wilken2023-05-25 22:00:16 +0200
committerTimo Wilken2023-05-25 23:25:19 +0200
commit3065653545adb60a081bc2cf816919563f30508b (patch)
treea2ad2d940828d178de713c7f09a65961440d4a82
parentd1f7625da1e130f155bdb19ea114dc4db92d6905 (diff)
Bind git daemon to IPv6 address as well
-rw-r--r--tw/system.scm16
-rw-r--r--tw/system/lud.scm3
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")))