mirror of
https://github.com/fosrl/pangolin.git
synced 2026-10-27 22:19:07 +01:00
Pull jit limit from org
This commit is contained in:
@@ -8,7 +8,8 @@ import {
|
||||
sites,
|
||||
clientSitesAssociationsCache,
|
||||
exitNodes,
|
||||
ExitNode
|
||||
ExitNode,
|
||||
orgs
|
||||
} from "@server/db";
|
||||
import { db } from "@server/db";
|
||||
import { eq, and, inArray } from "drizzle-orm";
|
||||
@@ -112,7 +113,12 @@ export async function updateHolePunch(
|
||||
destinations: destinations
|
||||
});
|
||||
} catch (error) {
|
||||
if (!(error instanceof Error && error.message === "Exit node not allowed")) {
|
||||
if (
|
||||
!(
|
||||
error instanceof Error &&
|
||||
error.message === "Exit node not allowed"
|
||||
)
|
||||
) {
|
||||
logger.error(error);
|
||||
}
|
||||
return next(
|
||||
@@ -460,7 +466,18 @@ async function handleClientEndpointChange(
|
||||
return;
|
||||
}
|
||||
|
||||
if (sitesWithNewtsToUpdate.length > 250) {
|
||||
const [org] = await db
|
||||
.select()
|
||||
.from(orgs)
|
||||
.where(eq(orgs.orgId, client.orgId))
|
||||
.limit(1);
|
||||
|
||||
if (!org) {
|
||||
logger.warn(`Client ${clientId} org not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (sitesWithNewtsToUpdate.length > org.settingsJitModeLimit) {
|
||||
logger.warn(
|
||||
`Client ${clientId} has ${sitesWithNewtsToUpdate.length} connected sites so the client will be in jit mode anyway, skipping endpoint updates`
|
||||
);
|
||||
|
||||
@@ -8,7 +8,8 @@ import {
|
||||
ExitNode,
|
||||
exitNodes,
|
||||
sites,
|
||||
clientSitesAssociationsCache
|
||||
clientSitesAssociationsCache,
|
||||
orgs
|
||||
} from "@server/db";
|
||||
import { olms } from "@server/db";
|
||||
import HttpCode from "@server/types/HttpCode";
|
||||
@@ -225,7 +226,23 @@ export async function getOlmToken(
|
||||
)
|
||||
.where(eq(clientSitesAssociationsCache.clientId, clientIdToUse!));
|
||||
|
||||
if (clientSites.length > 250 && build == "saas") {
|
||||
const [org] = await db
|
||||
.select()
|
||||
.from(orgs)
|
||||
.where(eq(orgs.orgId, orgIdToUse))
|
||||
.limit(1);
|
||||
|
||||
if (!org) {
|
||||
logger.warn(`Client ${clientIdToUse} org not found`);
|
||||
return next(
|
||||
createHttpError(
|
||||
HttpCode.INTERNAL_SERVER_ERROR,
|
||||
"Client's org not found"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (clientSites.length > org.settingsJitModeLimit && build == "saas") {
|
||||
// set all of the cache rows isJitMode to true
|
||||
await db
|
||||
.update(clientSitesAssociationsCache)
|
||||
|
||||
@@ -277,7 +277,7 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
|
||||
);
|
||||
|
||||
let jitMode = false;
|
||||
if (sitesCount > 250 && build == "saas") {
|
||||
if (sitesCount > org.settingsJitModeLimit && build == "saas") {
|
||||
// THIS IS THE MAX ON THE BUSINESS TIER
|
||||
// we have too many sites
|
||||
// If we have too many sites we need to drop into fully JIT mode by not sending any of the sites
|
||||
|
||||
@@ -5,7 +5,8 @@ import {
|
||||
exitNodes,
|
||||
Olm,
|
||||
sites,
|
||||
clientSitesAssociationsCache
|
||||
clientSitesAssociationsCache,
|
||||
orgs
|
||||
} from "@server/db";
|
||||
import { buildSiteConfigurationForOlmClient } from "./buildConfiguration";
|
||||
import { sendToClient } from "#dynamic/routers/ws";
|
||||
@@ -36,8 +37,19 @@ export async function sendOlmSyncMessage(olm: Olm, client: Client) {
|
||||
{ orgId: client.orgId }
|
||||
);
|
||||
|
||||
const [org] = await db
|
||||
.select()
|
||||
.from(orgs)
|
||||
.where(eq(orgs.orgId, client.orgId))
|
||||
.limit(1);
|
||||
|
||||
if (!org) {
|
||||
logger.warn(`Client ${client.clientId} org not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
let jitMode = false;
|
||||
if (sitesCount > 250 && build == "saas") {
|
||||
if (sitesCount > org.settingsJitModeLimit && build == "saas") {
|
||||
// THIS IS THE MAX ON THE BUSINESS TIER
|
||||
// we have too many sites
|
||||
// If we have too many sites we need to drop into fully JIT mode by not sending any of the sites
|
||||
|
||||
Reference in New Issue
Block a user