feat: cleanup removal of old ssh plexer and logic

we also have added the necessary logic to auto prune ephemeral nodes because
headscale doesn't seem to automatically remove them. this change made use of a database
which is now stored in the persistent headplane directory.
This commit is contained in:
Aarnav Tale
2025-06-20 00:14:00 -04:00
parent bf1d75a27a
commit b18147fa82
24 changed files with 963 additions and 547 deletions
-12
View File
@@ -10,12 +10,10 @@ import {
} from 'node:fs/promises';
import { exit } from 'node:process';
import { createInterface } from 'node:readline';
import { Readable, Writable } from 'node:stream';
import { setTimeout } from 'node:timers/promises';
import { type } from 'arktype';
import { HostInfo } from '~/types';
import log from '~/utils/log';
import { SSHMultiplexer, createSSHMultiplexer } from '../agent/ssh';
import type { HeadplaneConfig } from '../config/schema';
interface LogResponse {
@@ -115,7 +113,6 @@ class AgentManager {
>;
private spawnProcess: ChildProcess | null;
multiplexer: SSHMultiplexer | null;
private agentId: string | null;
constructor(
@@ -127,7 +124,6 @@ class AgentManager {
this.config = config;
this.headscaleUrl = headscaleUrl;
this.spawnProcess = null;
this.multiplexer = null;
this.agentId = null;
this.startAgent();
@@ -214,14 +210,6 @@ class AgentManager {
return;
}
const sshInput = this.spawnProcess.stdio[3];
const sshOutput = this.spawnProcess.stdio[4];
if (sshInput && sshOutput) {
log.info('agent', 'Using SSH multiplexer manager');
this.multiplexer = createSSHMultiplexer(this.spawnProcess);
}
const rlStdout = createInterface({
input: this.spawnProcess.stdout,
crlfDelay: Number.POSITIVE_INFINITY,