mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-03 17:44:44 +02:00
Add site_block_size
and migration for beta.3
This commit is contained in:
parent
484a099ee3
commit
38544cc2d6
7 changed files with 53 additions and 23 deletions
|
@ -8,6 +8,7 @@ import createHttpError from "http-errors";
|
|||
import logger from "@server/logger";
|
||||
import { findNextAvailableCidr } from "@server/lib/ip";
|
||||
import { generateId } from "@server/auth/sessions/app";
|
||||
import config from "@server/lib/config";
|
||||
|
||||
export type PickSiteDefaultsResponse = {
|
||||
exitNodeId: number;
|
||||
|
@ -51,9 +52,9 @@ export async function pickSiteDefaults(
|
|||
|
||||
// TODO: we need to lock this subnet for some time so someone else does not take it
|
||||
let subnets = sitesQuery.map((site) => site.subnet);
|
||||
// exclude the exit node address by replacing after the / with a /28
|
||||
subnets.push(exitNode.address.replace(/\/\d+$/, "/29"));
|
||||
const newSubnet = findNextAvailableCidr(subnets, 29, exitNode.address);
|
||||
// exclude the exit node address by replacing after the / with a site block size
|
||||
subnets.push(exitNode.address.replace(/\/\d+$/, `/${config.getRawConfig().gerbil.site_block_size}`));
|
||||
const newSubnet = findNextAvailableCidr(subnets, config.getRawConfig().gerbil.site_block_size, exitNode.address);
|
||||
if (!newSubnet) {
|
||||
return next(
|
||||
createHttpError(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue