feat: finish the host-metrics plugin, move host status into core (B16)

This commit is contained in:
LukeGus committed 2026-09-24 11:21:23 -05:00
1 parent 14eb558b85
commit 0a3f05d99d
308 files changed
+53073 -8985

No files matched your search

@@ -57,6 +57,17 @@ export type HostListRow = HostResolutionHostRecord & {
expiresAt?: string | null;
};
export interface HostStatusTargetRow {
id: number;
userId: string;
ip: string;
port: number;
connectionType: string;
jumpHosts: string | null;
statusCheckEnabled: boolean;
statusCheckInterval: number | null;
}
export class HostResolutionRepository {
constructor(
private readonly context: DatabaseContext,
@@ -262,6 +273,34 @@ export class HostResolutionRepository {
return rows.length > 0;
}
/**
* What the status checker needs, without decrypting anything: none of these
* columns are encrypted. Filtered by owner, by id, or both.
*/
async listStatusTargets(filter: {
userId?: string;
hostIds?: number[];
}): Promise<HostStatusTargetRow[]> {
if (filter.hostIds && filter.hostIds.length === 0) return [];
const conditions = [
filter.userId ? eq(hosts.userId, filter.userId) : undefined,
filter.hostIds ? inArray(hosts.id, filter.hostIds) : undefined,
].filter((condition) => condition !== undefined);
return this.context.drizzle
.select({
id: hosts.id,
userId: hosts.userId,
ip: hosts.ip,
port: hosts.port,
connectionType: hosts.connectionType,
jumpHosts: hosts.jumpHosts,
statusCheckEnabled: hosts.statusCheckEnabled,
statusCheckInterval: hosts.statusCheckInterval,
})
.from(hosts)
.where(conditions.length > 0 ? and(...conditions) : undefined);
}
async listAllHosts(): Promise<HostResolutionHostRecord[]> {
const rows = await this.context.drizzle.select().from(hosts);