mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-05 02:06:41 +00:00
Allow null exit node id as well
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import { db, exitNodes } from "@server/db";
|
import { db, exitNodes } from "@server/db";
|
||||||
import { and, eq, inArray } from "drizzle-orm";
|
import { and, eq, inArray, or, isNull } from "drizzle-orm";
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
import config from "@server/lib/config";
|
import config from "@server/lib/config";
|
||||||
@@ -48,62 +48,38 @@ export async function traefikConfigProvider(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let resourcesWithRelations;
|
// Get the site(s) on this exit node
|
||||||
if (currentExitNodeId) {
|
const resourcesWithRelations = await tx
|
||||||
// Get the site(s) on this exit node
|
.select({
|
||||||
resourcesWithRelations = await tx
|
// Resource fields
|
||||||
.select({
|
resourceId: resources.resourceId,
|
||||||
// Resource fields
|
fullDomain: resources.fullDomain,
|
||||||
resourceId: resources.resourceId,
|
ssl: resources.ssl,
|
||||||
fullDomain: resources.fullDomain,
|
http: resources.http,
|
||||||
ssl: resources.ssl,
|
proxyPort: resources.proxyPort,
|
||||||
http: resources.http,
|
protocol: resources.protocol,
|
||||||
proxyPort: resources.proxyPort,
|
subdomain: resources.subdomain,
|
||||||
protocol: resources.protocol,
|
domainId: resources.domainId,
|
||||||
subdomain: resources.subdomain,
|
// Site fields
|
||||||
domainId: resources.domainId,
|
site: {
|
||||||
// Site fields
|
siteId: sites.siteId,
|
||||||
site: {
|
type: sites.type,
|
||||||
siteId: sites.siteId,
|
subnet: sites.subnet,
|
||||||
type: sites.type,
|
exitNodeId: sites.exitNodeId
|
||||||
subnet: sites.subnet,
|
},
|
||||||
exitNodeId: sites.exitNodeId
|
enabled: resources.enabled,
|
||||||
},
|
stickySession: resources.stickySession,
|
||||||
enabled: resources.enabled,
|
tlsServerName: resources.tlsServerName,
|
||||||
stickySession: resources.stickySession,
|
setHostHeader: resources.setHostHeader
|
||||||
tlsServerName: resources.tlsServerName,
|
})
|
||||||
setHostHeader: resources.setHostHeader
|
.from(resources)
|
||||||
})
|
.innerJoin(sites, eq(sites.siteId, resources.siteId))
|
||||||
.from(resources)
|
.where(
|
||||||
.innerJoin(sites, eq(sites.siteId, resources.siteId))
|
or(
|
||||||
.where(eq(sites.exitNodeId, currentExitNodeId));
|
eq(sites.exitNodeId, currentExitNodeId),
|
||||||
} else {
|
isNull(sites.exitNodeId)
|
||||||
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user