mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-10 20:02:26 +00:00
Make utility subnet configurable
This commit is contained in:
@@ -301,6 +301,29 @@ export function isIpInCidr(ip: string, cidr: string): boolean {
|
||||
return ipBigInt >= range.start && ipBigInt <= range.end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if two CIDR ranges overlap
|
||||
* @param cidr1 First CIDR string
|
||||
* @param cidr2 Second CIDR string
|
||||
* @returns boolean indicating if the two CIDRs overlap
|
||||
*/
|
||||
export function doCidrsOverlap(cidr1: string, cidr2: string): boolean {
|
||||
const version1 = detectIpVersion(cidr1.split("/")[0]);
|
||||
const version2 = detectIpVersion(cidr2.split("/")[0]);
|
||||
if (version1 !== version2) {
|
||||
// Different IP versions cannot overlap
|
||||
return false;
|
||||
}
|
||||
const range1 = cidrToRange(cidr1);
|
||||
const range2 = cidrToRange(cidr2);
|
||||
|
||||
// Overlap if the ranges intersect
|
||||
return (
|
||||
range1.start <= range2.end &&
|
||||
range2.start <= range1.end
|
||||
);
|
||||
}
|
||||
|
||||
export async function getNextAvailableClientSubnet(
|
||||
orgId: string,
|
||||
transaction: Transaction | typeof db = db
|
||||
|
||||
@@ -255,11 +255,11 @@ export const configSchema = z
|
||||
orgs: z
|
||||
.object({
|
||||
block_size: z.number().positive().gt(0).optional().default(24),
|
||||
subnet_group: z.string().optional().default("100.90.128.0/24"),
|
||||
subnet_group: z.string().optional().default("100.90.128.0/20"),
|
||||
utility_subnet_group: z
|
||||
.string()
|
||||
.optional()
|
||||
.default("100.96.128.0/24") //just hardcode this for now as well
|
||||
.default("100.96.128.0/20") //just hardcode this for now as well
|
||||
})
|
||||
.optional()
|
||||
.default({
|
||||
|
||||
Reference in New Issue
Block a user