refactor(backend): reorganize top-level layout

- ssh/ renamed to hosts/ (it covers SSH, RDP, VNC, Telnet, Docker, metrics)
- serial/serial.ts and guacamole/ moved inside hosts/
- dashboard.ts and homepage.ts moved to services/
- swagger.ts moved to utils/ with adjusted scan globs

Import paths and the generate:openapi script updated; ports and endpoints
unchanged.
This commit is contained in:
LukeGus
2026-07-16 04:29:26 -05:00
parent 5e7090542d
commit 8b6037b7ff
121 changed files with 66 additions and 58 deletions
+51
View File
@@ -0,0 +1,51 @@
import type { ProxyNode } from "../../types/index.js";
import type { SOCKS5Config } from "../utils/socks5-helper.js";
type JumpHostProxyConfig = {
useSocks5?: boolean | null;
socks5Host?: string | null;
socks5Port?: number | null;
socks5Username?: string | null;
socks5Password?: string | null;
socks5ProxyChain?: ProxyNode[] | string | null;
};
function parseProxyChain(value: JumpHostProxyConfig["socks5ProxyChain"]) {
if (Array.isArray(value)) {
return value;
}
if (typeof value !== "string" || value.length === 0) {
return [];
}
try {
const parsed = JSON.parse(value);
return Array.isArray(parsed) ? (parsed as ProxyNode[]) : [];
} catch {
return [];
}
}
export function getJumpHostSocks5Config(
firstHop: JumpHostProxyConfig | null | undefined,
fallbackConfig?: SOCKS5Config | null,
): SOCKS5Config | null {
if (!firstHop?.useSocks5) {
return fallbackConfig ?? null;
}
const socks5ProxyChain = parseProxyChain(firstHop.socks5ProxyChain);
if (!firstHop.socks5Host && socks5ProxyChain.length === 0) {
return fallbackConfig ?? null;
}
return {
useSocks5: true,
socks5Host: firstHop.socks5Host ?? undefined,
socks5Port: firstHop.socks5Port ?? undefined,
socks5Username: firstHop.socks5Username ?? undefined,
socks5Password: firstHop.socks5Password ?? undefined,
socks5ProxyChain,
};
}