fix: self-check may work correctly with multiple public IPs
Massimo Melina committed
Jul 23, 2026 at 20:26 UTC
60c5a04dc375d6dd32673eadb872472ebaeb437c
1 file changed
+4
-4
src/selfCheck.ts
+4
-4
@@ -6,11 +6,11 @@ import _ from 'lodash'
6
import { findDefined, haveTimeout } from './cross'
7
import { httpString } from './util-http'
8
9
-let selfChecking = false
9
+let activeSelfChecks = 0
10
11
const CHECK_URL = SPECIAL_URI + 'self-check'
12
export const selfCheckMiddleware: Middleware = (ctx, next) => {
13
- if (!selfChecking || !ctx.url.startsWith(CHECK_URL))
13
+ if (!activeSelfChecks || !ctx.url.startsWith(CHECK_URL))
14
return next()
15
ctx.body = 'HFS'
16
ctx.state.skipFilters = true
@@ -37,7 +37,7 @@ export async function selfCheck(url: string) {
37
const parsed = new URL(url)
38
const family = !isIP(parsed.hostname) ? undefined : isIPv6(parsed.hostname) ? 6 : 4
39
try {
40
- selfChecking = true
40
+ ++activeSelfChecks
41
for (const services of _.chunk(_.shuffle<PortScannerService>(prjInfo.selfCheckServices), 2)) {
42
try {
43
const results = await Promise.allSettled(services.map(async svc => {
@@ -66,7 +66,7 @@ export async function selfCheck(url: string) {
66
}
67
}
68
finally {
69
- selfChecking = false
69
+ --activeSelfChecks
70
}
71
72
function applySymbols(s?: string) {