fix: geo-filter was blocking ipv6 LAN requests
Massimo Melina committed
Oct 15, 2024 at 15:54 UTC
22b287b32557ce664ef5252af7c7278eccf251c7
3 files changed
+6
-5
src/cross.ts
+1
-1
@@ -381,7 +381,7 @@ export function isIpLocalHost(ip: string) {
381
}
382
383
export function isIpLan(ip: string) {
384
- return /^(?:10\..*|172\.(1[6-9]|2\d|3[01])\..*|192\.168\..*)$/.test(ip)
384
+ return /^(?:10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.|fe80::)/.test(ip)
385
}
386
387
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
})
@@ -277,7 +277,8 @@ export async function getServerStatus(includeSrv=true) {
277
278
const ignore = /^(lo|.*loopback.*|virtualbox.*|.*\(wsl\).*|llw\d|awdl\d|utun\d|anpi\d)$/i // avoid giving too much information
279
280
-const isLinkLocal = makeNetMatcher('169.254.0.0/16|FE80::/16')
280
+// AKA auto-ip https://en.wikipedia.org/wiki/Link-local_address
281
+const isLinkLocal = makeNetMatcher('169.254.0.0/16|FE80::/10')
282
283
export async function getIps(external=true) {
284
const only = { '0.0.0.0': 'IPv4', '::' : 'IPv6' }[listenInterface.get()] || ''
src/nat.ts
+1
-1
@@ -67,7 +67,7 @@ export const getNatInfo = debounceAsync(async () => {
67
const res = await haveTimeout(10_000, upnpClient.getGateway()).catch(() => null)
68
const status = await getServerStatus()
69
const mappings = res && await haveTimeout(5_000, upnpClient.getMappings()).catch(() => null)
70
- console.debug('mappings found', mappings?.map(x => x.description))
70
+ console.debug("mappings found", mappings?.map(x => x.description) || "none")
71
const localIps = await getIps(false)
72
const gatewayIp = await gatewayIpPromise
73
const localIp = res?.address || (gatewayIp ? _.maxBy(localIps, x => inCommon(x, gatewayIp)) : localIps[0])