From e3866d75a9b67dc133c4729cd82a36f67ebfe6b3 Mon Sep 17 00:00:00 2001 From: Ari Sosnovsky Date: Wed, 26 Aug 2026 16:31:48 -0400 Subject: [PATCH] better openwrt sub lan control --- bin/lib/cmds.nu | 11 +- configs/fwbook/hypr/xdph.conf | 21 + flake.lock | 577 ++---------------- flake.nix | 6 +- modules/openwrt/ABOUTME.md | 37 +- modules/openwrt/default.nix | 108 +++- modules/openwrt/generator/ABOUTME.md | 27 +- modules/openwrt/generator/src/config.rs | 17 + .../generator/src/generators/dnsmasq.rs | 5 +- .../generator/src/generators/ethers.rs | 3 +- .../generator/src/generators/firewall.rs | 132 ++++ .../openwrt/generator/src/generators/mod.rs | 1 + modules/openwrt/generator/src/main.rs | 3 +- modules/openwrt/generator/src/network.rs | 9 + secrets/glmain.json.age | Bin 5306 -> 5416 bytes 15 files changed, 384 insertions(+), 573 deletions(-) create mode 100644 configs/fwbook/hypr/xdph.conf create mode 100644 modules/openwrt/generator/src/generators/firewall.rs diff --git a/bin/lib/cmds.nu b/bin/lib/cmds.nu index dcbfa52..3192b50 100644 --- a/bin/lib/cmds.nu +++ b/bin/lib/cmds.nu @@ -295,9 +295,16 @@ Report written to ($report_file)" } # Deploy OpenWrt router configuration -export def "skyg openwrt" [router: string = "glmain"] { +export def "skyg openwrt" [ + router: string = "glmain", + --dry-run # Render configs to .tmp/openwrt-/ without touching the router +] { cd $REPO_ROOT - bash -c $"age -d -i ~/.ssh/id_ed25519 secrets/($router).json.age | nix run .#openwrt-($router)" + if $dry_run { + bash -c $"export SKYG_ROUTER=($router); age -d -i ~/.ssh/id_ed25519 secrets/($router).json.age | nix run .#openwrt-($router)-dry-run" + } else { + bash -c $"age -d -i ~/.ssh/id_ed25519 secrets/($router).json.age | nix run .#openwrt-($router)" + } } # Build ISO image diff --git a/configs/fwbook/hypr/xdph.conf b/configs/fwbook/hypr/xdph.conf new file mode 100644 index 0000000..ec4552d --- /dev/null +++ b/configs/fwbook/hypr/xdph.conf @@ -0,0 +1,21 @@ +# ========================= +# xdg-desktop-portal-hyprland (fwbook) +# ========================= +# Read by xdph itself from ~/.config/hypr/xdph.conf (hyprlang format, not Lua), +# so it is not require()'d from hyprland.lua. This directory is symlinked to +# ~/.config/hypr by the skyg hyprland module. +# +# force_shm: skip DMA-BUF buffer negotiation for screencast. xdph fails modifier +# fixation on this machine ("DMA-BUF fixation failed after 2 attempts") and tears +# the stream down; Chromium then reopens a ScreenCast session, which re-shows the +# output picker. Capture already ended up on SHM via the fallback path anyway, so +# image quality is unchanged -- this just avoids the failing negotiation and the +# teardown it causes. +# +# Deliberately NOT setting screencopy:allow_token_by_default -- it would auto-grant +# restore tokens to any app that asks, letting it silently re-capture later. Tick +# "allow restore token" in the picker instead. + +screencopy { + force_shm = true +} diff --git a/flake.lock b/flake.lock index e43da77..b12073d 100644 --- a/flake.lock +++ b/flake.lock @@ -24,22 +24,18 @@ "aquamarine": { "inputs": { "hyprutils": [ - "hyprgrass", "hyprland", "hyprutils" ], "hyprwayland-scanner": [ - "hyprgrass", "hyprland", "hyprwayland-scanner" ], "nixpkgs": [ - "hyprgrass", "hyprland", "nixpkgs" ], "systems": [ - "hyprgrass", "hyprland", "systems" ] @@ -59,39 +55,6 @@ } }, "aquamarine_2": { - "inputs": { - "hyprutils": [ - "hyprland", - "hyprutils" - ], - "hyprwayland-scanner": [ - "hyprland", - "hyprwayland-scanner" - ], - "nixpkgs": [ - "hyprland", - "nixpkgs" - ], - "systems": [ - "hyprland", - "systems" - ] - }, - "locked": { - "lastModified": 1787400831, - "narHash": "sha256-H3MEkFDZf+UH+QrVgW8TdKrssPFltF8fBg/rh0J1zIc=", - "owner": "hyprwm", - "repo": "aquamarine", - "rev": "7ce889cb78b97979b83a4648509fc3ef405c3286", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "aquamarine", - "type": "github" - } - }, - "aquamarine_3": { "inputs": { "hyprutils": [ "hyprlauncher", @@ -447,22 +410,6 @@ "type": "github" } }, - "flake-compat_6": { - "flake": false, - "locked": { - "lastModified": 1767039857, - "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", - "owner": "NixOS", - "repo": "flake-compat", - "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "flake-compat", - "type": "github" - } - }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -732,17 +679,14 @@ "hyprcursor": { "inputs": { "hyprlang": [ - "hyprgrass", "hyprland", "hyprlang" ], "nixpkgs": [ - "hyprgrass", "hyprland", "nixpkgs" ], "systems": [ - "hyprgrass", "hyprland", "systems" ] @@ -761,49 +705,17 @@ "type": "github" } }, - "hyprcursor_2": { - "inputs": { - "hyprlang": [ - "hyprland", - "hyprlang" - ], - "nixpkgs": [ - "hyprland", - "nixpkgs" - ], - "systems": [ - "hyprland", - "systems" - ] - }, - "locked": { - "lastModified": 1786464181, - "narHash": "sha256-2alOMkLjXANh7unkZnYnCF2K2rApZaOLMoQ3o+VX2CY=", - "owner": "hyprwm", - "repo": "hyprcursor", - "rev": "e4ed7c08123df5af460a0a70961380cbfb872f76", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprcursor", - "type": "github" - } - }, "hyprgraphics": { "inputs": { "hyprutils": [ - "hyprgrass", "hyprland", "hyprutils" ], "nixpkgs": [ - "hyprgrass", "hyprland", "nixpkgs" ], "systems": [ - "hyprgrass", "hyprland", "systems" ] @@ -823,35 +735,6 @@ } }, "hyprgraphics_2": { - "inputs": { - "hyprutils": [ - "hyprland", - "hyprutils" - ], - "nixpkgs": [ - "hyprland", - "nixpkgs" - ], - "systems": [ - "hyprland", - "systems" - ] - }, - "locked": { - "lastModified": 1786464367, - "narHash": "sha256-k58p4wbzIXWyRWrW84pP8tD+iaZSSYiiM+fr0Auk4oU=", - "owner": "hyprwm", - "repo": "hyprgraphics", - "rev": "7c895c44e3ca6d28ed68ddd80ec02b02b925e7fc", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprgraphics", - "type": "github" - } - }, - "hyprgraphics_3": { "inputs": { "hyprutils": [ "hyprlauncher", @@ -882,7 +765,9 @@ }, "hyprgrass": { "inputs": { - "hyprland": "hyprland", + "hyprland": [ + "hyprland" + ], "nixpkgs": [ "hyprgrass", "hyprland", @@ -936,38 +821,31 @@ "hyprland-guiutils": { "inputs": { "aquamarine": [ - "hyprgrass", "hyprland", "aquamarine" ], "hyprgraphics": [ - "hyprgrass", "hyprland", "hyprgraphics" ], "hyprlang": [ - "hyprgrass", "hyprland", "hyprlang" ], "hyprtoolkit": "hyprtoolkit", "hyprutils": [ - "hyprgrass", "hyprland", "hyprutils" ], "hyprwayland-scanner": [ - "hyprgrass", "hyprland", "hyprwayland-scanner" ], "nixpkgs": [ - "hyprgrass", "hyprland", "nixpkgs" ], "systems": [ - "hyprgrass", "hyprland", "systems" ] @@ -986,80 +864,7 @@ "type": "github" } }, - "hyprland-guiutils_2": { - "inputs": { - "aquamarine": [ - "hyprland", - "aquamarine" - ], - "hyprgraphics": [ - "hyprland", - "hyprgraphics" - ], - "hyprlang": [ - "hyprland", - "hyprlang" - ], - "hyprtoolkit": "hyprtoolkit_2", - "hyprutils": [ - "hyprland", - "hyprutils" - ], - "hyprwayland-scanner": [ - "hyprland", - "hyprwayland-scanner" - ], - "nixpkgs": [ - "hyprland", - "nixpkgs" - ], - "systems": [ - "hyprland", - "systems" - ] - }, - "locked": { - "lastModified": 1786464504, - "narHash": "sha256-7sHwM86KILQyHDHDuE2SDBlQ2jvZ0EW3hY7sW009/cg=", - "owner": "hyprwm", - "repo": "hyprland-guiutils", - "rev": "4c30cf3097ea963c0e250749ee0c59f8b08816d6", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprland-guiutils", - "type": "github" - } - }, "hyprland-protocols": { - "inputs": { - "nixpkgs": [ - "hyprgrass", - "hyprland", - "nixpkgs" - ], - "systems": [ - "hyprgrass", - "hyprland", - "systems" - ] - }, - "locked": { - "lastModified": 1772460177, - "narHash": "sha256-/6G/MsPvtn7bc4Y32pserBT/Z4SUUdBd4XYJpOEKVR4=", - "owner": "hyprwm", - "repo": "hyprland-protocols", - "rev": "1cb6db5fd6bb8aee419f4457402fa18293ace917", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprland-protocols", - "type": "github" - } - }, - "hyprland-protocols_2": { "inputs": { "nixpkgs": [ "hyprland", @@ -1084,50 +889,17 @@ "type": "github" } }, - "hyprland_2": { - "inputs": { - "aquamarine": "aquamarine_2", - "hyprcursor": "hyprcursor_2", - "hyprgraphics": "hyprgraphics_2", - "hyprland-guiutils": "hyprland-guiutils_2", - "hyprland-protocols": "hyprland-protocols_2", - "hyprlang": "hyprlang_2", - "hyprutils": "hyprutils_2", - "hyprwayland-scanner": "hyprwayland-scanner_2", - "hyprwire": "hyprwire_2", - "nixpkgs": "nixpkgs_7", - "pre-commit-hooks": "pre-commit-hooks_3", - "systems": "systems_4", - "xdph": "xdph_2" - }, - "locked": { - "lastModified": 1787612295, - "narHash": "sha256-K7sUeS1tKTSDu+aQK0ZwCxJCls+JzDj1qeTJRGk+CV8=", - "owner": "hyprwm", - "repo": "Hyprland", - "rev": "0bd11c7a04a63d2785abd53363f09d552175d67d", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "Hyprland", - "type": "github" - } - }, "hyprlang": { "inputs": { "hyprutils": [ - "hyprgrass", "hyprland", "hyprutils" ], "nixpkgs": [ - "hyprgrass", "hyprland", "nixpkgs" ], "systems": [ - "hyprgrass", "hyprland", "systems" ] @@ -1149,15 +921,15 @@ "hyprlang_2": { "inputs": { "hyprutils": [ - "hyprland", + "hyprlauncher", "hyprutils" ], "nixpkgs": [ - "hyprland", + "hyprlauncher", "nixpkgs" ], "systems": [ - "hyprland", + "hyprlauncher", "systems" ] }, @@ -1176,35 +948,6 @@ } }, "hyprlang_3": { - "inputs": { - "hyprutils": [ - "hyprlauncher", - "hyprutils" - ], - "nixpkgs": [ - "hyprlauncher", - "nixpkgs" - ], - "systems": [ - "hyprlauncher", - "systems" - ] - }, - "locked": { - "lastModified": 1786464129, - "narHash": "sha256-339AkTlpMYSIvFuG0rnR+8Yg4/AZKeJalshJavlnKfg=", - "owner": "hyprwm", - "repo": "hyprlang", - "rev": "9508458be316a0d70d37ebed1ab725ccd10411ff", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprlang", - "type": "github" - } - }, - "hyprlang_4": { "inputs": { "hyprutils": [ "hyprlauncher", @@ -1238,15 +981,15 @@ }, "hyprlauncher": { "inputs": { - "aquamarine": "aquamarine_3", - "hyprgraphics": "hyprgraphics_3", - "hyprlang": "hyprlang_3", - "hyprtoolkit": "hyprtoolkit_3", - "hyprutils": "hyprutils_3", - "hyprwayland-scanner": "hyprwayland-scanner_3", - "hyprwire": "hyprwire_3", - "nixpkgs": "nixpkgs_8", - "systems": "systems_5" + "aquamarine": "aquamarine_2", + "hyprgraphics": "hyprgraphics_2", + "hyprlang": "hyprlang_2", + "hyprtoolkit": "hyprtoolkit_2", + "hyprutils": "hyprutils_2", + "hyprwayland-scanner": "hyprwayland-scanner_2", + "hyprwire": "hyprwire_2", + "nixpkgs": "nixpkgs_7", + "systems": "systems_4" }, "locked": { "lastModified": 1786644260, @@ -1265,43 +1008,36 @@ "hyprtoolkit": { "inputs": { "aquamarine": [ - "hyprgrass", "hyprland", "hyprland-guiutils", "aquamarine" ], "hyprgraphics": [ - "hyprgrass", "hyprland", "hyprland-guiutils", "hyprgraphics" ], "hyprlang": [ - "hyprgrass", "hyprland", "hyprland-guiutils", "hyprlang" ], "hyprutils": [ - "hyprgrass", "hyprland", "hyprland-guiutils", "hyprutils" ], "hyprwayland-scanner": [ - "hyprgrass", "hyprland", "hyprland-guiutils", "hyprwayland-scanner" ], "nixpkgs": [ - "hyprgrass", "hyprland", "hyprland-guiutils", "nixpkgs" ], "systems": [ - "hyprgrass", "hyprland", "hyprland-guiutils", "systems" @@ -1322,58 +1058,6 @@ } }, "hyprtoolkit_2": { - "inputs": { - "aquamarine": [ - "hyprland", - "hyprland-guiutils", - "aquamarine" - ], - "hyprgraphics": [ - "hyprland", - "hyprland-guiutils", - "hyprgraphics" - ], - "hyprlang": [ - "hyprland", - "hyprland-guiutils", - "hyprlang" - ], - "hyprutils": [ - "hyprland", - "hyprland-guiutils", - "hyprutils" - ], - "hyprwayland-scanner": [ - "hyprland", - "hyprland-guiutils", - "hyprwayland-scanner" - ], - "nixpkgs": [ - "hyprland", - "hyprland-guiutils", - "nixpkgs" - ], - "systems": [ - "hyprland", - "hyprland-guiutils", - "systems" - ] - }, - "locked": { - "lastModified": 1785930473, - "narHash": "sha256-DitTu625BhEYpZjtjxtGpjrEJwPwW+X/+jJvhSZNSJM=", - "owner": "hyprwm", - "repo": "hyprtoolkit", - "rev": "af515b69dfbe366dc7873aa1475cb2f4db3ebad7", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprtoolkit", - "type": "github" - } - }, - "hyprtoolkit_3": { "inputs": { "aquamarine": [ "hyprlauncher", @@ -1383,7 +1067,7 @@ "hyprlauncher", "hyprgraphics" ], - "hyprlang": "hyprlang_4", + "hyprlang": "hyprlang_3", "hyprutils": [ "hyprlauncher", "hyprutils" @@ -1418,12 +1102,10 @@ "hyprutils": { "inputs": { "nixpkgs": [ - "hyprgrass", "hyprland", "nixpkgs" ], "systems": [ - "hyprgrass", "hyprland", "systems" ] @@ -1443,31 +1125,6 @@ } }, "hyprutils_2": { - "inputs": { - "nixpkgs": [ - "hyprland", - "nixpkgs" - ], - "systems": [ - "hyprland", - "systems" - ] - }, - "locked": { - "lastModified": 1786903207, - "narHash": "sha256-QTwMqLLONRhv9iz6CVeuX6BqQNQCIqI8hL/cPYlR/24=", - "owner": "hyprwm", - "repo": "hyprutils", - "rev": "6cf50415e06dc6bd9f1252f1b745eac6b4a1cc39", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprutils", - "type": "github" - } - }, - "hyprutils_3": { "inputs": { "nixpkgs": [ "hyprlauncher", @@ -1495,12 +1152,10 @@ "hyprwayland-scanner": { "inputs": { "nixpkgs": [ - "hyprgrass", "hyprland", "nixpkgs" ], "systems": [ - "hyprgrass", "hyprland", "systems" ] @@ -1520,31 +1175,6 @@ } }, "hyprwayland-scanner_2": { - "inputs": { - "nixpkgs": [ - "hyprland", - "nixpkgs" - ], - "systems": [ - "hyprland", - "systems" - ] - }, - "locked": { - "lastModified": 1786464033, - "narHash": "sha256-QM8Qe4/L8lpdVN4bgwahmi+jyyc4fisseDMe4afcDxA=", - "owner": "hyprwm", - "repo": "hyprwayland-scanner", - "rev": "62e62c1ca23da17612c6890d4ad2064f575643db", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprwayland-scanner", - "type": "github" - } - }, - "hyprwayland-scanner_3": { "inputs": { "nixpkgs": [ "hyprlauncher", @@ -1572,17 +1202,14 @@ "hyprwire": { "inputs": { "hyprutils": [ - "hyprgrass", "hyprland", "hyprutils" ], "nixpkgs": [ - "hyprgrass", "hyprland", "nixpkgs" ], "systems": [ - "hyprgrass", "hyprland", "systems" ] @@ -1602,35 +1229,6 @@ } }, "hyprwire_2": { - "inputs": { - "hyprutils": [ - "hyprland", - "hyprutils" - ], - "nixpkgs": [ - "hyprland", - "nixpkgs" - ], - "systems": [ - "hyprland", - "systems" - ] - }, - "locked": { - "lastModified": 1786464294, - "narHash": "sha256-ZQsZ2WvBdkboCIyh8LStDPdAIARmxzn0XMNxxoOhjPE=", - "owner": "hyprwm", - "repo": "hyprwire", - "rev": "4ce7cd6b6128c1ac41caf23c58a30a26b327f9dd", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprwire", - "type": "github" - } - }, - "hyprwire_3": { "inputs": { "hyprutils": [ "hyprlauncher", @@ -1738,7 +1336,7 @@ }, "nixos-hardware": { "inputs": { - "nixpkgs": "nixpkgs_9" + "nixpkgs": "nixpkgs_8" }, "locked": { "lastModified": 1786867632, @@ -1817,20 +1415,6 @@ "url": "https://flakehub.com/f/NixOS/nixpkgs/0.1" } }, - "nixpkgs_10": { - "locked": { - "lastModified": 1786711500, - "narHash": "sha256-QvnceIGTBeDvDd9oCn+GvdsnkquliuwbVgpiRH68qaQ=", - "rev": "02e08985a27c65ffd33d434eeb2e660a2e4dc84d", - "revCount": 1011966, - "type": "tarball", - "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2605.1011966%2Brev-02e08985a27c65ffd33d434eeb2e660a2e4dc84d/01a003f1-59bd-7782-b0ed-5cbf8697f61e/source.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://flakehub.com/f/NixOS/nixpkgs/0" - } - }, "nixpkgs_2": { "locked": { "lastModified": 1784160687, @@ -1908,22 +1492,6 @@ } }, "nixpkgs_7": { - "locked": { - "lastModified": 1787360063, - "narHash": "sha256-dt4WdcvsA8/RCe+VZZwqU0X+XMM3wBbGCWA0/sFWzGo=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "2c423e03bbafcff28bfadc6781a4a8257f205cb5", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_8": { "locked": { "lastModified": 1786247143, "narHash": "sha256-8S3Kcxs7D4UtxJxSJZz0m14CGhuW0MxfrIwJxeGWGnQ=", @@ -1939,7 +1507,7 @@ "type": "github" } }, - "nixpkgs_9": { + "nixpkgs_8": { "locked": { "lastModified": 1767892417, "narHash": "sha256-8bW3q88CEg2u4hSP66Vf4lpbLonHz7hqDNBMcCY7E9U=", @@ -1952,6 +1520,20 @@ "url": "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz" } }, + "nixpkgs_9": { + "locked": { + "lastModified": 1786711500, + "narHash": "sha256-QvnceIGTBeDvDd9oCn+GvdsnkquliuwbVgpiRH68qaQ=", + "rev": "02e08985a27c65ffd33d434eeb2e660a2e4dc84d", + "revCount": 1011966, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2605.1011966%2Brev-02e08985a27c65ffd33d434eeb2e660a2e4dc84d/01a003f1-59bd-7782-b0ed-5cbf8697f61e/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/NixOS/nixpkgs/0" + } + }, "noctalia": { "inputs": { "nixpkgs": [ @@ -2044,29 +1626,6 @@ "pre-commit-hooks_2": { "inputs": { "flake-compat": "flake-compat_5", - "nixpkgs": [ - "hyprgrass", - "hyprland", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1784288435, - "narHash": "sha256-ReRHaLgr/uVqdD8afFSn+myXIfpHeOhP0yYe0TJqAA8=", - "owner": "cachix", - "repo": "git-hooks.nix", - "rev": "43b3c1ab9d40fb1dbb008f451988a91e375825e9", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "git-hooks.nix", - "type": "github" - } - }, - "pre-commit-hooks_3": { - "inputs": { - "flake-compat": "flake-compat_6", "nixpkgs": [ "hyprland", "nixpkgs" @@ -2147,17 +1706,17 @@ "hermes-agent": "hermes-agent", "home-manager": "home-manager_2", "hyprgrass": "hyprgrass", - "hyprland": "hyprland_2", + "hyprland": "hyprland", "hyprlauncher": "hyprlauncher", "nix-darwin": "nix-darwin", "nix-flatpak": "nix-flatpak", "nix-index-database": "nix-index-database", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs_10", + "nixpkgs": "nixpkgs_9", "nixpkgs-unstable": "nixpkgs-unstable", "noctalia": "noctalia", "stylix": "stylix", - "systems": "systems_7" + "systems": "systems_6" } }, "rust-analyzer-src": { @@ -2190,7 +1749,7 @@ "nixpkgs" ], "nur": "nur", - "systems": "systems_6", + "systems": "systems_5", "tinted-kitty": "tinted-kitty", "tinted-schemes": "tinted-schemes", "tinted-tmux": "tinted-tmux", @@ -2272,21 +1831,6 @@ } }, "systems_5": { - "locked": { - "lastModified": 1689347949, - "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", - "owner": "nix-systems", - "repo": "default-linux", - "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default-linux", - "type": "github" - } - }, - "systems_6": { "locked": { "lastModified": 1681028828, "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", @@ -2301,7 +1845,7 @@ "type": "github" } }, - "systems_7": { + "systems_6": { "locked": { "lastModified": 1681028828, "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", @@ -2408,32 +1952,26 @@ "xdph": { "inputs": { "hyprland-protocols": [ - "hyprgrass", "hyprland", "hyprland-protocols" ], "hyprlang": [ - "hyprgrass", "hyprland", "hyprlang" ], "hyprutils": [ - "hyprgrass", "hyprland", "hyprutils" ], "hyprwayland-scanner": [ - "hyprgrass", "hyprland", "hyprwayland-scanner" ], "nixpkgs": [ - "hyprgrass", "hyprland", "nixpkgs" ], "systems": [ - "hyprgrass", "hyprland", "systems" ] @@ -2451,47 +1989,6 @@ "repo": "xdg-desktop-portal-hyprland", "type": "github" } - }, - "xdph_2": { - "inputs": { - "hyprland-protocols": [ - "hyprland", - "hyprland-protocols" - ], - "hyprlang": [ - "hyprland", - "hyprlang" - ], - "hyprutils": [ - "hyprland", - "hyprutils" - ], - "hyprwayland-scanner": [ - "hyprland", - "hyprwayland-scanner" - ], - "nixpkgs": [ - "hyprland", - "nixpkgs" - ], - "systems": [ - "hyprland", - "systems" - ] - }, - "locked": { - "lastModified": 1786988229, - "narHash": "sha256-frEFLVRj8xXvBBDs44IRiqHo6R2PxsRpluygL7abjjI=", - "owner": "hyprwm", - "repo": "xdg-desktop-portal-hyprland", - "rev": "59d429bf45aed4e2209043c0c36565ad8e2859a5", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "xdg-desktop-portal-hyprland", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index e57c87c..1894632 100644 --- a/flake.nix +++ b/flake.nix @@ -52,7 +52,10 @@ # Hyprland compositor via flake (latest git). hyprland.url = "github:hyprwm/Hyprland"; # Hyprland touchpad gesture plugin - hyprgrass.url = "github:horriblename/hyprgrass"; + hyprgrass = { + url = "github:horriblename/hyprgrass"; + inputs.hyprland.follows = "hyprland"; + }; # Secrets management agenix.url = "github:ryantm/agenix"; # Claude Desktop @@ -191,6 +194,7 @@ in { openwrt-glmain = (openwrt (import ./openwrt-routers/glmain.nix)).deployScript; + openwrt-glmain-dry-run = (openwrt (import ./openwrt-routers/glmain.nix)).dryRunScript; grok-cli = lib.pkgs.${system}.grok-cli; # CPU variant of DwarfStar (antirez/ds4); buildable on any system. # GPU variants (ds4-rocm/ds4-cuda) are overlay-only — see modules/core. diff --git a/modules/openwrt/ABOUTME.md b/modules/openwrt/ABOUTME.md index 3e6784d..e5f026a 100644 --- a/modules/openwrt/ABOUTME.md +++ b/modules/openwrt/ABOUTME.md @@ -16,17 +16,39 @@ openwrt/ ## How it works 1. The router config lives as an **agenix secret** (e.g. `secrets/glmain.json.age`). -2. `openwrt-deploy` reads the decrypted JSON from stdin, runs `openwrt-gen dnsmasq` and - `openwrt-gen ethers` to render the two target files. -3. It SSHes to the router, shows a **colorized diff** against the current files, and prompts - for confirmation before writing. -4. `dnsmasq.conf` is validated with `dnsmasq --test` on the router and **automatically - reverted** if the new config is invalid. +2. `openwrt-deploy` reads the decrypted JSON from stdin, runs `openwrt-gen dnsmasq`, + `openwrt-gen ethers`, and `openwrt-gen firewall` to render the three target files. +3. It SSHes to the router, shows a **colorized diff** against the current files (for the + firewall, only the `skyg_*`-managed rules are diffed), and prompts for confirmation. +4. On the router it **backs up** the configs it overrides to `/etc/skyg-backups/` with a + timestamp, then applies them. `dnsmasq.conf` is validated with `dnsmasq --test` and the + firewall is committed + reloaded; **any failure auto-restores** from that timestamp's + backups. Backups persist so you can restore later if something breaks: + ```sh + cp /etc/skyg-backups/firewall. /etc/config/firewall + uci commit firewall && /etc/init.d/firewall restart + ``` ``` age -d secrets/glmain.json.age | openwrt-deploy ``` +### Dry run (no router changes) + +`openwrt-dry-run` renders the same three configs **locally** and writes them to +`.tmp/openwrt-/` for review — no SSH, no `uci`, no confirm prompt. The router name +comes from the `SKYG_ROUTER` env var (default `glmain`). + +```bash +skyg openwrt --dry-run +# → .tmp/openwrt-glmain/dnsmasq.conf +# → .tmp/openwrt-glmain/ethers +# → .tmp/openwrt-glmain/firewall.batch # the exact `uci batch` that would be applied +``` + +Use this to inspect what a deploy *would* do (especially the firewall rules) before running +the real `skyg openwrt`. + `router.ip` / `router.user` are taken from the `config` passed into `default.nix`. ## Conventions @@ -35,3 +57,6 @@ age -d secrets/glmain.json.age | openwrt-deploy - Deploys are interactive and reviewed by a human; the script intentionally requires confirmation and self-reverts on a bad dnsmasq config. - `generator/target/` is gitignored Rust build output — ignore it. +- Firewall rules are **managed by name**: the deploy script only touches rules named + `skyg_*`. It deletes existing `skyg_*` rules, adds the newly generated ones, commits, and + reloads — so deploys are idempotent and never clobber hand-written rules. diff --git a/modules/openwrt/default.nix b/modules/openwrt/default.nix index 6fd90d5..d1054b5 100644 --- a/modules/openwrt/default.nix +++ b/modules/openwrt/default.nix @@ -7,6 +7,54 @@ let src = ./generator; cargoLock.lockFile = ./generator/Cargo.lock; }; + + # Remote apply script: backs up the configs it overrides, applies the new + # firewall/dnsmasq/ethers, validates, and auto-restores on failure. + # Run on the router as: TS= bash skyg-apply.sh + # Expects the new files staged at /tmp/skyg_firewall.batch, + # /tmp/dnsmasq.new.conf and /tmp/ethers.new. + applyScript = pkgs.writeText { + name = "skyg-apply.sh"; + text = '' + set -euo pipefail + BK=/etc/skyg-backups + mkdir -p "$BK" + cp /etc/config/firewall "$BK/firewall.$TS" + cp /etc/dnsmasq.conf "$BK/dnsmasq.conf.$TS" + cp /etc/ethers "$BK/ethers.$TS" 2>/dev/null || true + + # --- Firewall: replace the skyg-managed rules --- + for ref in $(uci show firewall | awk -F. '/\.name=.skyg_/{print $1"."$2}'); do + uci -q del "$ref" || true + done + if ! uci batch < /tmp/skyg_firewall.batch; then + echo 'FIREWALL: uci batch failed, restoring' + cp "$BK/firewall.$TS" /etc/config/firewall + exit 1 + fi + if ! uci commit firewall; then + echo 'FIREWALL: uci commit failed, restoring' + cp "$BK/firewall.$TS" /etc/config/firewall + exit 1 + fi + /etc/init.d/firewall reload + + # --- dnsmasq --- + cp /tmp/dnsmasq.new.conf /etc/dnsmasq.conf + if dnsmasq --test; then + /etc/init.d/dnsmasq restart + else + echo 'dnsmasq config invalid, restoring' + cp "$BK/dnsmasq.conf.$TS" /etc/dnsmasq.conf + exit 1 + fi + + # --- ethers --- + cp /tmp/ethers.new /etc/ethers + + echo 'Done' + ''; + }; in config: @@ -23,10 +71,16 @@ let DNSMASQ=$(echo "$CONFIG" | ${generator}/bin/openwrt-gen dnsmasq) ETHERS=$(echo "$CONFIG" | ${generator}/bin/openwrt-gen ethers) + FIREWALL=$(echo "$CONFIG" | ${generator}/bin/openwrt-gen firewall) echo "Fetching current config from $SERVER..." CURRENT_DNSMASQ=$(ssh "$SERVER" 'cat /etc/dnsmasq.conf' 2>/dev/null || echo "") CURRENT_ETHERS=$(ssh "$SERVER" 'cat /etc/ethers' 2>/dev/null || echo "") + CURRENT_FIREWALL_ALL=$(ssh "$SERVER" 'uci export firewall' 2>/dev/null || echo "") + # Keep only the skyg-managed rule blocks (for the diff) + CURRENT_FIREWALL=$(echo "$CURRENT_FIREWALL_ALL" | awk '/^config /{if(have && block ~ /skyg_/) print block; block=$0; have=1; next}{if(have) block=block ORS $0}END{if(have && block ~ /skyg_/) print block}') + # Drop the header comment from the generated firewall for a clean diff + NEW_FIREWALL=$(echo "$FIREWALL" | tail -n +2) echo "" echo "$DNSMASQ" @@ -34,8 +88,6 @@ let comm -3 <(echo "$CURRENT_DNSMASQ" | sort) <(echo "$DNSMASQ" | sort) | awk '{if ($0 ~ /^/) print "\033[32m"$0"\033[0m"; else print}' echo "=== dnsmasq.conf diff [END] ===" echo "" - read -p "Looks good? [y/N] " -n 1 -r < /dev/tty; echo - [[ $REPLY =~ ^[Yy]$ ]] || exit 1 echo "$ETHERS" echo "=== ethers diff [START] ===" @@ -43,26 +95,48 @@ let echo "=== ethers diff [END] ===" echo "" + echo "$NEW_FIREWALL" + echo "=== firewall (skyg rules) diff [START] ===" + comm -3 <(echo "$CURRENT_FIREWALL" | sort) <(echo "$NEW_FIREWALL" | sort) | awk '{if ($0 ~ /^/) print "\033[32m"$0"\033[0m"; else print}' + echo "=== firewall (skyg rules) diff [END] ===" + echo "" + read -p "Deploy to $SERVER? [y/N] " -n 1 -r < /dev/tty; echo [[ $REPLY =~ ^[Yy]$ ]] || exit 1 - echo "$DNSMASQ" | ssh "$SERVER" 'cat > /tmp/dnsmasq.new.conf' - echo "$ETHERS" | ssh "$SERVER" 'cat > /etc/ethers' + TS=$(date +%Y%m%d-%H%M%S) - ssh "$SERVER" ' - cp /etc/dnsmasq.conf /tmp/dnsmasq.old.conf - cp /tmp/dnsmasq.new.conf /etc/dnsmasq.conf - if dnsmasq --test; then - /etc/init.d/dnsmasq restart - echo "Done" - else - echo "Config invalid, reverting..." - cp /tmp/dnsmasq.old.conf /etc/dnsmasq.conf - exit 1 - fi - ' + # Stage the apply script and the new config files on the router + ssh "$SERVER" 'cat > /tmp/skyg_apply.sh' < "${applyScript}" + echo "$DNSMASQ" | ssh "$SERVER" 'cat > /tmp/dnsmasq.new.conf' + echo "$ETHERS" | ssh "$SERVER" 'cat > /tmp/ethers.new' + echo "$FIREWALL" | ssh "$SERVER" 'cat > /tmp/skyg_firewall.batch' + + # Back up, apply, validate, auto-restore on failure + ssh "$SERVER" "TS=$TS bash /tmp/skyg_apply.sh" + ''; + + # Dry-run: render the configs locally and write them to .tmp/openwrt-/ + # for review. No SSH, no uci, no router changes. Run from the repo root. + # The router name is taken from $SKYG_ROUTER (default glmain). + dryRunScript = pkgs.writeShellScriptBin "openwrt-dry-run" '' + set -euo pipefail + ROUTER="$'{SKYG_ROUTER:-glmain}" + OUTDIR=".tmp/openwrt-$ROUTER" + mkdir -p "$OUTDIR" + + CONFIG=$(cat) + + echo "$CONFIG" | ${generator}/bin/openwrt-gen dnsmasq > "$OUTDIR/dnsmasq.conf" + echo "$CONFIG" | ${generator}/bin/openwrt-gen ethers > "$OUTDIR/ethers" + echo "$CONFIG" | ${generator}/bin/openwrt-gen firewall > "$OUTDIR/firewall.batch" + + echo "Dry-run configs written to $OUTDIR (no router changes made):" + echo " $OUTDIR/dnsmasq.conf" + echo " $OUTDIR/ethers" + echo " $OUTDIR/firewall.batch" ''; in { - inherit deployScript; + inherit deployScript dryRunScript; } diff --git a/modules/openwrt/generator/ABOUTME.md b/modules/openwrt/generator/ABOUTME.md index d7e5c71..5fa6c14 100644 --- a/modules/openwrt/generator/ABOUTME.md +++ b/modules/openwrt/generator/ABOUTME.md @@ -15,17 +15,19 @@ generator/ │ ├── config.rs # serde Deserialize structs for the input JSON (+ unit tests) │ ├── network.rs # process_network — expands per-network device lists │ └── generators/ -│ ├── mod.rs # re-exports dnsmasq + ethers +│ ├── mod.rs # re-exports dnsmasq + ethers + firewall │ ├── dnsmasq.rs # renders dnsmasq.conf (server= + address= lines) -│ └── ethers.rs # renders /etc/ethers (MAC → name/IP) +│ ├── ethers.rs # renders /etc/ethers (MAC → name/IP) +│ └── firewall.rs # renders UCI firewall rules (internet-only networks) └── target/ # gitignored Cargo build output — ignore it ``` ## Usage ``` -openwrt-gen dnsmasq < config.json # prints dnsmasq.conf -openwrt-gen ethers < config.json # prints /etc/ethers +openwrt-gen dnsmasq < config.json # prints dnsmasq.conf +openwrt-gen ethers < config.json # prints /etc/ethers +openwrt-gen firewall < config.json # prints UCI firewall rules (uci batch format) ``` ## Input shape (`config.rs`) @@ -33,6 +35,23 @@ openwrt-gen ethers < config.json # prints /etc/ethers - `generalMappings`: `[{ ip, domains[] }]` — shared domain→IP records. - `networks`: `{ : [ { mac, name, id?, domains?, justMac? } ] }` — per-network hosts. - `dnsResolvers`: `[{ ip, port?, name? }]` — upstream `server=` entries for dnsmasq. +- `internetOnly`: `[, ...]` — networks restricted to internet-only access. + +## Internet-only firewall rules (`firewall.rs`) + +For each network in `internetOnly`, the generator emits UCI `config rule` blocks that DROP +forwarded traffic from that network to the rest of the LAN (`10.0.0.0/16`): + +- **IPv4** — one rule per network matching the whole subnet (catches every device on it). +- **IPv6** — one rule per known device MAC. All subnets share a single ULA /64 + (`fd59:de0a:bff5::/48`, see `network::ULA_PREFIX`), so subnets are not distinguishable + in IPv6 and blocking is done per known device. An *unknown* IPv6-only device on those + subnets is **not** blocked (inherent to the flat-L2 topology). + +Rules are named `skyg__drop_lan` (IPv4) and `skyg__drop_lan_v6` (IPv6) so +the deploy script owns exactly these. They are inserted before port-specific ACCEPT rules +(e.g. the existing `sambasharelan`) so the DROPs win. Reverse direction (LAN → restricted +network) stays open, and within-subnet traffic (e.g. cam→cam) is blocked. ## Conventions diff --git a/modules/openwrt/generator/src/config.rs b/modules/openwrt/generator/src/config.rs index 324a527..93391af 100644 --- a/modules/openwrt/generator/src/config.rs +++ b/modules/openwrt/generator/src/config.rs @@ -8,6 +8,9 @@ pub struct Config { pub networks: BTreeMap>, #[serde(default, rename = "dnsResolvers")] pub dns_resolvers: Vec, + /// Networks whose devices may only reach the internet, not the rest of the LAN. + #[serde(default, rename = "internetOnly")] + pub internet_only: Vec, } #[derive(Deserialize)] @@ -82,4 +85,18 @@ mod tests { assert_eq!(resolver.port, Some(853)); assert_eq!(resolver.name, Some("CF".to_string())); } + + #[test] + fn test_internet_only_parsing() { + let json = r#"{"generalMappings": [], "networks": {}, "internetOnly": ["cam", "apl", "iot"]}"#; + let config: Config = serde_json::from_str(json).unwrap(); + assert_eq!(config.internet_only, vec!["cam", "apl", "iot"]); + } + + #[test] + fn test_internet_only_defaults_empty() { + let json = r#"{"generalMappings": [], "networks": {}}"#; + let config: Config = serde_json::from_str(json).unwrap(); + assert!(config.internet_only.is_empty()); + } } diff --git a/modules/openwrt/generator/src/generators/dnsmasq.rs b/modules/openwrt/generator/src/generators/dnsmasq.rs index 42d4332..f794320 100644 --- a/modules/openwrt/generator/src/generators/dnsmasq.rs +++ b/modules/openwrt/generator/src/generators/dnsmasq.rs @@ -60,7 +60,7 @@ mod tests { domains, just_mac: false, }]); - Config { general_mappings: vec![], networks, dns_resolvers: vec![] } + Config { general_mappings: vec![], networks, dns_resolvers: vec![], internet_only: vec![] } } #[test] @@ -80,6 +80,7 @@ mod tests { }], networks: BTreeMap::new(), dns_resolvers: vec![], + internet_only: vec![], }; let result = generate(&config); assert!(result.contains("address=/gw.local/192.168.1.1\n")); @@ -95,6 +96,7 @@ mod tests { port: Some(853), name: Some("CF".to_string()), }], + internet_only: vec![], }; let result = generate(&config); assert!(result.contains("server=1.1.1.1#853 # CF\n")); @@ -106,6 +108,7 @@ mod tests { general_mappings: vec![], networks: BTreeMap::new(), dns_resolvers: vec![], + internet_only: vec![], }; assert!(generate(&config).is_empty()); } diff --git a/modules/openwrt/generator/src/generators/ethers.rs b/modules/openwrt/generator/src/generators/ethers.rs index 1db0102..af562d3 100644 --- a/modules/openwrt/generator/src/generators/ethers.rs +++ b/modules/openwrt/generator/src/generators/ethers.rs @@ -40,7 +40,7 @@ mod tests { domains: None, just_mac, }]); - Config { general_mappings: vec![], networks, dns_resolvers: vec![] } + Config { general_mappings: vec![], networks, dns_resolvers: vec![], internet_only: vec![] } } #[test] @@ -69,6 +69,7 @@ mod tests { general_mappings: vec![], networks: BTreeMap::new(), dns_resolvers: vec![], + internet_only: vec![], }; assert!(generate(&config).is_empty()); } diff --git a/modules/openwrt/generator/src/generators/firewall.rs b/modules/openwrt/generator/src/generators/firewall.rs new file mode 100644 index 0000000..0568769 --- /dev/null +++ b/modules/openwrt/generator/src/generators/firewall.rs @@ -0,0 +1,132 @@ +use crate::config::Config; +use crate::network::{prefix_for, process_network, ULA_PREFIX}; + +/// Renders UCI firewall rules (in `uci batch` format) that restrict the networks +/// listed in `config.internet_only` to internet-only access. +/// +/// For each restricted network: +/// - IPv4: a single DROP rule matching the whole subnet (catches all devices on it). +/// - IPv6: a DROP rule per known device MAC (all subnets share one /64, so subnets +/// are not distinguishable in IPv6). +/// +/// Rules are named `skyg__drop_lan[_v6]` so the deploy script can manage +/// exactly the rules it owns. They are inserted before port-specific ACCEPT rules +/// (e.g. the existing `sambasharelan`) so the DROPs win. +pub fn generate(config: &Config) -> String { + let mut out = String::new(); + out.push_str("# Managed by skyg openwrt — do not edit by hand\n"); + + for network in &config.internet_only { + let devices = match config.networks.get(network) { + Some(d) => d, + None => continue, // unknown network name; skip + }; + + // IPv4: block the whole subnet from reaching the rest of the LAN. + let v4_prefix = prefix_for(network); + let v4_subnet = format!("{}.0/24", v4_prefix.trim_end_matches('.')); + out.push_str(&format!( + "config rule\n\ + \toption name 'skyg_{net}_drop_lan'\n\ + \toption src 'lan'\n\ + \toption dest 'lan'\n\ + \toption src_ip '{subnet}'\n\ + \toption dest_ip '10.0.0.0/16'\n\ + \toption target 'DROP'\n\ + \toption family 'ipv4'\n", + net = network, + subnet = v4_subnet, + )); + + // IPv6: block each known device's MAC from reaching the ULA LAN. + for pd in process_network(network, devices) { + out.push_str(&format!( + "config rule\n\ + \toption name 'skyg_{net}_drop_lan_v6'\n\ + \toption src 'lan'\n\ + \toption dest 'lan'\n\ + \toption src_mac '{mac}'\n\ + \toption dest_ip '{ula}'\n\ + \toption target 'DROP'\n\ + \toption family 'ipv6'\n", + net = network, + mac = pd.device.mac, + ula = ULA_PREFIX, + )); + } + } + + out +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::config::{Config, Device}; + use std::collections::BTreeMap; + + fn config_with_devices(internet_only: Vec) -> Config { + let mut networks = BTreeMap::new(); + networks.insert( + "cam".to_string(), + vec![ + Device { + mac: "aa:bb:cc:dd:ee:01".to_string(), + name: "doorbell".to_string(), + id: None, + domains: None, + just_mac: false, + }, + Device { + mac: "aa:bb:cc:dd:ee:02".to_string(), + name: "cam2".to_string(), + id: None, + domains: None, + just_mac: false, + }, + ], + ); + Config { + general_mappings: vec![], + networks, + dns_resolvers: vec![], + internet_only, + } + } + + #[test] + fn test_no_internet_only_is_empty() { + let config = config_with_devices(vec![]); + let result = generate(&config); + assert!(result.lines().count() == 1); // only the header comment + } + + #[test] + fn test_ipv4_subnet_rule() { + let config = config_with_devices(vec!["cam".to_string()]); + let result = generate(&config); + assert!(result.contains("skyg_cam_drop_lan")); + assert!(result.contains("option src_ip '10.0.13.0/24'")); + assert!(result.contains("option dest_ip '10.0.0.0/16'")); + assert!(result.contains("option target 'DROP'")); + assert!(result.contains("option family 'ipv4'")); + } + + #[test] + fn test_ipv6_per_mac_rules() { + let config = config_with_devices(vec!["cam".to_string()]); + let result = generate(&config); + assert!(result.contains("skyg_cam_drop_lan_v6")); + assert!(result.contains("option src_mac 'aa:bb:cc:dd:ee:01'")); + assert!(result.contains("option src_mac 'aa:bb:cc:dd:ee:02'")); + assert!(result.contains("option dest_ip 'fd59:de0a:bff5::/48'")); + assert!(result.contains("option family 'ipv6'")); + } + + #[test] + fn test_unknown_network_is_skipped() { + let config = config_with_devices(vec!["nonexistent".to_string()]); + let result = generate(&config); + assert!(result.lines().count() == 1); // only the header comment + } +} diff --git a/modules/openwrt/generator/src/generators/mod.rs b/modules/openwrt/generator/src/generators/mod.rs index a55aa0e..c94fb90 100644 --- a/modules/openwrt/generator/src/generators/mod.rs +++ b/modules/openwrt/generator/src/generators/mod.rs @@ -1,2 +1,3 @@ pub mod dnsmasq; pub mod ethers; +pub mod firewall; diff --git a/modules/openwrt/generator/src/main.rs b/modules/openwrt/generator/src/main.rs index 6f0a9ce..121c820 100644 --- a/modules/openwrt/generator/src/main.rs +++ b/modules/openwrt/generator/src/main.rs @@ -18,8 +18,9 @@ fn main() { let output = match cmd.as_str() { "dnsmasq" => generators::dnsmasq::generate(&config), "ethers" => generators::ethers::generate(&config), + "firewall" => generators::firewall::generate(&config), _ => { - eprintln!("usage: openwrt-gen "); + eprintln!("usage: openwrt-gen "); std::process::exit(1); } }; diff --git a/modules/openwrt/generator/src/network.rs b/modules/openwrt/generator/src/network.rs index fcfe9bc..53092b1 100644 --- a/modules/openwrt/generator/src/network.rs +++ b/modules/openwrt/generator/src/network.rs @@ -2,6 +2,10 @@ use crate::config::Device; pub const ROOT_DOMAIN: &str = "internal"; +// IPv6 ULA prefix assigned to br-lan (network.lan.ip6prefix). All subnets share +// this single /64, so IPv6 internet-only blocking is done per-device MAC. +pub const ULA_PREFIX: &str = "fd59:de0a:bff5::/48"; + pub static IP_PREFIXES: &[(&str, &str)] = &[ ("lab", "10.0.10."), ("k3s", "10.0.11."), @@ -99,4 +103,9 @@ mod tests { let result = process_network("devices", &devices); assert!(result[0].just_mac); } + + #[test] + fn test_ula_prefix_constant() { + assert_eq!(ULA_PREFIX, "fd59:de0a:bff5::/48"); + } } diff --git a/secrets/glmain.json.age b/secrets/glmain.json.age index 0ee4dd5a617f1dcef3eff056f9d9a70a2f69c6b5..41f1ee357a14c2fd21200c03bba31ddb41d3a6be 100644 GIT binary patch literal 5416 zcmV+@71!!vXJsvAZewzJaCB*JZZ2GzKXGS(bb7ggO zNN{UwXgD)PO-5xfS!y?QPcuhnWHc~%c`I;cY()whh$OjDsTRKpQY&Ud1;ZLW>?(f_ z)GLt{SmIGcM5RCd3FrYZ`4A@rqM`azx>qmF?%UV?4jFo_^ zc*C5#Mvv@Q%N;AO8M|ik5&aFR&c`|?&@p&%xo0WdicrB@?J7#me5$21YE<6v&SV>Q zsHUK~6rLNtd?eETtNsOsMpj8bmw)Uhbp4ME16Bf6|1K<=l5tOzomLom#fbhrMeJr1 z@Em-d50kPO!Yv)z767d?lGzi?de`c)X!$V;IJJ{4!5Am5RFiJl!r%Y9!YMwQ#VGQh zx_L751T>eid=01WD$#R1gAbj;quHw8RWdkU2BblQW)p%e zm!e(FamNKrCU0jfh)!tHS?X>YtUkdKUA!vu`?$BTfT5&Lu7oZs`iXqcha35(RDrpI zJrJJC)xyF48kK0|HoXujwqPhkmk5B9P}B>*xR+{6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