From 3d516a3ca45ea1745467d61fe8c4ba155bf75756 Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Sun, 4 Aug 2024 17:21:29 -0600 Subject: sys/ns: implement SRV records --- sys/ns/rr.nix | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'sys') diff --git a/sys/ns/rr.nix b/sys/ns/rr.nix index f1c6aca..3ccbd55 100644 --- a/sys/ns/rr.nix +++ b/sys/ns/rr.nix @@ -37,12 +37,13 @@ in }); }; - rrConfig = { rrs, type, format }: (map + rrConfig = { rrs, type, format, applyName ? (rr: rr.name) }: (map (rr: { inherit type; - inherit (rr) name ttl; + inherit (rr) ttl; data = format rr; + name = applyName rr; }) rrs); in @@ -168,6 +169,30 @@ in host = nameOption; }; + srv = rrType { + host = nameOption; + + port = mkOption { + type = port; + }; + + priority = mkOption { + type = int; + }; + + proto = mkOption { + type = enum [ "tcp" "udp" ]; + }; + + service = mkOption { + type = str; + }; + + weight = mkOption { + type = int; + }; + }; + txt = rrType { text = mkOption { type = strMatching "[^\"\n\\]*\n?"; @@ -234,6 +259,14 @@ in format = rr: [ rr.priority rr.host ]; }) + (rrConfig { + rrs = config.srv; + type = "SRV"; + + format = rr: [ rr.priority rr.weight rr.port rr.host ]; + applyName = rr: "_${rr.service}._${rr.proto}.${rr.name}"; + }) + (rrConfig { rrs = config.txt; type = "TXT"; -- cgit v1.2.3