about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorVladimír Čunát <v@cunat.cz>2022-01-11 12:55:47 +0100
committerVladimír Čunát <v@cunat.cz>2022-01-11 12:55:47 +0100
commitddc24ff270ced1254ee0183f221082945f8bb157 (patch)
tree1befc94d347d8b6b1ee128df0c0dfd5f10174d74 /nixos
parentfd0784859b65cc334e52f3df82d71470ab012b3b (diff)
parent180213a0aca0f783fed14e0e71e558693d4cbd0b (diff)
Merge #153610: nixos/kresd: fix IPv6 scope syntax
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/networking/kresd.nix9
1 files changed, 5 insertions, 4 deletions
diff --git a/nixos/modules/services/networking/kresd.nix b/nixos/modules/services/networking/kresd.nix
index 3a36ac7e6670e..16011573f8bbe 100644
--- a/nixos/modules/services/networking/kresd.nix
+++ b/nixos/modules/services/networking/kresd.nix
@@ -7,15 +7,16 @@ let
 
   # Convert systemd-style address specification to kresd config line(s).
   # On Nix level we don't attempt to precisely validate the address specifications.
+  # The optional IPv6 scope spec comes *after* port, perhaps surprisingly.
   mkListen = kind: addr: let
-    al_v4 = builtins.match "([0-9.]+):([0-9]+)" addr;
-    al_v6 = builtins.match "\\[(.+)]:([0-9]+)" addr;
+    al_v4 = builtins.match "([0-9.]+):([0-9]+)()" addr;
+    al_v6 = builtins.match "\\[(.+)]:([0-9]+)(%.*|$)" addr;
     al_portOnly = builtins.match "([0-9]+)" addr;
     al = findFirst (a: a != null)
       (throw "services.kresd.*: incorrect address specification '${addr}'")
       [ al_v4 al_v6 al_portOnly ];
-    port = last al;
-    addrSpec = if al_portOnly == null then "'${head al}'" else "{'::', '0.0.0.0'}";
+    port = elemAt al 1;
+    addrSpec = if al_portOnly == null then "'${head al}${elemAt al 2}'" else "{'::', '0.0.0.0'}";
     in # freebind is set for compatibility with earlier kresd services;
        # it could be configurable, for example.
       ''