zerotier-static-peers: add external devices

Allow the `zerotier-auto-accept` service to add external devices through
their respective `zerotierID`, or their `zerotierIP` in a stateless way.

This is useful to either add mobile phones, that can't be managed
through clan yet, or to add devices of other peoples clans, to connect
them together.
This commit is contained in:
a-kenji
2024-07-03 11:52:14 +02:00
committed by kenji
parent c34fa376f5
commit c4365c22a7

View File

@@ -30,6 +30,16 @@ in
default = [ config.clan.core.machineName ]; default = [ config.clan.core.machineName ];
description = "Hosts that should be excluded"; description = "Hosts that should be excluded";
}; };
networkIps = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
description = "Extra zerotier network Ips that should be accepted";
};
networkIds = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
description = "Extra zerotier network Ids that should be accepted";
};
}; };
config.systemd.services.zerotier-static-peers-autoaccept = config.systemd.services.zerotier-static-peers-autoaccept =
@@ -56,6 +66,7 @@ in
lib.nameValuePair (builtins.readFile fullPath) [ machine ] lib.nameValuePair (builtins.readFile fullPath) [ machine ]
) filteredMachines ) filteredMachines
); );
allHostIPs = config.clan.zerotier-static-peers.networkIps ++ hosts;
in in
lib.mkIf (config.clan.networking.zerotier.controller.enable) { lib.mkIf (config.clan.networking.zerotier.controller.enable) {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
@@ -65,7 +76,10 @@ in
#!/bin/sh #!/bin/sh
${lib.concatMapStringsSep "\n" (host: '' ${lib.concatMapStringsSep "\n" (host: ''
${config.clan.core.clanPkgs.zerotier-members}/bin/zerotier-members allow --member-ip ${host} ${config.clan.core.clanPkgs.zerotier-members}/bin/zerotier-members allow --member-ip ${host}
'') hosts} '') allHostIPs}
${lib.concatMapStringsSep "\n" (host: ''
${config.clan.core.clanPkgs.zerotier-members}/bin/zerotier-members allow ${host}
'') config.clan.zerotier-static-peers.networkIds}
''; '';
}; };