authoravatarclover caruso<git@paperclover.net>2026-10-23 17:16:42-07:00
committeravatarclover caruso<git@paperclover.net>2026-10-24 19:01:23-07:00
logab54eeca0df96c59724bf78d5491bfe87b1a677d
treec996f5113ea0b1b02764ee17dcd93e2d92014d0c
parent819edbefbe5ce363a1bc53de796344792271d6bc
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

Unpublish the Knife web client

Clients reach the container's Knife over the mesh, which already holds a direct LAN path, so the signed-in web route has no user. Assisted-by: claude-opus-5.5

3 files changed, 0 insertions(+), 37 deletions(-)

nixos/knife-linux.nix-20
......@@ -15,30 +15,10 @@ let
1515 exec ${pkgs.podman}/bin/podman --root=${root}/containers/storage --runroot=/run/knife-linux/containers "$@"
1616 '';
1717 run = "${podman}/bin/knife-linux-podman";
18 web = "13773";
1918in
2019{
2120 environment.systemPackages = [ podman ];
2221
23 # Knife listens on the container's loopback; the router publishes this port behind
24 # Snow Globe sign-in, and Knife still requires its own paired session.
25 systemd.services.knife-linux-web = {
26 description = "Host port for the Knife web client";
27 wantedBy = [ "multi-user.target" "knife-linux.service" ];
28 bindsTo = [ "knife-linux.service" ];
29 after = [ "knife-linux.service" ];
30 serviceConfig = {
31 ExecStart = pkgs.writeShellScript "knife-linux-web" ''
32 pid=$(${run} inspect --format '{{.State.Pid}}' knife-linux)
33 exec ${pkgs.socat}/bin/socat TCP-LISTEN:${web},bind=127.0.0.1,fork,reuseaddr \
34 "EXEC:${pkgs.util-linux}/bin/nsenter --target=$pid --net ${pkgs.socat}/bin/socat STDIO TCP\:127.0.0.1\:3773"
35 '';
36 Restart = "always";
37 RestartSec = 5;
38 };
39 };
40 systemd.services.snowglobe-router.environment.SNOWGLOBE_KNIFE_PORT = web;
41
4222 systemd.services.knife-linux = {
4323 description = "The Knife Linux agent container";
4424 wantedBy = [ "multi-user.target" ];
tools/knife-linux.md-6
......@@ -17,12 +17,6 @@ agent. Image and unit changes apply at the next manual
1717last only until then, so add them to the Containerfile too. Devices cannot be
1818added to the running container.
1919
20`https://personal.knife.paperclover.net` serves the Knife web client behind Snow
21Globe sign-in for `infra-admin`. `knife-linux-web` relays host port 13773 into the
22container's loopback, so Knife still needs its own session: pair each browser
23once with `knife pair --label NAME` inside the container, then open the printed
24`/pair#token=…` path on that host.
25
2620| Container path | Host source |
2721| --- | --- |
2822| `/Volumes/Code` | the Mac VM's NFS export, `/srv/mac-studio-vm/sandbox` |
tools/router.py-11
......@@ -268,17 +268,6 @@ def render(token):
268268 route = routes.setdefault((listener, ""), {"upstreams": set(), "services": set()})
269269 route["upstreams"].add(upstream)
270270
271 knife_port = os.environ.get("SNOWGLOBE_KNIFE_PORT")
272 if knife_port is not None:
273 knife_host = "personal.knife." + os.environ["SNOWGLOBE_DOMAIN"]
274 if not knife_port.isdecimal() or not 1 <= int(knife_port) <= 65535 or not HOST.fullmatch(knife_host):
275 raise ValueError("invalid Knife route")
276 if (80, knife_host) in routes:
277 raise ValueError(f"Knife route conflicts with a Nomad service: {knife_host}")
278 routes[(80, knife_host)] = {"upstreams": {f"127.0.0.1:{int(knife_port)}"}, "services": {"knife-linux"},
279 "authRole": "infra-admin", "userHeader": None, "internal": False,
280 "realIp": False, "secureCookies": False}
281
282271 lines = []
283272 for (listener, host), route in sorted(routes.items()):
284273 if host: