Peer to peer connection keepalive task

This commit is contained in:
Zuckerberg 2023-03-07 22:54:26 -07:00
parent aff5611cdb
commit 8b6bc354bd
3 changed files with 21 additions and 14 deletions

View File

@ -9,6 +9,7 @@ in
imports = [ imports = [
./hosts.nix ./hosts.nix
./pia-openvpn.nix ./pia-openvpn.nix
./ping.nix
./tailscale.nix ./tailscale.nix
./vpn.nix ./vpn.nix
./zerotier.nix ./zerotier.nix

View File

@ -3,6 +3,10 @@
with builtins; with builtins;
let let
# TODO: remove when all systems are updated to new enough nixpkgs
concatMapAttrs =
f: with lib; flip pipe [ (mapAttrs f) attrValues (foldl' mergeAttrs { }) ];
system = (import ../ssh.nix).system; system = (import ../ssh.nix).system;
# hostnames that resolve on clearnet for LUKS unlocking # hostnames that resolve on clearnet for LUKS unlocking
@ -18,13 +22,18 @@ let
ponyo = "cfamr6artx75qvt7ho3rrbsc7mkucmv5aawebwflsfuorusayacffryd.onion"; ponyo = "cfamr6artx75qvt7ho3rrbsc7mkucmv5aawebwflsfuorusayacffryd.onion";
s0 = "r3zvf7f2ppaeithzswigma46pajt3hqytmkg3rshgknbl3jbni455fqd.onion"; s0 = "r3zvf7f2ppaeithzswigma46pajt3hqytmkg3rshgknbl3jbni455fqd.onion";
}; };
in {
networking.hosts = { zerotierHosts = {
# some DNS providers filter local ip results from DNS request "s0.zt.neet.dev" = "172.30.145.180";
"172.30.145.180" = [ "s0.zt.neet.dev" ]; "ponyo.zt.neet.dev" = "172.30.109.9";
"172.30.109.9" = [ "ponyo.zt.neet.dev" ]; "ray.zt.neet.dev" = "172.30.189.212";
"172.30.189.212" = [ "ray.zt.neet.dev" ];
}; };
in {
# some DNS providers filter local ip results from DNS request
networking.hosts = concatMapAttrs (host: ip: {ip = [host];}) zerotierHosts;
# TODO only add if zerotier is enabled
keepalive-ping.hosts = attrNames zerotierHosts;
programs.ssh.knownHosts = { programs.ssh.knownHosts = {
liza = { liza = {
@ -95,12 +104,7 @@ in {
# prebuilt cmds for easy ssh LUKS unlock # prebuilt cmds for easy ssh LUKS unlock
environment.shellAliases = environment.shellAliases =
let concatMapAttrs (host: addr: {"unlock-over-tor_${host}" = "torsocks ssh root@${addr}";}) unlock-onion-hosts
# TODO: remove when all systems are updated to new enough nixpkgs //
concatMapAttrs = concatMapAttrs (host: addr: {"unlock_${host}" = "torsocks ssh root@${addr}";}) unlock-clearnet-hosts;
f: with lib; flip pipe [ (mapAttrs f) attrValues (foldl' mergeAttrs { }) ];
in
concatMapAttrs (host: addr: {"unlock-over-tor_${host}" = "torsocks ssh root@${addr}";}) unlock-onion-hosts
//
concatMapAttrs (host: addr: {"unlock_${host}" = "torsocks ssh root@${addr}";}) unlock-clearnet-hosts;
} }

View File

@ -4,6 +4,8 @@ let
cfg = config.services.zerotierone; cfg = config.services.zerotierone;
in { in {
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
keepalive-ping.enable = true;
services.zerotierone.joinNetworks = [ services.zerotierone.joinNetworks = [
"565799d8f6d654c0" "565799d8f6d654c0"
]; ];