mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-12-04 11:36:20 +01:00
fix(ssh,ai): keep connections to idle LAN peers fast (#463)
* fix(ssh): retry and multiplex LAN connections * fix(ai): shrink the neighbour-probe fallback to ~1s Assisted-by: DeepSeek Harness 0.2.0-rc.2 (deepseek-flash)
This commit is contained in:
1 parent
3266aad4a2
commit
a0ff9f7fd7
4 files changed
+77
-15
No files matched your search
+38
-15
@@ -3,8 +3,26 @@
|
||||
lib,
|
||||
pkgs,
|
||||
mysecrets,
|
||||
myvars,
|
||||
...
|
||||
}:
|
||||
let
|
||||
# WA-035: settings for the home LAN, which the desktop reaches over a Mesh
|
||||
# WiFi backhaul.
|
||||
lanHost = {
|
||||
# A lost first SYN must not fail the connection; a LAN handshake is ~2 ms,
|
||||
# so the connect is cut short and retried instead of hanging.
|
||||
ConnectTimeout = 1;
|
||||
ConnectionAttempts = 3;
|
||||
# One persistent master per host keeps a session (and with it the mesh's
|
||||
# forwarding entry for that peer) open, so later connections reuse it
|
||||
# instead of resolving and handshaking again. Three missed keepalives reap a
|
||||
# master whose path died.
|
||||
ControlMaster = "auto";
|
||||
ControlPersist = "30m";
|
||||
ServerAliveInterval = 15;
|
||||
};
|
||||
in
|
||||
{
|
||||
home.file.".ssh/romantic.pub".source = "${mysecrets}/public/romantic.pub";
|
||||
|
||||
@@ -12,20 +30,23 @@
|
||||
enable = true;
|
||||
|
||||
enableDefaultConfig = false;
|
||||
settings."*" = {
|
||||
ForwardAgent = false;
|
||||
AddKeysToAgent = "yes";
|
||||
Compression = true;
|
||||
ServerAliveInterval = 0;
|
||||
ServerAliveCountMax = 3;
|
||||
HashKnownHosts = false;
|
||||
UserKnownHostsFile = "~/.ssh/known_hosts";
|
||||
ControlMaster = "no";
|
||||
ControlPath = "~/.ssh/master-%r@%n:%p";
|
||||
ControlPersist = "no";
|
||||
};
|
||||
|
||||
# Keep this one definition: Nix merges a `settings."<pattern>"` attribute
|
||||
# path into `settings = ...` only while that value stays an attrset literal,
|
||||
# so the generated LAN patterns are merged inside it with `//` instead.
|
||||
settings = {
|
||||
"*" = {
|
||||
ForwardAgent = false;
|
||||
AddKeysToAgent = "yes";
|
||||
Compression = true;
|
||||
ServerAliveInterval = 0;
|
||||
ServerAliveCountMax = 3;
|
||||
HashKnownHosts = false;
|
||||
UserKnownHostsFile = "~/.ssh/known_hosts";
|
||||
ControlMaster = "no";
|
||||
ControlPath = "~/.ssh/master-%r@%n:%p";
|
||||
ControlPersist = "no";
|
||||
};
|
||||
|
||||
"github.com" = {
|
||||
# WA-028: pinned to IPv4 until the mihomo v6 fake-ip pool is proven here
|
||||
AddressFamily = "inet";
|
||||
@@ -37,8 +58,10 @@
|
||||
|
||||
"192.168.*" = {
|
||||
ForwardAgent = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
// lanHost;
|
||||
}
|
||||
// lib.genAttrs (builtins.attrNames myvars.networking.hostsAddr) (_: lanHost);
|
||||
};
|
||||
|
||||
# Keep ~/.ssh/config a real, user-owned file rather than a /nix/store symlink.
|
||||
|
||||
Reference in new issue
Block a user