Fix local sites

This commit is contained in:
Owen
2025-07-17 14:35:09 -07:00
parent da7166a7ea
commit 330b28ad9c

View File

@@ -42,42 +42,68 @@ export async function traefikConfigProvider(
.from(exitNodes) .from(exitNodes)
.limit(1); .limit(1);
if (!exitNode) { if (exitNode) {
logger.error("No exit node found in the database"); currentExitNodeId = exitNode.exitNodeId;
return [];
} }
currentExitNodeId = exitNode.exitNodeId;
} }
} }
// Get the site(s) on this exit node let resourcesWithRelations;
const resourcesWithRelations = await tx if (currentExitNodeId) {
.select({ // Get the site(s) on this exit node
// Resource fields resourcesWithRelations = await tx
resourceId: resources.resourceId, .select({
fullDomain: resources.fullDomain, // Resource fields
ssl: resources.ssl, resourceId: resources.resourceId,
http: resources.http, fullDomain: resources.fullDomain,
proxyPort: resources.proxyPort, ssl: resources.ssl,
protocol: resources.protocol, http: resources.http,
subdomain: resources.subdomain, proxyPort: resources.proxyPort,
domainId: resources.domainId, protocol: resources.protocol,
// Site fields subdomain: resources.subdomain,
site: { domainId: resources.domainId,
siteId: sites.siteId, // Site fields
type: sites.type, site: {
subnet: sites.subnet, siteId: sites.siteId,
exitNodeId: sites.exitNodeId, type: sites.type,
}, subnet: sites.subnet,
enabled: resources.enabled, exitNodeId: sites.exitNodeId
stickySession: resources.stickySession, },
tlsServerName: resources.tlsServerName, enabled: resources.enabled,
setHostHeader: resources.setHostHeader stickySession: resources.stickySession,
}) tlsServerName: resources.tlsServerName,
.from(resources) setHostHeader: resources.setHostHeader
.innerJoin(sites, eq(sites.siteId, resources.siteId)) })
.where(eq(sites.exitNodeId, currentExitNodeId)); .from(resources)
.innerJoin(sites, eq(sites.siteId, resources.siteId))
.where(eq(sites.exitNodeId, currentExitNodeId));
} else {
resourcesWithRelations = await tx
.select({
// Resource fields
resourceId: resources.resourceId,
fullDomain: resources.fullDomain,
ssl: resources.ssl,
http: resources.http,
proxyPort: resources.proxyPort,
protocol: resources.protocol,
subdomain: resources.subdomain,
domainId: resources.domainId,
// Site fields
site: {
siteId: sites.siteId,
type: sites.type,
subnet: sites.subnet,
exitNodeId: sites.exitNodeId
},
enabled: resources.enabled,
stickySession: resources.stickySession,
tlsServerName: resources.tlsServerName,
setHostHeader: resources.setHostHeader
})
.from(resources)
.innerJoin(sites, eq(sites.siteId, resources.siteId));
}
// Get all resource IDs from the first query // Get all resource IDs from the first query
const resourceIds = resourcesWithRelations.map((r) => r.resourceId); const resourceIds = resourcesWithRelations.map((r) => r.resourceId);
@@ -284,7 +310,8 @@ export async function traefikConfigProvider(
} else if (site.type === "newt") { } else if (site.type === "newt") {
if ( if (
!target.internalPort || !target.internalPort ||
!target.method || !site.subnet !target.method ||
!site.subnet
) { ) {
return false; return false;
} }