mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-14 00:09:55 +02:00
Use the right subnet
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user