fix: geo-filter was blocking ipv6 LAN requests
Massimo Melina committed
Oct 15, 2024 at 15:54 UTC
b1649f0e0cba92fb4c9bcbbdbb9561759956afd3
3 files changed
+6
-5
src/cross.ts
+1
-1
@@ -379,7 +379,7 @@ export function isIpLocalHost(ip: string) {
379
}
380
381
export function isIpLan(ip: string) {
382
- return /^(?:10\..*|172\.(1[6-9]|2\d|3[01])\..*|192\.168\..*)$/.test(ip)
382
+ return /^(?:10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.|fe80::)/.test(ip)
383
}
384
385
export function ipForUrl(ip: string) {
src/listen.ts
+4
-3
@@ -156,9 +156,9 @@ for (const cfg of httpsNeeds) {
156
return considerHttps()
157
// v is a path
158
httpsOptions[k] = ''
159
- unwatch = watchLoad(v, data => {
159
+ unwatch = watchLoad(v, async data => {
160
httpsOptions[k] = data
161
- considerHttps()
161
+ await considerHttps()
162
}, { immediateFirst: true }).unwatch
163
await considerHttps()
164
})
@@ -269,7 +269,8 @@ export async function getServerStatus(includeSrv=true) {
269
270
const ignore = /^(lo|.*loopback.*|virtualbox.*|.*\(wsl\).*|llw\d|awdl\d|utun\d|anpi\d)$/i // avoid giving too much information
271
272
-const isLinkLocal = makeNetMatcher('169.254.0.0/16|FE80::/16')
272
+// AKA auto-ip https://en.wikipedia.org/wiki/Link-local_address
273
+const isLinkLocal = makeNetMatcher('169.254.0.0/16|FE80::/10')
274
275
export async function getIps(external=true) {
276
const ips = onlyTruthy(Object.entries(networkInterfaces()).flatMap(([name, nets]) =>
src/nat.ts
+1
-1
@@ -66,7 +66,7 @@ export const getNatInfo = debounceAsync(async () => {
66
const res = await haveTimeout(10_000, upnpClient.getGateway()).catch(() => null)
67
const status = await getServerStatus()
68
const mappings = res && await haveTimeout(5_000, upnpClient.getMappings()).catch(() => null)
69
- console.debug('mappings found', mappings?.map(x => x.description))
69
+ console.debug("mappings found", mappings?.map(x => x.description) || "none")
70
const gatewayIp = res && try_(() => new URL(res.gateway.description).hostname, () => console.debug('unexpected upnp gw', res.gateway?.description))
71
|| await findGateway().catch(() => undefined)
72
const localIps = await getIps(false)