Add backward compatability

This commit is contained in:
Owen
2025-08-04 20:36:25 -07:00
parent 6b1808dab1
commit dcf530d237

View File

@@ -7,7 +7,8 @@ import {
Site, Site,
sites, sites,
clientSites, clientSites,
exitNodes exitNodes,
ExitNode
} from "@server/db"; } from "@server/db";
import { db } from "@server/db"; import { db } from "@server/db";
import { eq, and } from "drizzle-orm"; import { eq, and } from "drizzle-orm";
@@ -110,11 +111,20 @@ export async function updateHolePunch(
.where(eq(clients.clientId, olm.clientId)) .where(eq(clients.clientId, olm.clientId))
.returning(); .returning();
let exitNode: ExitNode | undefined;
if (publicKey) {
// Get the exit node by public key // Get the exit node by public key
const [exitNode] = await db [exitNode] = await db
.select() .select()
.from(exitNodes) .from(exitNodes)
.where(eq(exitNodes.publicKey, publicKey)); .where(eq(exitNodes.publicKey, publicKey));
} else {
// FOR BACKWARDS COMPATIBILITY IF GERBIL IS STILL =<1.1.0
[exitNode] = await db
.select()
.from(exitNodes)
.limit(1)
}
if (exitNode) { if (exitNode) {
// Get sites that are on this specific exit node and connected to this client // Get sites that are on this specific exit node and connected to this client