mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-14 16:30:15 +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
|
const [client] = await db
|
||||||
.select({ clientId: clients.clientId, userId: clients.userId })
|
.select({ clientId: clients.clientId, userId: clients.userId })
|
||||||
.from(clients)
|
.from(clients)
|
||||||
.where(eq(clients.exitNodeSubnet, `${ip}/32`))
|
.where(
|
||||||
|
eq(
|
||||||
|
clients.exitNodeSubnet,
|
||||||
|
`${ip}/${config.getRawConfig().gerbil.site_block_size}`
|
||||||
|
)
|
||||||
|
)
|
||||||
.limit(1);
|
.limit(1);
|
||||||
|
|
||||||
const result: CachedClient = client || null;
|
const result: CachedClient = client || null;
|
||||||
@@ -323,6 +328,8 @@ async function resolveRequestUser(
|
|||||||
return { user: null, virtualApiKeyId: null };
|
return { user: null, virtualApiKeyId: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.debug(`AI gateway request from IP ${ip} (site-resource)`);
|
||||||
|
|
||||||
const exitNodeRanges = await getExitNodeRanges();
|
const exitNodeRanges = await getExitNodeRanges();
|
||||||
const inExitNodeRange = exitNodeRanges.some((range) =>
|
const inExitNodeRange = exitNodeRanges.some((range) =>
|
||||||
isIpInCidr(ip, range)
|
isIpInCidr(ip, range)
|
||||||
|
|||||||
Reference in New Issue
Block a user