From dca2a29865f263d07614ad90f6603623c110ddb3 Mon Sep 17 00:00:00 2001 From: Owen Date: Fri, 18 Jul 2025 11:32:07 -0700 Subject: [PATCH] Fix #1085 --- config/db/db.sqlite.bak | Bin 0 -> 323584 bytes server/routers/site/createSite.ts | 28 +++++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 config/db/db.sqlite.bak diff --git a/config/db/db.sqlite.bak b/config/db/db.sqlite.bak new file mode 100644 index 0000000000000000000000000000000000000000..9d0b3db301aba78725e447cb3c84bec1ae023b7a GIT binary patch literal 323584 zcmeI532+-(dfx#OBnW^2sDpwu94%YJnISRMLGX~onbFKZBq(vkYk178c2h+((T`-W zzy_wf!DEulni6N%E|;&^+1lEqTz0Z9$5))%#I^BJiJinwoV6?7*yT7*%C5CzdtJ5@ zyW%TryDIPN*WKtQ0129rW+eHK;?eJW*Y|$k_r0T=0GD2$QB5YTm-H>!ltuzwfnYH3 znj{4RferpW&%d45D8C3f3I03ixo&j15jg+O$J=;rTk`j)%yjavl7F83ljI*Je=qi> z$Z9y${>8Sr_B*X#Z~1b|sg}=aRfM5RK5qw33%p&14%)mlhVMXS0hpr5m}MQg&r|etM4Ao6XHFOLO!5 zdu3+kEU%==TP!b`Y}fRO&AoCxvBK8nO3_>_71^v@F00yxs7o!`dGq>4O_p3SOAC5w zTQ$^@R@HDaH}dMJk@nQY>0m(B6t-);Rpf5EN@K9nt4<%Q8RzQg?X$^n zs<$_I&~K^Cc2#q(q%gz1=<+M=%7xZW@`0I8Rur8XMjgX4O)2wn@L|{3yj)o;s)ZYD zuTEZ3HB6>0l=M2h$oQOQVUt{xfKtmO+>&=EN}9$BCO11*#`er;`u6LIaB6%!cyLAF z+LG1c8%$T%)q+fACoFb#rO87e>lSk2!R@liV5k^OcRj~(2O0^ZZt7qua7F8g*=||o z{OdUvZ*6LRF*ki}&I-(dyxnJ7TFg!57ISkGxh2UG<_CC0=hM>soV2nqNdd2wB-vs~ zvdP>`j>`(NQIHk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{E%R&cdTnkN>_`0ZBv1wmU z)LO{SxkrR5R#UF&JnMs>)kBIdw|jpW2r&hMr$AF-7EO!y|6dIxuRgG20vZAV5C8!X z009sH0T2KI5C8!X0D&iv!2V0Y2a|sk;9q!w00@8p2!H?xfB*=900@8p2!H?x zJP8DjwhkV?If3{8KM97#7(f67KmY_l00ck)1V8`;KmY_l;O+$I`G276?q!e*0w4ea zAOHd&00JNY0w4eaAOHd&@OTrz^Z&=&e$XBSKmY_l00ck)1V8`;KmY_l00f#Lfam|s eP(m3H009sH0T2KI5C8!X009sH0T6h+3H*O|2gm3D literal 0 HcmV?d00001 diff --git a/server/routers/site/createSite.ts b/server/routers/site/createSite.ts index 391b6234..60e34465 100644 --- a/server/routers/site/createSite.ts +++ b/server/routers/site/createSite.ts @@ -148,7 +148,7 @@ export async function createSite( ) ); } - + if (!isIpInCidr(address, org.subnet)) { return next( createHttpError( @@ -157,35 +157,45 @@ export async function createSite( ) ); } - + updatedAddress = `${address}/${org.subnet.split("/")[1]}`; // we want the block size of the whole org - + // make sure the subnet is unique const addressExistsSites = await db .select() .from(sites) - .where(eq(sites.address, updatedAddress)) + .where( + and( + eq(sites.address, updatedAddress), + eq(sites.orgId, orgId) + ) + ) .limit(1); - + if (addressExistsSites.length > 0) { return next( createHttpError( HttpCode.CONFLICT, - `Subnet ${subnet} already exists` + `Subnet ${updatedAddress} already exists in sites` ) ); } - + const addressExistsClients = await db .select() .from(clients) - .where(eq(clients.subnet, updatedAddress)) + .where( + and( + eq(clients.subnet, updatedAddress), + eq(clients.orgId, orgId) + ) + ) .limit(1); if (addressExistsClients.length > 0) { return next( createHttpError( HttpCode.CONFLICT, - `Subnet ${subnet} already exists` + `Subnet ${updatedAddress} already exists in clients` ) ); }