Fix terminal connections

This commit is contained in:
LukeGus
2025-09-30 23:15:57 -05:00
parent d59ecad24c
commit 75cca25393

View File

@@ -17,6 +17,7 @@ import type {
import { CONNECTION_STATES } from "../../types/index.js"; import { CONNECTION_STATES } from "../../types/index.js";
import { tunnelLogger } from "../utils/logger.js"; import { tunnelLogger } from "../utils/logger.js";
import { SystemCrypto } from "../utils/system-crypto.js"; import { SystemCrypto } from "../utils/system-crypto.js";
import { SimpleDBOps } from "../utils/simple-db-ops.js";
const app = express(); const app = express();
app.use( app.use(
@@ -490,15 +491,19 @@ async function connectSSHTunnel(
if (tunnelConfig.sourceCredentialId && tunnelConfig.sourceUserId) { if (tunnelConfig.sourceCredentialId && tunnelConfig.sourceUserId) {
try { try {
const credentials = await getDb() const credentials = await SimpleDBOps.select(
.select() getDb()
.from(sshCredentials) .select()
.where( .from(sshCredentials)
and( .where(
eq(sshCredentials.id, tunnelConfig.sourceCredentialId), and(
eq(sshCredentials.userId, tunnelConfig.sourceUserId), eq(sshCredentials.id, tunnelConfig.sourceCredentialId),
eq(sshCredentials.userId, tunnelConfig.sourceUserId),
),
), ),
); "ssh_credentials",
tunnelConfig.sourceUserId,
);
if (credentials.length > 0) { if (credentials.length > 0) {
const credential = credentials[0]; const credential = credentials[0];
@@ -564,15 +569,19 @@ async function connectSSHTunnel(
if (tunnelConfig.endpointCredentialId && tunnelConfig.endpointUserId) { if (tunnelConfig.endpointCredentialId && tunnelConfig.endpointUserId) {
try { try {
const credentials = await getDb() const credentials = await SimpleDBOps.select(
.select() getDb()
.from(sshCredentials) .select()
.where( .from(sshCredentials)
and( .where(
eq(sshCredentials.id, tunnelConfig.endpointCredentialId), and(
eq(sshCredentials.userId, tunnelConfig.endpointUserId), eq(sshCredentials.id, tunnelConfig.endpointCredentialId),
eq(sshCredentials.userId, tunnelConfig.endpointUserId),
),
), ),
); "ssh_credentials",
tunnelConfig.endpointUserId,
);
if (credentials.length > 0) { if (credentials.length > 0) {
const credential = credentials[0]; const credential = credentials[0];
@@ -990,15 +999,19 @@ async function killRemoteTunnelByMarker(
if (tunnelConfig.sourceCredentialId && tunnelConfig.sourceUserId) { if (tunnelConfig.sourceCredentialId && tunnelConfig.sourceUserId) {
try { try {
const credentials = await getDb() const credentials = await SimpleDBOps.select(
.select() getDb()
.from(sshCredentials) .select()
.where( .from(sshCredentials)
and( .where(
eq(sshCredentials.id, tunnelConfig.sourceCredentialId), and(
eq(sshCredentials.userId, tunnelConfig.sourceUserId), eq(sshCredentials.id, tunnelConfig.sourceCredentialId),
eq(sshCredentials.userId, tunnelConfig.sourceUserId),
),
), ),
); "ssh_credentials",
tunnelConfig.sourceUserId,
);
if (credentials.length > 0) { if (credentials.length > 0) {
const credential = credentials[0]; const credential = credentials[0];