@samitouri / QOSami-HFS / commits / 242fdd1b

admin/fs: link local ip first

Massimo Melina committed May 9, 2024 at 22:45 UTC 242fdd1b42048a9d3dd963372d04bc690f7feb71
1 file changed +6 -3
src/listen.ts
+6 -3
@@ -272,10 +272,13 @@ export async function getIps(external=true) {
272 ))
273 const e = external && defaultBaseUrl.externalIp
274 if (e && !ips.includes(e))
275 - ips.unshift(e)
275 + ips.push(e)
276 const noLinkLocal = ips.filter(x => !isLinkLocal(x))
277 - const ret = _.sortBy(noLinkLocal.length ? noLinkLocal : ips, isIPv6) // false=IPV4 comes first
278 - defaultBaseUrl.localIp = ret[0] || ''
277 + const ret = _.sortBy(noLinkLocal.length ? noLinkLocal : ips, [
278 + x => x !== defaultBaseUrl.localIp, // use the "nat" info to put best ip first
279 + isIPv6 // false=IPV4 comes first
280 + ])
281 + defaultBaseUrl.localIp ||= ret[0] || ''
282 return ret
283 }
284