🌳
pt0/sharedF/isPrivateIpAI.mts
1export const isPrivateIp = (ip: string): boolean => {
2 if (!ip) return true
3 // IPv4 private ranges: 10.x.x.x, 172.16-31.x.x, 192.168.x.x, 127.x.x.x
4 if (/^(10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.|127\.)/.test(ip)) return true
5 // IPv6 loopback or link-local
6 if (ip === '::1' || ip.startsWith('fe80:') || ip.startsWith('fc') || ip.startsWith('fd')) return true
7 return false
8}