Use the right subnet

This commit is contained in:
Owen
2026-08-13 09:37:56 -04:00
parent 96bfc66a94
commit e100645a00
+8 -1
View File
@@ -123,7 +123,12 @@ async function findClientByIp(ip: string): Promise<CachedClient> {
const [client] = await db
.select({ clientId: clients.clientId, userId: clients.userId })
.from(clients)
.where(eq(clients.exitNodeSubnet, `${ip}/32`))
.where(
eq(
clients.exitNodeSubnet,
`${ip}/${config.getRawConfig().gerbil.site_block_size}`
)
)
.limit(1);
const result: CachedClient = client || null;
@@ -323,6 +328,8 @@ async function resolveRequestUser(
return { user: null, virtualApiKeyId: null };
}
logger.debug(`AI gateway request from IP ${ip} (site-resource)`);
const exitNodeRanges = await getExitNodeRanges();
const inExitNodeRange = exitNodeRanges.some((range) =>
isIpInCidr(ip, range)