INNER CODE UNIT · TypeScript
buildTrustedProxies
laxamentumtech/audnexus · src/server.ts:55
async function buildTrustedProxies(): Promise<string[]> {
let cloudflareIps: string[] = []
try {
cloudflareIps = await getCloudflareIps()
} catch (err) {
console.warn('Failed to fetch Cloudflare IPs, using user-configured proxies only:', err)
}
// Merge user IPs with Cloudflare IPs, removing duplicates
return [...new Set([...userTrustedProxies, ...cloudflareIps])]
}
/**
* Check if an IP is in the trusted proxies list
* Supports both exact IP matches and CIDR ranges (e.g., "10.0.0.0/8")
*/
function isTrustedProxy(ip: string, trustedProxiesList: string[]): boolean {
try {
return ipRangeCheck(ip, trustedProxiesList)