From 72fb0d4e1a0b02f89d70645b5b0dbc74cb035237 Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Fri, 3 Jan 2025 19:17:08 -0600 Subject: sys/[lustrated]: implement NAT64 --- sys/net/options.nix | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'sys/net') diff --git a/sys/net/options.nix b/sys/net/options.nix index a0d29d5..2930567 100644 --- a/sys/net/options.nix +++ b/sys/net/options.nix @@ -87,9 +87,11 @@ with lib; { doubleColon = hextets v6config.prefix + hextets config.suffix < 8; joined = - if v6config.bits != 0 - then "${v6config.prefix}${separator}${config.suffix}" - else config.suffix; + if v6config.bits == 128 + then v6config.prefix + else if v6config.bits == 0 + then config.suffix + else "${v6config.prefix}${separator}${config.suffix}"; in joined; @@ -142,7 +144,7 @@ with lib; { type = nullOr (submodule ({ config, ... }: { options = { bits = mkOption { - type = addCheck (ints.between 0 64) (b: mod b 4 == 0) // { + type = addCheck (ints.between 0 128) (b: mod b 4 == 0) // { description = "IPv6 subnet bits at nibble boundary"; }; }; @@ -164,7 +166,10 @@ with lib; { config = { cidr = "${config.subnet}/${toString config.bits}"; - subnet = "${config.prefix}::"; + subnet = + if config.bits == 128 || length (splitString "::" config.prefix) > 1 + then config.prefix + else "${config.prefix}::"; }; })); }; -- cgit v1.2.3