mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-23 02:56:37 +00:00
Adjust build functions
This commit is contained in:
@@ -4,8 +4,10 @@ import {
|
|||||||
clientSitesAssociationsCache,
|
clientSitesAssociationsCache,
|
||||||
db,
|
db,
|
||||||
ExitNode,
|
ExitNode,
|
||||||
|
networks,
|
||||||
resources,
|
resources,
|
||||||
Site,
|
Site,
|
||||||
|
siteNetworks,
|
||||||
siteResources,
|
siteResources,
|
||||||
targetHealthCheck,
|
targetHealthCheck,
|
||||||
targets
|
targets
|
||||||
@@ -137,11 +139,14 @@ export async function buildClientConfigurationForNewtClient(
|
|||||||
// Filter out any null values from peers that didn't have an olm
|
// Filter out any null values from peers that didn't have an olm
|
||||||
const validPeers = peers.filter((peer) => peer !== null);
|
const validPeers = peers.filter((peer) => peer !== null);
|
||||||
|
|
||||||
// Get all enabled site resources for this site
|
// Get all enabled site resources for this site by joining through siteNetworks and networks
|
||||||
const allSiteResources = await db
|
const allSiteResources = await db
|
||||||
.select()
|
.select()
|
||||||
.from(siteResources)
|
.from(siteResources)
|
||||||
.where(eq(siteResources.siteId, siteId));
|
.innerJoin(networks, eq(siteResources.networkId, networks.networkId))
|
||||||
|
.innerJoin(siteNetworks, eq(networks.networkId, siteNetworks.networkId))
|
||||||
|
.where(eq(siteNetworks.siteId, siteId))
|
||||||
|
.then((rows) => rows.map((r) => r.siteResources));
|
||||||
|
|
||||||
const targetsToSend: SubnetProxyTarget[] = [];
|
const targetsToSend: SubnetProxyTarget[] = [];
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import {
|
|||||||
clientSitesAssociationsCache,
|
clientSitesAssociationsCache,
|
||||||
db,
|
db,
|
||||||
exitNodes,
|
exitNodes,
|
||||||
|
networks,
|
||||||
|
siteNetworks,
|
||||||
siteResources,
|
siteResources,
|
||||||
sites
|
sites
|
||||||
} from "@server/db";
|
} from "@server/db";
|
||||||
@@ -59,9 +61,17 @@ export async function buildSiteConfigurationForOlmClient(
|
|||||||
clientSiteResourcesAssociationsCache.siteResourceId
|
clientSiteResourcesAssociationsCache.siteResourceId
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
.innerJoin(
|
||||||
|
networks,
|
||||||
|
eq(siteResources.networkId, networks.networkId)
|
||||||
|
)
|
||||||
|
.innerJoin(
|
||||||
|
siteNetworks,
|
||||||
|
eq(networks.networkId, siteNetworks.networkId)
|
||||||
|
)
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
eq(siteResources.siteId, site.siteId),
|
eq(siteNetworks.siteId, site.siteId),
|
||||||
eq(
|
eq(
|
||||||
clientSiteResourcesAssociationsCache.clientId,
|
clientSiteResourcesAssociationsCache.clientId,
|
||||||
client.clientId
|
client.clientId
|
||||||
@@ -69,6 +79,7 @@ export async function buildSiteConfigurationForOlmClient(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
if (jitMode) {
|
if (jitMode) {
|
||||||
// Add site configuration to the array
|
// Add site configuration to the array
|
||||||
siteConfigurations.push({
|
siteConfigurations.push({
|
||||||
|
|||||||
Reference in New Issue
Block a user