syncthing: automatically add zt network ip to devices
This commit is contained in:
@@ -18,11 +18,28 @@ let
|
|||||||
if builtins.pathExists fullPath then machine else null
|
if builtins.pathExists fullPath then machine else null
|
||||||
) machines;
|
) machines;
|
||||||
syncthingPublicKeyMachines = lib.filter (machine: machine != null) syncthingPublicKeysUnchecked;
|
syncthingPublicKeyMachines = lib.filter (machine: machine != null) syncthingPublicKeysUnchecked;
|
||||||
|
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;
|
||||||
|
networkIpMachines = lib.filter (machine: machine != null) networkIpsUnchecked;
|
||||||
devices = builtins.map (machine: {
|
devices = builtins.map (machine: {
|
||||||
name = machine;
|
name = machine;
|
||||||
value = {
|
value = {
|
||||||
name = machine;
|
name = machine;
|
||||||
id = (lib.removeSuffix "\n" (builtins.readFile (syncthingPublicKeyPath machine)));
|
id = (lib.removeSuffix "\n" (builtins.readFile (syncthingPublicKeyPath machine)));
|
||||||
|
addresses =
|
||||||
|
[ "dynamic" ]
|
||||||
|
++ (
|
||||||
|
if (lib.elem machine networkIpMachines) then
|
||||||
|
[ "tcp://[${(lib.removeSuffix "\n" (builtins.readFile (zerotierIpMachinePath machine)))}]:22000" ]
|
||||||
|
else
|
||||||
|
[ ]
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}) syncthingPublicKeyMachines;
|
}) syncthingPublicKeyMachines;
|
||||||
in
|
in
|
||||||
|
|||||||
Reference in New Issue
Block a user