forked from clan/clan-core
Merge pull request 'zerotier-static-peers: filter out non existing Ip' (#1576) from kenji/clan-core:fix/static-zerotier into main
Reviewed-on: clan/clan-core#1576
This commit is contained in:
commit
510634bc04
@ -35,21 +35,26 @@ in
|
|||||||
|
|
||||||
config.systemd.services.zerotier-static-peers-autoaccept =
|
config.systemd.services.zerotier-static-peers-autoaccept =
|
||||||
let
|
let
|
||||||
machines = builtins.readDir machineDir;
|
|
||||||
zerotierIpMachinePath = machines: machineDir + machines + "/facts/zerotier-ip";
|
zerotierIpMachinePath = machines: machineDir + machines + "/facts/zerotier-ip";
|
||||||
|
networkIpsUnchecked = builtins.map (
|
||||||
|
machine:
|
||||||
|
let
|
||||||
|
fullPath = zerotierIpMachinePath machine;
|
||||||
|
in
|
||||||
|
if builtins.pathExists fullPath then machine else null
|
||||||
|
) machines;
|
||||||
|
networkIps = lib.filter (machine: machine != null) networkIpsUnchecked;
|
||||||
|
machinesWithIp = lib.filterAttrs (name: _: (lib.elem name networkIps)) machinesFileSet;
|
||||||
filteredMachines = lib.filterAttrs (
|
filteredMachines = lib.filterAttrs (
|
||||||
name: _: !(lib.elem name config.clan.zerotier-static-peers.excludeHosts)
|
name: _: !(lib.elem name config.clan.zerotier-static-peers.excludeHosts)
|
||||||
) machines;
|
) machinesWithIp;
|
||||||
hosts = lib.mapAttrsToList (host: _: host) (
|
hosts = lib.mapAttrsToList (host: _: host) (
|
||||||
lib.mapAttrs' (
|
lib.mapAttrs' (
|
||||||
machine: _:
|
machine: _:
|
||||||
let
|
let
|
||||||
fullPath = zerotierIpMachinePath machine;
|
fullPath = zerotierIpMachinePath machine;
|
||||||
in
|
in
|
||||||
if builtins.pathExists fullPath then
|
lib.nameValuePair (builtins.readFile fullPath) [ machine ]
|
||||||
lib.nameValuePair (builtins.readFile fullPath) [ machine ]
|
|
||||||
else
|
|
||||||
null
|
|
||||||
) filteredMachines
|
) filteredMachines
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
|
Loading…
Reference in New Issue
Block a user