Merge branch 'dev' of https://github.com/fosrl/pangolin into dev

This commit is contained in:
Milo Schwartz 2025-01-11 14:13:08 -05:00
commit 82192fa180
No known key found for this signature in database
12 changed files with 96 additions and 28 deletions

View file

@ -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(

View file

@ -72,6 +72,16 @@ export async function acceptInvite(
const { user, session } = await verifySession(req);
// at this point we know the user exists
if (!user) {
return next(
createHttpError(
HttpCode.UNAUTHORIZED,
"You must be logged in to accept an invite"
)
);
}
if (user && user.email !== existingInvite.email) {
return next(
createHttpError(