mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-07-16 21:33:41 +00:00
refactor(ssh): single shared createConnectionLog helper
file-manager-log.ts becomes ssh/connection-log.ts; the copies in docker.ts and host-metrics-helpers.ts are gone.
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
createCurrentHostResolutionRepository,
|
||||
} from "../database/repositories/factory.js";
|
||||
import { createJumpHostChain } from "./jump-host-chain.js";
|
||||
import { createConnectionLog } from "./connection-log.js";
|
||||
import { DataCrypto } from "../utils/data-crypto.js";
|
||||
import { AuthManager } from "../utils/auth-manager.js";
|
||||
import type { AuthenticatedRequest } from "../../types/index.js";
|
||||
@@ -33,20 +34,6 @@ import { resolveSshConnectConfigHost } from "./ssh-dns.js";
|
||||
|
||||
const sshLogger = logger;
|
||||
|
||||
function createConnectionLog(
|
||||
type: "info" | "success" | "warning" | "error",
|
||||
stage: ConnectionStage,
|
||||
message: string,
|
||||
details?: Record<string, unknown>,
|
||||
): Omit<LogEntry, "id" | "timestamp"> {
|
||||
return {
|
||||
type,
|
||||
stage,
|
||||
message,
|
||||
details,
|
||||
};
|
||||
}
|
||||
|
||||
interface SSHSession {
|
||||
client: SSHClient;
|
||||
isConnected: boolean;
|
||||
|
||||
@@ -28,7 +28,7 @@ import {
|
||||
type HostTransferDeps,
|
||||
} from "./host-transfer.js";
|
||||
import { registerFileContentRoutes } from "./file-manager-content-routes.js";
|
||||
import { createConnectionLog } from "./file-manager-log.js";
|
||||
import { createConnectionLog } from "./connection-log.js";
|
||||
import { createJumpHostChain } from "./jump-host-chain.js";
|
||||
import { preparePrivateKeyForSSH2 } from "../utils/ssh-key-utils.js";
|
||||
import {
|
||||
|
||||
@@ -3,9 +3,9 @@ import { describe, it, expect, vi } from "vitest";
|
||||
import {
|
||||
supportsMetrics,
|
||||
isTcpPingEnabled,
|
||||
createConnectionLog,
|
||||
tcpPingThroughJumpHost,
|
||||
} from "./host-metrics-helpers.js";
|
||||
import { createConnectionLog } from "./connection-log.js";
|
||||
|
||||
describe("supportsMetrics", () => {
|
||||
it("supports plain ssh hosts", () => {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import type { LogEntry, ConnectionStage } from "../../types/connection-log.js";
|
||||
import type { Client } from "ssh2";
|
||||
|
||||
export type StatsCapableHost = {
|
||||
@@ -47,17 +46,3 @@ export function tcpPingThroughJumpHost(
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function createConnectionLog(
|
||||
type: "info" | "success" | "warning" | "error",
|
||||
stage: ConnectionStage,
|
||||
message: string,
|
||||
details?: Record<string, unknown>,
|
||||
): Omit<LogEntry, "id" | "timestamp"> {
|
||||
return {
|
||||
type,
|
||||
stage,
|
||||
message,
|
||||
details,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -47,11 +47,11 @@ import { AccessDeniedError } from "./managers/route-helpers.js";
|
||||
import type { ManagerHost } from "./managers/types.js";
|
||||
import { createJumpHostChain } from "./jump-host-chain.js";
|
||||
import {
|
||||
createConnectionLog,
|
||||
isTcpPingEnabled,
|
||||
supportsMetrics,
|
||||
tcpPingThroughJumpHost,
|
||||
} from "./host-metrics-helpers.js";
|
||||
import { createConnectionLog } from "./connection-log.js";
|
||||
import {
|
||||
cleanupMetricsSession,
|
||||
getSessionKey,
|
||||
|
||||
Reference in New Issue
Block a user