Handle the alias create and update special case exit nodes

This commit is contained in:
Owen
2026-07-31 17:22:08 -04:00
parent 104dcebda7
commit 9e10428640
3 changed files with 90 additions and 7 deletions
@@ -29,7 +29,7 @@ import response from "@server/lib/response";
import logger from "@server/logger";
import { OpenAPITags, registry } from "@server/openApi";
import HttpCode from "@server/types/HttpCode";
import { and, eq, inArray } from "drizzle-orm";
import { and, eq, inArray, ne } from "drizzle-orm";
import { NextFunction, Request, Response } from "express";
import createHttpError from "http-errors";
import { z } from "zod";
@@ -490,7 +490,11 @@ export async function createSiteResource(
.where(
and(
eq(siteResources.orgId, orgId),
eq(siteResources.alias, alias.trim())
eq(siteResources.alias, alias.trim()),
ne(
siteResources.requiresExitNodeConnection,
mode == "inference"
) // exclude looking at the ones on exit nodes if this is an inference resource
)
)
.limit(1);
@@ -527,6 +531,7 @@ export async function createSiteResource(
let aliasAddress: string | null = null;
let releaseAliasLock: (() => Promise<void>) | null = null;
if (mode === "host" || mode === "http" || mode === "ssh") {
// no alias address but we do have an alias for inference
const { value, release } =
await getNextAvailableAliasAddress(orgId);
aliasAddress = value;
@@ -507,7 +507,11 @@ export async function updateSiteResource(
and(
eq(siteResources.orgId, existingSiteResource.orgId),
eq(siteResources.alias, alias.trim()),
ne(siteResources.siteResourceId, siteResourceId) // exclude self
ne(siteResources.siteResourceId, siteResourceId), // exclude self
ne(
siteResources.requiresExitNodeConnection,
mode == "inference"
) // exclude looking at the ones on exit nodes if this is an inference resource
)
)
.limit(1);
@@ -587,8 +591,7 @@ export async function updateSiteResource(
domainId,
subdomain: finalSubdomain,
fullDomain,
networkId:
mode === "inference" ? null : undefined,
networkId: mode === "inference" ? null : undefined,
requiresExitNodeConnection:
mode !== undefined ? mode === "inference" : undefined,
...sshPamSet