You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
6.1 KiB
Nix

1 year ago
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
/**
ACL independent functions that can be used in parsers.
*/
Squashed commit of the following: commit 014fa13262f264d61de6ae5cd49b67bc02c25bd0 Author: Tilmann Meyer <me@atiltedtree.dev> Date: Sun Mar 24 23:09:00 2024 +0100 Fixed persistent keepalive for networkd configurer commit 37453982ab4c65848c9849aec54806b829072e91 Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:08:06 2024 -0400 update flake commit 68a0496bc7fa0770427d22bd25c6910b9144e9ab Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:07:59 2024 -0400 Update tests to use `subnets` in all connections commit 8c7f741b7f0549387abd96482010bc06b731a55c Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:07:31 2024 -0400 Add error message to parser for incorrectly configured subnets in connections commit 3e3a37fc0f5b232da4c4744d81981d68ccd93ffc Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:05:27 2024 -0400 Update disjoint test commit 1236e4e8f27c22e3e9d936dbbdcb1913b26b8c9c Author: Adam Stephens <adam@valkor.net> Date: Sun Mar 24 20:59:26 2024 -0400 Add disjointed meshes tests commit dadd5bf7205eddb0a17330426bcabdccd6923615 Author: Matthew Salerno <m@salernosection.com> Date: Wed Dec 13 22:01:16 2023 -0500 add tags to agenix-rekey provider commit 1d3184639a5a83f0633f2908cd3b66293a24d1d8 Author: Matthew Salerno <m@salernosection.com> Date: Mon Dec 11 22:09:45 2023 -0500 sneaky systemd issues with dev only commit c8fb5affe5802c133abe10a51b228bfd76e03147 Author: Matthew Salerno <m@salernosection.com> Date: Tue Dec 5 20:51:30 2023 -0500 wnlib is back commit 1e697eb859788c592a5e3606086180b72fd1e9f1 Author: Matthew Salerno <m@salernosection.com> Date: Sat Nov 11 22:09:26 2023 -0500 allow multiple devs for same subnet commit 45b70c90636eee57d49ebac348e345912be226da Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 18 16:04:49 2023 -0400 added manual ip tests and resulting fixes commit 3d49ebff29894fe58de97a07a02035bd6d9a2752 Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 18 11:49:58 2023 -0400 Added manual IP assignment tests commit bd52d85d2dc56b0933d958aa3ef4faa3113e356c Author: Matthew Salerno <m@salernosection.com> Date: Thu Sep 14 16:08:00 2023 -0400 Generalized ip assignment to take cidr or IP commit fd2b9ce77cf1492463413e8bc0a9797226f9ddd0 Author: Matthew Salerno <m@salernosection.com> Date: Thu Sep 14 13:50:11 2023 -0400 Generalized ip assignment to take cidr or IP commit 57f8e0e97463dec3e0da7f4b995ee89b92d36687 Author: Matthew Salerno <m@salernosection.com> Date: Wed Sep 13 18:38:42 2023 -0400 Fixed manual ipv4 assignment issue commit a24fffa753745d1d6285ae588ff29b374ea1f8d2 Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 11 13:44:11 2023 -0400 Update README.md with link to self commit dd9de47a84060004ec9c76ceb7e7ee4086438f73 Author: Matthew Salerno <m@salernosection.com> Date: Sat Sep 2 19:55:17 2023 -0400 fixed missing link commit e761330e9189d194018ec2e3bd314d015b3f5f38 Merge: bb8636d b658653 Author: Matthew Salerno <m@salernosection.com> Date: Sat Sep 2 19:54:29 2023 -0400 fixed missing link commit bb8636dd8d5841747cdb7e8da171aeb44534e4a6 Author: Matthew Salerno <m@salernosection.com> Date: Thu Aug 31 20:45:14 2023 -0400 Readme moved to wiki commit 86e300428b905843129d2785d01fdf4313334b93 Author: Matthew Salerno <m@salernosection.com> Date: Tue Aug 22 21:07:34 2023 -0400 Fixed a bug in allGroupEndpoints logic commit 9a5c773355c571b6dc005dd70b083775b00f106d Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 22:03:19 2023 -0400 oops, delete net.nix commit b97760e456dc471e33bab3844ab9d3dbd5cc5a73 Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:59:30 2023 -0400 fixup additional_ settings commit 753c0726630304113e5a6af75d97b4fcf0b45a90 Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:30:40 2023 -0400 change null test to test enable = false commit 690e13e902ef6515946baf882a470f00b54adefa Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:28:29 2023 -0400 add mailing list to readme
7 months ago
{ lib, ... }:
with lib;
rec {
/** Builtin Parsers */
defaultParsers = {
v1 = import ./parsers/v1.nix;
};
/** Builtin configurers */
defaultConfigurers = {
static = import ./configurers/static.nix;
networkd = import ./configurers/networkd.nix;
Squashed commit of the following: commit 014fa13262f264d61de6ae5cd49b67bc02c25bd0 Author: Tilmann Meyer <me@atiltedtree.dev> Date: Sun Mar 24 23:09:00 2024 +0100 Fixed persistent keepalive for networkd configurer commit 37453982ab4c65848c9849aec54806b829072e91 Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:08:06 2024 -0400 update flake commit 68a0496bc7fa0770427d22bd25c6910b9144e9ab Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:07:59 2024 -0400 Update tests to use `subnets` in all connections commit 8c7f741b7f0549387abd96482010bc06b731a55c Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:07:31 2024 -0400 Add error message to parser for incorrectly configured subnets in connections commit 3e3a37fc0f5b232da4c4744d81981d68ccd93ffc Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:05:27 2024 -0400 Update disjoint test commit 1236e4e8f27c22e3e9d936dbbdcb1913b26b8c9c Author: Adam Stephens <adam@valkor.net> Date: Sun Mar 24 20:59:26 2024 -0400 Add disjointed meshes tests commit dadd5bf7205eddb0a17330426bcabdccd6923615 Author: Matthew Salerno <m@salernosection.com> Date: Wed Dec 13 22:01:16 2023 -0500 add tags to agenix-rekey provider commit 1d3184639a5a83f0633f2908cd3b66293a24d1d8 Author: Matthew Salerno <m@salernosection.com> Date: Mon Dec 11 22:09:45 2023 -0500 sneaky systemd issues with dev only commit c8fb5affe5802c133abe10a51b228bfd76e03147 Author: Matthew Salerno <m@salernosection.com> Date: Tue Dec 5 20:51:30 2023 -0500 wnlib is back commit 1e697eb859788c592a5e3606086180b72fd1e9f1 Author: Matthew Salerno <m@salernosection.com> Date: Sat Nov 11 22:09:26 2023 -0500 allow multiple devs for same subnet commit 45b70c90636eee57d49ebac348e345912be226da Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 18 16:04:49 2023 -0400 added manual ip tests and resulting fixes commit 3d49ebff29894fe58de97a07a02035bd6d9a2752 Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 18 11:49:58 2023 -0400 Added manual IP assignment tests commit bd52d85d2dc56b0933d958aa3ef4faa3113e356c Author: Matthew Salerno <m@salernosection.com> Date: Thu Sep 14 16:08:00 2023 -0400 Generalized ip assignment to take cidr or IP commit fd2b9ce77cf1492463413e8bc0a9797226f9ddd0 Author: Matthew Salerno <m@salernosection.com> Date: Thu Sep 14 13:50:11 2023 -0400 Generalized ip assignment to take cidr or IP commit 57f8e0e97463dec3e0da7f4b995ee89b92d36687 Author: Matthew Salerno <m@salernosection.com> Date: Wed Sep 13 18:38:42 2023 -0400 Fixed manual ipv4 assignment issue commit a24fffa753745d1d6285ae588ff29b374ea1f8d2 Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 11 13:44:11 2023 -0400 Update README.md with link to self commit dd9de47a84060004ec9c76ceb7e7ee4086438f73 Author: Matthew Salerno <m@salernosection.com> Date: Sat Sep 2 19:55:17 2023 -0400 fixed missing link commit e761330e9189d194018ec2e3bd314d015b3f5f38 Merge: bb8636d b658653 Author: Matthew Salerno <m@salernosection.com> Date: Sat Sep 2 19:54:29 2023 -0400 fixed missing link commit bb8636dd8d5841747cdb7e8da171aeb44534e4a6 Author: Matthew Salerno <m@salernosection.com> Date: Thu Aug 31 20:45:14 2023 -0400 Readme moved to wiki commit 86e300428b905843129d2785d01fdf4313334b93 Author: Matthew Salerno <m@salernosection.com> Date: Tue Aug 22 21:07:34 2023 -0400 Fixed a bug in allGroupEndpoints logic commit 9a5c773355c571b6dc005dd70b083775b00f106d Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 22:03:19 2023 -0400 oops, delete net.nix commit b97760e456dc471e33bab3844ab9d3dbd5cc5a73 Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:59:30 2023 -0400 fixup additional_ settings commit 753c0726630304113e5a6af75d97b4fcf0b45a90 Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:30:40 2023 -0400 change null test to test enable = false commit 690e13e902ef6515946baf882a470f00b54adefa Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:28:29 2023 -0400 add mailing list to readme
7 months ago
networkd-dev-only = import ./configurers/networkd-dev-only.nix;
};
/** Builtin key providers */
defaultKeyProviders = {
acl = import ./key-providers/acl.nix;
agenix-rekey = import ./key-providers/agenix-rekey.nix;
};
/** listOfSetsToSetByKey :: string -> list -> attrSet
* Example:
* listOfSetsToSetByKey "primary" [ {primary = "foo"; secondary = 1; tertiary = "one"} {primary = "bar"; secondary = 2; tertiary = "two"} ]
* {foo = {secondary = 1; tertiary = "one"}; bar = {secondary = 2; tertiary = "two"};}
*/
listOfSetsToSetByKey = key: list:
listToAttrs (
1 year ago
map (item: {
name = item."${key}";
value = removeAttrs item [ key ];
}) list
);
/** Like listOfSetsToSetByKey, but also performs a map before dropping the key */
1 year ago
mapListOfSetsToSetByKey = key: function: list:
mapAttrs (name: value: removeAttrs (function value) [key]) (
listToAttrs (
map (item: {
name = item."${key}";
value = item;
}) list
)
);
/** adds colons to a string every 4 characters for IPv6 shenanigans */
addColonsToIPv6 = string:
if ((stringLength string) > 4)
then
((substring 0 4 string) + ":" + (addColonsToIPv6 (substring 4 32 string)))
else string;
/** pipeMap :: [(a_(n) -> a_(n+1)] -> [a_0] -> [a_end]
* equivelent to `builtins.map (lib.trivial.flip lib.trivial.pipe funcList) elems`
*/
pipeMap =
let
pipe = item: funcs:
if ((length funcs) == 0)
then item
else pipe ((head funcs) item) (tail funcs);
pipe' = funcs: item: pipe item funcs;
in
funcs: list: map (pipe' funcs) list;
/** generate last 20 characters (80 bits) of the peer's IPv6 address */
Squashed commit of the following: commit 014fa13262f264d61de6ae5cd49b67bc02c25bd0 Author: Tilmann Meyer <me@atiltedtree.dev> Date: Sun Mar 24 23:09:00 2024 +0100 Fixed persistent keepalive for networkd configurer commit 37453982ab4c65848c9849aec54806b829072e91 Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:08:06 2024 -0400 update flake commit 68a0496bc7fa0770427d22bd25c6910b9144e9ab Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:07:59 2024 -0400 Update tests to use `subnets` in all connections commit 8c7f741b7f0549387abd96482010bc06b731a55c Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:07:31 2024 -0400 Add error message to parser for incorrectly configured subnets in connections commit 3e3a37fc0f5b232da4c4744d81981d68ccd93ffc Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:05:27 2024 -0400 Update disjoint test commit 1236e4e8f27c22e3e9d936dbbdcb1913b26b8c9c Author: Adam Stephens <adam@valkor.net> Date: Sun Mar 24 20:59:26 2024 -0400 Add disjointed meshes tests commit dadd5bf7205eddb0a17330426bcabdccd6923615 Author: Matthew Salerno <m@salernosection.com> Date: Wed Dec 13 22:01:16 2023 -0500 add tags to agenix-rekey provider commit 1d3184639a5a83f0633f2908cd3b66293a24d1d8 Author: Matthew Salerno <m@salernosection.com> Date: Mon Dec 11 22:09:45 2023 -0500 sneaky systemd issues with dev only commit c8fb5affe5802c133abe10a51b228bfd76e03147 Author: Matthew Salerno <m@salernosection.com> Date: Tue Dec 5 20:51:30 2023 -0500 wnlib is back commit 1e697eb859788c592a5e3606086180b72fd1e9f1 Author: Matthew Salerno <m@salernosection.com> Date: Sat Nov 11 22:09:26 2023 -0500 allow multiple devs for same subnet commit 45b70c90636eee57d49ebac348e345912be226da Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 18 16:04:49 2023 -0400 added manual ip tests and resulting fixes commit 3d49ebff29894fe58de97a07a02035bd6d9a2752 Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 18 11:49:58 2023 -0400 Added manual IP assignment tests commit bd52d85d2dc56b0933d958aa3ef4faa3113e356c Author: Matthew Salerno <m@salernosection.com> Date: Thu Sep 14 16:08:00 2023 -0400 Generalized ip assignment to take cidr or IP commit fd2b9ce77cf1492463413e8bc0a9797226f9ddd0 Author: Matthew Salerno <m@salernosection.com> Date: Thu Sep 14 13:50:11 2023 -0400 Generalized ip assignment to take cidr or IP commit 57f8e0e97463dec3e0da7f4b995ee89b92d36687 Author: Matthew Salerno <m@salernosection.com> Date: Wed Sep 13 18:38:42 2023 -0400 Fixed manual ipv4 assignment issue commit a24fffa753745d1d6285ae588ff29b374ea1f8d2 Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 11 13:44:11 2023 -0400 Update README.md with link to self commit dd9de47a84060004ec9c76ceb7e7ee4086438f73 Author: Matthew Salerno <m@salernosection.com> Date: Sat Sep 2 19:55:17 2023 -0400 fixed missing link commit e761330e9189d194018ec2e3bd314d015b3f5f38 Merge: bb8636d b658653 Author: Matthew Salerno <m@salernosection.com> Date: Sat Sep 2 19:54:29 2023 -0400 fixed missing link commit bb8636dd8d5841747cdb7e8da171aeb44534e4a6 Author: Matthew Salerno <m@salernosection.com> Date: Thu Aug 31 20:45:14 2023 -0400 Readme moved to wiki commit 86e300428b905843129d2785d01fdf4313334b93 Author: Matthew Salerno <m@salernosection.com> Date: Tue Aug 22 21:07:34 2023 -0400 Fixed a bug in allGroupEndpoints logic commit 9a5c773355c571b6dc005dd70b083775b00f106d Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 22:03:19 2023 -0400 oops, delete net.nix commit b97760e456dc471e33bab3844ab9d3dbd5cc5a73 Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:59:30 2023 -0400 fixup additional_ settings commit 753c0726630304113e5a6af75d97b4fcf0b45a90 Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:30:40 2023 -0400 change null test to test enable = false commit 690e13e902ef6515946baf882a470f00b54adefa Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:28:29 2023 -0400 add mailing list to readme
7 months ago
generateIPv6Suffix = peerName: substring 0 16 (builtins.hashString "sha256" peerName);
/** generate the first 10 characters of the IPV6 address for the subnet name */
Squashed commit of the following: commit 014fa13262f264d61de6ae5cd49b67bc02c25bd0 Author: Tilmann Meyer <me@atiltedtree.dev> Date: Sun Mar 24 23:09:00 2024 +0100 Fixed persistent keepalive for networkd configurer commit 37453982ab4c65848c9849aec54806b829072e91 Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:08:06 2024 -0400 update flake commit 68a0496bc7fa0770427d22bd25c6910b9144e9ab Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:07:59 2024 -0400 Update tests to use `subnets` in all connections commit 8c7f741b7f0549387abd96482010bc06b731a55c Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:07:31 2024 -0400 Add error message to parser for incorrectly configured subnets in connections commit 3e3a37fc0f5b232da4c4744d81981d68ccd93ffc Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:05:27 2024 -0400 Update disjoint test commit 1236e4e8f27c22e3e9d936dbbdcb1913b26b8c9c Author: Adam Stephens <adam@valkor.net> Date: Sun Mar 24 20:59:26 2024 -0400 Add disjointed meshes tests commit dadd5bf7205eddb0a17330426bcabdccd6923615 Author: Matthew Salerno <m@salernosection.com> Date: Wed Dec 13 22:01:16 2023 -0500 add tags to agenix-rekey provider commit 1d3184639a5a83f0633f2908cd3b66293a24d1d8 Author: Matthew Salerno <m@salernosection.com> Date: Mon Dec 11 22:09:45 2023 -0500 sneaky systemd issues with dev only commit c8fb5affe5802c133abe10a51b228bfd76e03147 Author: Matthew Salerno <m@salernosection.com> Date: Tue Dec 5 20:51:30 2023 -0500 wnlib is back commit 1e697eb859788c592a5e3606086180b72fd1e9f1 Author: Matthew Salerno <m@salernosection.com> Date: Sat Nov 11 22:09:26 2023 -0500 allow multiple devs for same subnet commit 45b70c90636eee57d49ebac348e345912be226da Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 18 16:04:49 2023 -0400 added manual ip tests and resulting fixes commit 3d49ebff29894fe58de97a07a02035bd6d9a2752 Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 18 11:49:58 2023 -0400 Added manual IP assignment tests commit bd52d85d2dc56b0933d958aa3ef4faa3113e356c Author: Matthew Salerno <m@salernosection.com> Date: Thu Sep 14 16:08:00 2023 -0400 Generalized ip assignment to take cidr or IP commit fd2b9ce77cf1492463413e8bc0a9797226f9ddd0 Author: Matthew Salerno <m@salernosection.com> Date: Thu Sep 14 13:50:11 2023 -0400 Generalized ip assignment to take cidr or IP commit 57f8e0e97463dec3e0da7f4b995ee89b92d36687 Author: Matthew Salerno <m@salernosection.com> Date: Wed Sep 13 18:38:42 2023 -0400 Fixed manual ipv4 assignment issue commit a24fffa753745d1d6285ae588ff29b374ea1f8d2 Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 11 13:44:11 2023 -0400 Update README.md with link to self commit dd9de47a84060004ec9c76ceb7e7ee4086438f73 Author: Matthew Salerno <m@salernosection.com> Date: Sat Sep 2 19:55:17 2023 -0400 fixed missing link commit e761330e9189d194018ec2e3bd314d015b3f5f38 Merge: bb8636d b658653 Author: Matthew Salerno <m@salernosection.com> Date: Sat Sep 2 19:54:29 2023 -0400 fixed missing link commit bb8636dd8d5841747cdb7e8da171aeb44534e4a6 Author: Matthew Salerno <m@salernosection.com> Date: Thu Aug 31 20:45:14 2023 -0400 Readme moved to wiki commit 86e300428b905843129d2785d01fdf4313334b93 Author: Matthew Salerno <m@salernosection.com> Date: Tue Aug 22 21:07:34 2023 -0400 Fixed a bug in allGroupEndpoints logic commit 9a5c773355c571b6dc005dd70b083775b00f106d Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 22:03:19 2023 -0400 oops, delete net.nix commit b97760e456dc471e33bab3844ab9d3dbd5cc5a73 Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:59:30 2023 -0400 fixup additional_ settings commit 753c0726630304113e5a6af75d97b4fcf0b45a90 Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:30:40 2023 -0400 change null test to test enable = false commit 690e13e902ef6515946baf882a470f00b54adefa Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:28:29 2023 -0400 add mailing list to readme
7 months ago
generateIPv6Prefix = subnetName: "fd" + (substring 0 14 (builtins.hashString "sha256" subnetName));
/** generates a full IPv6 subnet */
generateIPv6Subnet = subnetName: (addColonsToIPv6 (generateIPv6Prefix subnetName)) + "::/64";
/** generates a full IPv6 address */
generateIPv6Address = subnetName: peerName: (addColonsToIPv6 ((generateIPv6Prefix subnetName) + (generateIPv6Suffix peerName)));
/** generates a full IPv6 address with cidr */
generateIPv6Cidr = subnetName: peerName: (addColonsToIPv6 ((generateIPv6Prefix subnetName) + (generateIPv6Suffix peerName))) + "/64";
Squashed commit of the following: commit 014fa13262f264d61de6ae5cd49b67bc02c25bd0 Author: Tilmann Meyer <me@atiltedtree.dev> Date: Sun Mar 24 23:09:00 2024 +0100 Fixed persistent keepalive for networkd configurer commit 37453982ab4c65848c9849aec54806b829072e91 Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:08:06 2024 -0400 update flake commit 68a0496bc7fa0770427d22bd25c6910b9144e9ab Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:07:59 2024 -0400 Update tests to use `subnets` in all connections commit 8c7f741b7f0549387abd96482010bc06b731a55c Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:07:31 2024 -0400 Add error message to parser for incorrectly configured subnets in connections commit 3e3a37fc0f5b232da4c4744d81981d68ccd93ffc Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:05:27 2024 -0400 Update disjoint test commit 1236e4e8f27c22e3e9d936dbbdcb1913b26b8c9c Author: Adam Stephens <adam@valkor.net> Date: Sun Mar 24 20:59:26 2024 -0400 Add disjointed meshes tests commit dadd5bf7205eddb0a17330426bcabdccd6923615 Author: Matthew Salerno <m@salernosection.com> Date: Wed Dec 13 22:01:16 2023 -0500 add tags to agenix-rekey provider commit 1d3184639a5a83f0633f2908cd3b66293a24d1d8 Author: Matthew Salerno <m@salernosection.com> Date: Mon Dec 11 22:09:45 2023 -0500 sneaky systemd issues with dev only commit c8fb5affe5802c133abe10a51b228bfd76e03147 Author: Matthew Salerno <m@salernosection.com> Date: Tue Dec 5 20:51:30 2023 -0500 wnlib is back commit 1e697eb859788c592a5e3606086180b72fd1e9f1 Author: Matthew Salerno <m@salernosection.com> Date: Sat Nov 11 22:09:26 2023 -0500 allow multiple devs for same subnet commit 45b70c90636eee57d49ebac348e345912be226da Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 18 16:04:49 2023 -0400 added manual ip tests and resulting fixes commit 3d49ebff29894fe58de97a07a02035bd6d9a2752 Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 18 11:49:58 2023 -0400 Added manual IP assignment tests commit bd52d85d2dc56b0933d958aa3ef4faa3113e356c Author: Matthew Salerno <m@salernosection.com> Date: Thu Sep 14 16:08:00 2023 -0400 Generalized ip assignment to take cidr or IP commit fd2b9ce77cf1492463413e8bc0a9797226f9ddd0 Author: Matthew Salerno <m@salernosection.com> Date: Thu Sep 14 13:50:11 2023 -0400 Generalized ip assignment to take cidr or IP commit 57f8e0e97463dec3e0da7f4b995ee89b92d36687 Author: Matthew Salerno <m@salernosection.com> Date: Wed Sep 13 18:38:42 2023 -0400 Fixed manual ipv4 assignment issue commit a24fffa753745d1d6285ae588ff29b374ea1f8d2 Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 11 13:44:11 2023 -0400 Update README.md with link to self commit dd9de47a84060004ec9c76ceb7e7ee4086438f73 Author: Matthew Salerno <m@salernosection.com> Date: Sat Sep 2 19:55:17 2023 -0400 fixed missing link commit e761330e9189d194018ec2e3bd314d015b3f5f38 Merge: bb8636d b658653 Author: Matthew Salerno <m@salernosection.com> Date: Sat Sep 2 19:54:29 2023 -0400 fixed missing link commit bb8636dd8d5841747cdb7e8da171aeb44534e4a6 Author: Matthew Salerno <m@salernosection.com> Date: Thu Aug 31 20:45:14 2023 -0400 Readme moved to wiki commit 86e300428b905843129d2785d01fdf4313334b93 Author: Matthew Salerno <m@salernosection.com> Date: Tue Aug 22 21:07:34 2023 -0400 Fixed a bug in allGroupEndpoints logic commit 9a5c773355c571b6dc005dd70b083775b00f106d Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 22:03:19 2023 -0400 oops, delete net.nix commit b97760e456dc471e33bab3844ab9d3dbd5cc5a73 Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:59:30 2023 -0400 fixup additional_ settings commit 753c0726630304113e5a6af75d97b4fcf0b45a90 Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:30:40 2023 -0400 change null test to test enable = false commit 690e13e902ef6515946baf882a470f00b54adefa Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:28:29 2023 -0400 add mailing list to readme
7 months ago
getDevName' = devNameMethod: peerName: subnetName:
let
getDevNameLong = peerName: subnetName: subnetName;
getDevNameShort = peerName: subnetName: head (splitString "." subnetName);
getDevNameHash = peerName: subnetName: "wn." + (substring 0 12 (builtins.hashString "sha256" (peerName + "." + subnetName)));
in
if devNameMethod == "hash" then
getDevNameHash peerName subnetName
else if devNameMethod == "long" then
getDevNameLong peerName subnetName
else
getDevNameShort peerName subnetName;
getDevName = devNameMethod: peerName: subnetName:
let
name = getDevName' devNameMethod peerName subnetName;
in
throwIf (stringLength name > 15) "Wirenix: Dev name must be less than or equal to 15 characters. Try changing devNameMethod to \"hash\"" name;
# getDevName = subnetName: peerName: if stringLength (getDevNameLong subnetName peerName) > 12 then getDevNameShort subnetName peerName else getDevNameLong subnetName peerName;
/**
* makes the intermediate config non-recursive, so it can be pretty printed and
* inspected in the repl. Also helps with testing as it forces evaluation of the config.
*/
breakIntermediateRecursion = intermediateConfig:
let recurse = parentName:
mapAttrs (name: value:
Squashed commit of the following: commit 014fa13262f264d61de6ae5cd49b67bc02c25bd0 Author: Tilmann Meyer <me@atiltedtree.dev> Date: Sun Mar 24 23:09:00 2024 +0100 Fixed persistent keepalive for networkd configurer commit 37453982ab4c65848c9849aec54806b829072e91 Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:08:06 2024 -0400 update flake commit 68a0496bc7fa0770427d22bd25c6910b9144e9ab Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:07:59 2024 -0400 Update tests to use `subnets` in all connections commit 8c7f741b7f0549387abd96482010bc06b731a55c Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:07:31 2024 -0400 Add error message to parser for incorrectly configured subnets in connections commit 3e3a37fc0f5b232da4c4744d81981d68ccd93ffc Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:05:27 2024 -0400 Update disjoint test commit 1236e4e8f27c22e3e9d936dbbdcb1913b26b8c9c Author: Adam Stephens <adam@valkor.net> Date: Sun Mar 24 20:59:26 2024 -0400 Add disjointed meshes tests commit dadd5bf7205eddb0a17330426bcabdccd6923615 Author: Matthew Salerno <m@salernosection.com> Date: Wed Dec 13 22:01:16 2023 -0500 add tags to agenix-rekey provider commit 1d3184639a5a83f0633f2908cd3b66293a24d1d8 Author: Matthew Salerno <m@salernosection.com> Date: Mon Dec 11 22:09:45 2023 -0500 sneaky systemd issues with dev only commit c8fb5affe5802c133abe10a51b228bfd76e03147 Author: Matthew Salerno <m@salernosection.com> Date: Tue Dec 5 20:51:30 2023 -0500 wnlib is back commit 1e697eb859788c592a5e3606086180b72fd1e9f1 Author: Matthew Salerno <m@salernosection.com> Date: Sat Nov 11 22:09:26 2023 -0500 allow multiple devs for same subnet commit 45b70c90636eee57d49ebac348e345912be226da Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 18 16:04:49 2023 -0400 added manual ip tests and resulting fixes commit 3d49ebff29894fe58de97a07a02035bd6d9a2752 Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 18 11:49:58 2023 -0400 Added manual IP assignment tests commit bd52d85d2dc56b0933d958aa3ef4faa3113e356c Author: Matthew Salerno <m@salernosection.com> Date: Thu Sep 14 16:08:00 2023 -0400 Generalized ip assignment to take cidr or IP commit fd2b9ce77cf1492463413e8bc0a9797226f9ddd0 Author: Matthew Salerno <m@salernosection.com> Date: Thu Sep 14 13:50:11 2023 -0400 Generalized ip assignment to take cidr or IP commit 57f8e0e97463dec3e0da7f4b995ee89b92d36687 Author: Matthew Salerno <m@salernosection.com> Date: Wed Sep 13 18:38:42 2023 -0400 Fixed manual ipv4 assignment issue commit a24fffa753745d1d6285ae588ff29b374ea1f8d2 Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 11 13:44:11 2023 -0400 Update README.md with link to self commit dd9de47a84060004ec9c76ceb7e7ee4086438f73 Author: Matthew Salerno <m@salernosection.com> Date: Sat Sep 2 19:55:17 2023 -0400 fixed missing link commit e761330e9189d194018ec2e3bd314d015b3f5f38 Merge: bb8636d b658653 Author: Matthew Salerno <m@salernosection.com> Date: Sat Sep 2 19:54:29 2023 -0400 fixed missing link commit bb8636dd8d5841747cdb7e8da171aeb44534e4a6 Author: Matthew Salerno <m@salernosection.com> Date: Thu Aug 31 20:45:14 2023 -0400 Readme moved to wiki commit 86e300428b905843129d2785d01fdf4313334b93 Author: Matthew Salerno <m@salernosection.com> Date: Tue Aug 22 21:07:34 2023 -0400 Fixed a bug in allGroupEndpoints logic commit 9a5c773355c571b6dc005dd70b083775b00f106d Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 22:03:19 2023 -0400 oops, delete net.nix commit b97760e456dc471e33bab3844ab9d3dbd5cc5a73 Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:59:30 2023 -0400 fixup additional_ settings commit 753c0726630304113e5a6af75d97b4fcf0b45a90 Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:30:40 2023 -0400 change null test to test enable = false commit 690e13e902ef6515946baf882a470f00b54adefa Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:28:29 2023 -0400 add mailing list to readme
7 months ago
if builtins.typeOf value == "set" then
if elem name [ "peer" "subnet" "group" "groups" ] then
"${name}s.${parentName}"
else if elem parentName ["peers"] then
"${parentName}.${name}"
else
recurse name value
else
value
);
in
mapAttrs (name: value: recurse "" value) intermediateConfig;
Squashed commit of the following: commit 014fa13262f264d61de6ae5cd49b67bc02c25bd0 Author: Tilmann Meyer <me@atiltedtree.dev> Date: Sun Mar 24 23:09:00 2024 +0100 Fixed persistent keepalive for networkd configurer commit 37453982ab4c65848c9849aec54806b829072e91 Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:08:06 2024 -0400 update flake commit 68a0496bc7fa0770427d22bd25c6910b9144e9ab Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:07:59 2024 -0400 Update tests to use `subnets` in all connections commit 8c7f741b7f0549387abd96482010bc06b731a55c Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:07:31 2024 -0400 Add error message to parser for incorrectly configured subnets in connections commit 3e3a37fc0f5b232da4c4744d81981d68ccd93ffc Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:05:27 2024 -0400 Update disjoint test commit 1236e4e8f27c22e3e9d936dbbdcb1913b26b8c9c Author: Adam Stephens <adam@valkor.net> Date: Sun Mar 24 20:59:26 2024 -0400 Add disjointed meshes tests commit dadd5bf7205eddb0a17330426bcabdccd6923615 Author: Matthew Salerno <m@salernosection.com> Date: Wed Dec 13 22:01:16 2023 -0500 add tags to agenix-rekey provider commit 1d3184639a5a83f0633f2908cd3b66293a24d1d8 Author: Matthew Salerno <m@salernosection.com> Date: Mon Dec 11 22:09:45 2023 -0500 sneaky systemd issues with dev only commit c8fb5affe5802c133abe10a51b228bfd76e03147 Author: Matthew Salerno <m@salernosection.com> Date: Tue Dec 5 20:51:30 2023 -0500 wnlib is back commit 1e697eb859788c592a5e3606086180b72fd1e9f1 Author: Matthew Salerno <m@salernosection.com> Date: Sat Nov 11 22:09:26 2023 -0500 allow multiple devs for same subnet commit 45b70c90636eee57d49ebac348e345912be226da Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 18 16:04:49 2023 -0400 added manual ip tests and resulting fixes commit 3d49ebff29894fe58de97a07a02035bd6d9a2752 Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 18 11:49:58 2023 -0400 Added manual IP assignment tests commit bd52d85d2dc56b0933d958aa3ef4faa3113e356c Author: Matthew Salerno <m@salernosection.com> Date: Thu Sep 14 16:08:00 2023 -0400 Generalized ip assignment to take cidr or IP commit fd2b9ce77cf1492463413e8bc0a9797226f9ddd0 Author: Matthew Salerno <m@salernosection.com> Date: Thu Sep 14 13:50:11 2023 -0400 Generalized ip assignment to take cidr or IP commit 57f8e0e97463dec3e0da7f4b995ee89b92d36687 Author: Matthew Salerno <m@salernosection.com> Date: Wed Sep 13 18:38:42 2023 -0400 Fixed manual ipv4 assignment issue commit a24fffa753745d1d6285ae588ff29b374ea1f8d2 Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 11 13:44:11 2023 -0400 Update README.md with link to self commit dd9de47a84060004ec9c76ceb7e7ee4086438f73 Author: Matthew Salerno <m@salernosection.com> Date: Sat Sep 2 19:55:17 2023 -0400 fixed missing link commit e761330e9189d194018ec2e3bd314d015b3f5f38 Merge: bb8636d b658653 Author: Matthew Salerno <m@salernosection.com> Date: Sat Sep 2 19:54:29 2023 -0400 fixed missing link commit bb8636dd8d5841747cdb7e8da171aeb44534e4a6 Author: Matthew Salerno <m@salernosection.com> Date: Thu Aug 31 20:45:14 2023 -0400 Readme moved to wiki commit 86e300428b905843129d2785d01fdf4313334b93 Author: Matthew Salerno <m@salernosection.com> Date: Tue Aug 22 21:07:34 2023 -0400 Fixed a bug in allGroupEndpoints logic commit 9a5c773355c571b6dc005dd70b083775b00f106d Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 22:03:19 2023 -0400 oops, delete net.nix commit b97760e456dc471e33bab3844ab9d3dbd5cc5a73 Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:59:30 2023 -0400 fixup additional_ settings commit 753c0726630304113e5a6af75d97b4fcf0b45a90 Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:30:40 2023 -0400 change null test to test enable = false commit 690e13e902ef6515946baf882a470f00b54adefa Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:28:29 2023 -0400 add mailing list to readme
7 months ago
nixosConfigForPeer = nixosConfigurations: peerName: head (attrValues (
filterAttrs (
name: value: (attrByPath ["config" "modules" "wirenix" "peerName"] null value) == peerName
) nixosConfigurations));
getKeyProviderFuncs = keyProvidersUninitialized: inputs: intermediateConfig: peerName:
let
keyProviders = map (x: x inputs intermediateConfig peerName) keyProvidersUninitialized;
in
{
getPeerPubKey = otherPeerName: findFirst (x: x != null) (throw ("Wirenix: Could not find public key for " + otherPeerName))
(map (provider: provider.getPeerPubKey otherPeerName) keyProviders);
1 year ago
getPrivKeyFile = findFirst (x: x != null) (if getPrivKey == null then throw ("Wirenix: Could not find private key file for " + peerName) else null)
(map (provider: provider.getPrivKeyFile) keyProviders);
getSubnetPSKFile = subnetName: findFirst (x: x != null) (null)
(map (provider: provider.getSubnetPSKFile subnetName) keyProviders);
getProviderConfig = foldl' (x: y: x // y) {} (map (provider: if provider ? config then provider.config else {}) keyProviders);
};
Squashed commit of the following: commit 014fa13262f264d61de6ae5cd49b67bc02c25bd0 Author: Tilmann Meyer <me@atiltedtree.dev> Date: Sun Mar 24 23:09:00 2024 +0100 Fixed persistent keepalive for networkd configurer commit 37453982ab4c65848c9849aec54806b829072e91 Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:08:06 2024 -0400 update flake commit 68a0496bc7fa0770427d22bd25c6910b9144e9ab Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:07:59 2024 -0400 Update tests to use `subnets` in all connections commit 8c7f741b7f0549387abd96482010bc06b731a55c Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:07:31 2024 -0400 Add error message to parser for incorrectly configured subnets in connections commit 3e3a37fc0f5b232da4c4744d81981d68ccd93ffc Author: Matthew Salerno <m@salernosection.com> Date: Sun Mar 24 21:05:27 2024 -0400 Update disjoint test commit 1236e4e8f27c22e3e9d936dbbdcb1913b26b8c9c Author: Adam Stephens <adam@valkor.net> Date: Sun Mar 24 20:59:26 2024 -0400 Add disjointed meshes tests commit dadd5bf7205eddb0a17330426bcabdccd6923615 Author: Matthew Salerno <m@salernosection.com> Date: Wed Dec 13 22:01:16 2023 -0500 add tags to agenix-rekey provider commit 1d3184639a5a83f0633f2908cd3b66293a24d1d8 Author: Matthew Salerno <m@salernosection.com> Date: Mon Dec 11 22:09:45 2023 -0500 sneaky systemd issues with dev only commit c8fb5affe5802c133abe10a51b228bfd76e03147 Author: Matthew Salerno <m@salernosection.com> Date: Tue Dec 5 20:51:30 2023 -0500 wnlib is back commit 1e697eb859788c592a5e3606086180b72fd1e9f1 Author: Matthew Salerno <m@salernosection.com> Date: Sat Nov 11 22:09:26 2023 -0500 allow multiple devs for same subnet commit 45b70c90636eee57d49ebac348e345912be226da Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 18 16:04:49 2023 -0400 added manual ip tests and resulting fixes commit 3d49ebff29894fe58de97a07a02035bd6d9a2752 Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 18 11:49:58 2023 -0400 Added manual IP assignment tests commit bd52d85d2dc56b0933d958aa3ef4faa3113e356c Author: Matthew Salerno <m@salernosection.com> Date: Thu Sep 14 16:08:00 2023 -0400 Generalized ip assignment to take cidr or IP commit fd2b9ce77cf1492463413e8bc0a9797226f9ddd0 Author: Matthew Salerno <m@salernosection.com> Date: Thu Sep 14 13:50:11 2023 -0400 Generalized ip assignment to take cidr or IP commit 57f8e0e97463dec3e0da7f4b995ee89b92d36687 Author: Matthew Salerno <m@salernosection.com> Date: Wed Sep 13 18:38:42 2023 -0400 Fixed manual ipv4 assignment issue commit a24fffa753745d1d6285ae588ff29b374ea1f8d2 Author: Matthew Salerno <m@salernosection.com> Date: Mon Sep 11 13:44:11 2023 -0400 Update README.md with link to self commit dd9de47a84060004ec9c76ceb7e7ee4086438f73 Author: Matthew Salerno <m@salernosection.com> Date: Sat Sep 2 19:55:17 2023 -0400 fixed missing link commit e761330e9189d194018ec2e3bd314d015b3f5f38 Merge: bb8636d b658653 Author: Matthew Salerno <m@salernosection.com> Date: Sat Sep 2 19:54:29 2023 -0400 fixed missing link commit bb8636dd8d5841747cdb7e8da171aeb44534e4a6 Author: Matthew Salerno <m@salernosection.com> Date: Thu Aug 31 20:45:14 2023 -0400 Readme moved to wiki commit 86e300428b905843129d2785d01fdf4313334b93 Author: Matthew Salerno <m@salernosection.com> Date: Tue Aug 22 21:07:34 2023 -0400 Fixed a bug in allGroupEndpoints logic commit 9a5c773355c571b6dc005dd70b083775b00f106d Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 22:03:19 2023 -0400 oops, delete net.nix commit b97760e456dc471e33bab3844ab9d3dbd5cc5a73 Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:59:30 2023 -0400 fixup additional_ settings commit 753c0726630304113e5a6af75d97b4fcf0b45a90 Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:30:40 2023 -0400 change null test to test enable = false commit 690e13e902ef6515946baf882a470f00b54adefa Author: Matthew Salerno <m@salernosection.com> Date: Mon Aug 21 21:28:29 2023 -0400 add mailing list to readme
7 months ago
mergeIf = attr: key: if hasAttr key attr then {"${key}" = attr."${key}";} else {};
asIp = cidr: head (splitString "/" cidr);
isIpv6 = ip: builtins.match ".*:.*" ip != null;
isCidr = cidr: builtins.match ".*/.*" cidr != null;
asCidr' = ifv6: ifv4: ip: if (isCidr ip) then ip else if isIpv6 ip then ip+"/"+ifv6 else ip+"/"+ifv4;
asCidr = asCidr' "128" "32";
}