mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-06 18:56:39 +00:00
Fix get config for gerbil
This commit is contained in:
@@ -2,8 +2,7 @@ import { Request, Response, NextFunction } from "express";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { sites, resources, targets, exitNodes } from "@server/db";
|
import { sites, resources, targets, exitNodes } from "@server/db";
|
||||||
import { db } from "@server/db";
|
import { db } from "@server/db";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq, isNotNull, and } from "drizzle-orm";
|
||||||
import response from "@server/lib/response";
|
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
@@ -105,13 +104,30 @@ export async function getConfig(
|
|||||||
const sitesRes = await db
|
const sitesRes = await db
|
||||||
.select()
|
.select()
|
||||||
.from(sites)
|
.from(sites)
|
||||||
.where(eq(sites.exitNodeId, exitNode[0].exitNodeId));
|
.where(
|
||||||
|
and(
|
||||||
|
eq(sites.exitNodeId, exitNode[0].exitNodeId),
|
||||||
|
isNotNull(sites.pubKey),
|
||||||
|
isNotNull(sites.subnet)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
const peers = await Promise.all(
|
let peers = await Promise.all(
|
||||||
sitesRes.map(async (site) => {
|
sitesRes.map(async (site) => {
|
||||||
|
if (site.type === "wireguard") {
|
||||||
|
return {
|
||||||
|
publicKey: site.pubKey,
|
||||||
|
allowedIps: await getAllowedIps(site.siteId)
|
||||||
|
};
|
||||||
|
} else if (site.type === "newt") {
|
||||||
|
return {
|
||||||
|
publicKey: site.pubKey,
|
||||||
|
allowedIps: [site.subnet!]
|
||||||
|
};
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
publicKey: site.pubKey,
|
publicKey: null,
|
||||||
allowedIps: await getAllowedIps(site.siteId)
|
allowedIps: []
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user