mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-19 07:15:21 +00:00
Pull in the destination from the api
This commit is contained in:
@@ -780,9 +780,9 @@ async function syncAcmeCerts(acmeJsonPath: string): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
logger.debug(
|
||||
`acmeCertSync: cert for ${mainDomain} covers ${allDomains.size} domain(s): ${[...allDomains].join(", ")}`
|
||||
);
|
||||
// logger.debug(
|
||||
// `acmeCertSync: cert for ${mainDomain} covers ${allDomains.size} domain(s): ${[...allDomains].join(", ")}`
|
||||
// );
|
||||
|
||||
for (const domain of allDomains) {
|
||||
try {
|
||||
|
||||
@@ -38,10 +38,12 @@ export async function getBrowserTarget(
|
||||
|
||||
const { fullDomain } = parsed.data;
|
||||
|
||||
const [row] = await db
|
||||
logger.info(`Retrieving browser target for domain: ${fullDomain}`);
|
||||
|
||||
const [browserTarget] = await db
|
||||
.select({
|
||||
ip: browserGatewayTarget.destination,
|
||||
port: browserGatewayTarget.destinationPort
|
||||
destination: browserGatewayTarget.destination,
|
||||
destinationPort: browserGatewayTarget.destinationPort
|
||||
})
|
||||
.from(browserGatewayTarget)
|
||||
.innerJoin(
|
||||
@@ -51,7 +53,7 @@ export async function getBrowserTarget(
|
||||
.where(eq(resources.fullDomain, fullDomain))
|
||||
.limit(1);
|
||||
|
||||
if (!row) {
|
||||
if (!browserTarget) {
|
||||
return next(
|
||||
createHttpError(
|
||||
HttpCode.NOT_FOUND,
|
||||
@@ -61,7 +63,10 @@ export async function getBrowserTarget(
|
||||
}
|
||||
|
||||
return response<GetBrowserTargetResponse>(res, {
|
||||
data: { ip: row.ip, port: row.port },
|
||||
data: {
|
||||
ip: browserTarget.destination,
|
||||
port: browserTarget.destinationPort
|
||||
},
|
||||
success: true,
|
||||
error: false,
|
||||
message: "Browser target retrieved successfully",
|
||||
|
||||
@@ -223,9 +223,9 @@ export default function RdpClient({
|
||||
);
|
||||
}
|
||||
|
||||
const destination = target
|
||||
? `${target.ip}:${target.port}`
|
||||
: "";
|
||||
const destination = target ? `${target.ip}:${target.port}` : "";
|
||||
|
||||
console.log("Starting RDP session with destination:", destination);
|
||||
|
||||
const builder = userInteraction
|
||||
.configBuilder()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { headers } from "next/headers";
|
||||
import { internal } from "@app/lib/api";
|
||||
import { priv } from "@app/lib/api";
|
||||
import { AxiosResponse } from "axios";
|
||||
import { GetBrowserTargetResponse } from "@server/routers/resource";
|
||||
import RdpClient from "./RdpClient";
|
||||
@@ -19,11 +19,13 @@ export default async function RdpPage() {
|
||||
let error: string | null = null;
|
||||
|
||||
try {
|
||||
const res = await internal.get<AxiosResponse<GetBrowserTargetResponse>>(
|
||||
const res = await priv.get<AxiosResponse<GetBrowserTargetResponse>>(
|
||||
`/resource/browser-target?fullDomain=${encodeURIComponent(hostname)}`
|
||||
);
|
||||
target = res.data.data;
|
||||
} catch {
|
||||
console.log("Fetched browser target:", target);
|
||||
} catch (error) {
|
||||
console.error("Error fetching browser target:", error);
|
||||
error = "No resource found for this domain";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { headers } from "next/headers";
|
||||
import { internal } from "@app/lib/api";
|
||||
import { priv } from "@app/lib/api";
|
||||
import { AxiosResponse } from "axios";
|
||||
import { GetBrowserTargetResponse } from "@server/routers/resource";
|
||||
import SshClient from "./SshClient";
|
||||
@@ -19,11 +19,12 @@ export default async function SshPage() {
|
||||
let error: string | null = null;
|
||||
|
||||
try {
|
||||
const res = await internal.get<AxiosResponse<GetBrowserTargetResponse>>(
|
||||
const res = await priv.get<AxiosResponse<GetBrowserTargetResponse>>(
|
||||
`/resource/browser-target?fullDomain=${encodeURIComponent(hostname)}`
|
||||
);
|
||||
target = res.data.data;
|
||||
} catch {
|
||||
} catch (error) {
|
||||
console.error("Error fetching browser target:", error);
|
||||
error = "No resource found for this domain";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { headers } from "next/headers";
|
||||
import { internal } from "@app/lib/api";
|
||||
import { priv } from "@app/lib/api";
|
||||
import { AxiosResponse } from "axios";
|
||||
import { GetBrowserTargetResponse } from "@server/routers/resource";
|
||||
import VncClient from "./VncClient";
|
||||
@@ -19,11 +19,12 @@ export default async function VncPage() {
|
||||
let error: string | null = null;
|
||||
|
||||
try {
|
||||
const res = await internal.get<AxiosResponse<GetBrowserTargetResponse>>(
|
||||
const res = await priv.get<AxiosResponse<GetBrowserTargetResponse>>(
|
||||
`/resource/browser-target?fullDomain=${encodeURIComponent(hostname)}`
|
||||
);
|
||||
target = res.data.data;
|
||||
} catch {
|
||||
} catch (error) {
|
||||
console.error("Error fetching browser target:", error);
|
||||
error = "No resource found for this domain";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user