mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-26 23:06:37 +00:00
Able to connect multi site on olm - POC 1
This commit is contained in:
@@ -51,32 +51,32 @@ export async function getAllRelays(
|
||||
}
|
||||
}
|
||||
|
||||
// get the clients on each site and map them to the site
|
||||
const sitesAndClients = await Promise.all(sitesRes.map(async (site) => {
|
||||
const clientsRes = await db.select().from(clients).where(eq(clients.siteId, site.siteId));
|
||||
return {
|
||||
site,
|
||||
clients: clientsRes
|
||||
};
|
||||
}));
|
||||
// // get the clients on each site and map them to the site
|
||||
// const sitesAndClients = await Promise.all(sitesRes.map(async (site) => {
|
||||
// const clientsRes = await db.select().from(clients).where(eq(clients.siteId, site.siteId));
|
||||
// return {
|
||||
// site,
|
||||
// clients: clientsRes
|
||||
// };
|
||||
// }));
|
||||
|
||||
let mappings: { [key: string]: {
|
||||
destinationIp: string;
|
||||
destinationPort: number;
|
||||
} } = {};
|
||||
|
||||
for (const siteAndClients of sitesAndClients) {
|
||||
const { site, clients } = siteAndClients;
|
||||
for (const client of clients) {
|
||||
if (!client.endpoint || !site.endpoint || !site.subnet) {
|
||||
continue;
|
||||
}
|
||||
mappings[client.endpoint] = {
|
||||
destinationIp: site.subnet.split("/")[0],
|
||||
destinationPort: parseInt(site.endpoint.split(":")[1])
|
||||
};
|
||||
}
|
||||
}
|
||||
// for (const siteAndClients of sitesAndClients) {
|
||||
// const { site, clients } = siteAndClients;
|
||||
// for (const client of clients) {
|
||||
// if (!client.endpoint || !site.endpoint || !site.subnet) {
|
||||
// continue;
|
||||
// }
|
||||
// mappings[client.endpoint] = {
|
||||
// destinationIp: site.subnet.split("/")[0],
|
||||
// destinationPort: parseInt(site.endpoint.split(":")[1])
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
|
||||
return res.status(HttpCode.OK).send({ mappings });
|
||||
} catch (error) {
|
||||
|
||||
@@ -80,10 +80,10 @@ export async function updateHolePunch(
|
||||
.where(eq(clients.clientId, olm.clientId))
|
||||
.returning();
|
||||
|
||||
[site] = await db
|
||||
.select()
|
||||
.from(sites)
|
||||
.where(eq(sites.siteId, client.siteId));
|
||||
// [site] = await db
|
||||
// .select()
|
||||
// .from(sites)
|
||||
// .where(eq(sites.siteId, client.siteId));
|
||||
|
||||
} else if (newtId) {
|
||||
const { session, newt: newtSession } =
|
||||
|
||||
Reference in New Issue
Block a user