Chungus 2.0

This commit is contained in:
Owen
2025-10-10 11:27:15 -07:00
parent f64a477c3d
commit d92b87b7c8
224 changed files with 1507 additions and 1586 deletions

View File

@@ -4,9 +4,9 @@ import HttpCode from "@server/types/HttpCode";
import createHttpError from "http-errors";
import logger from "@server/logger";
import { fromError } from "zod-validation-error";
import { resolveExitNodes } from "@server/lib/exitNodes";
import config from "@server/lib/config";
import { resolveExitNodes } from "#dynamic/lib/exitNodes";
import { build } from "@server/build";
import config from "@server/lib/config";
// Define Zod schema for request validation
const getResolvedHostnameSchema = z.object({
@@ -36,7 +36,15 @@ export async function getResolvedHostname(
const { hostname, publicKey } = parsedParams.data;
const baseDomain = config.getRawPrivateConfig().app.base_domain;
const dashboardUrl = config.getRawConfig().app.dashboard_url;
// extract the domain removing the http and stuff
const baseDomain = dashboardUrl
? dashboardUrl
.replace("http://", "")
.replace("https://", "")
.split("/")[0]
: null;
// if the hostname ends with the base domain then send back a empty array
if (baseDomain && hostname.endsWith(baseDomain)) {
@@ -50,6 +58,13 @@ export async function getResolvedHostname(
publicKey
);
if (resourceExitNodes.length === 0) {
// no exit nodes found, return empty array to force local routing
return res.status(HttpCode.OK).send({
endpoints: [] // this should force to route locally
});
}
endpoints = resourceExitNodes.map((node) => node.endpoint);
}