fix: add Pylon relay fallback to /probe/:id endpoint
The lightweight probe endpoint used by the dashboard for live status checks had no Pylon integration. When DNS2 (Singapore) tried to probe home network services directly, all probes timed out with 502. Now falls back to the configured Pylon relay before the domain fallback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -487,6 +487,28 @@ async function createApp() {
|
||||
statusCode = await makeRequest('GET');
|
||||
}
|
||||
} catch {
|
||||
// Direct probe failed — try Pylon relay if configured
|
||||
const pylonConfig = config.siteConfig?.pylon;
|
||||
if (pylonConfig?.url) {
|
||||
try {
|
||||
const pylonUrl = `${pylonConfig.url}/probe?url=${encodeURIComponent(url)}`;
|
||||
const headers = { 'User-Agent': APP.USER_AGENTS.PROBE };
|
||||
if (pylonConfig.key) headers['x-pylon-key'] = pylonConfig.key;
|
||||
const controller = new AbortController();
|
||||
const pylonTimeout = setTimeout(() => controller.abort(), 8000);
|
||||
const pylonRes = await fetchT(pylonUrl, { method: 'GET', signal: controller.signal, headers });
|
||||
clearTimeout(pylonTimeout);
|
||||
if (pylonRes.ok) {
|
||||
const data = await pylonRes.json();
|
||||
statusCode = data.statusCode || 502;
|
||||
}
|
||||
} catch {
|
||||
// Pylon also failed — fall through to domain fallback
|
||||
}
|
||||
}
|
||||
|
||||
// Domain-based fallback (last resort)
|
||||
if (!statusCode) {
|
||||
const fallbackUrl = `https://${config.buildDomain(id)}`;
|
||||
const fp = new URL(fallbackUrl);
|
||||
statusCode = await new Promise((resolve, reject) => {
|
||||
@@ -505,7 +527,8 @@ async function createApp() {
|
||||
fReq.on('error', reject);
|
||||
fReq.on('timeout', () => { fReq.destroy(); reject(new Error('Timeout')); });
|
||||
fReq.end();
|
||||
});
|
||||
}).catch(() => 502);
|
||||
}
|
||||
}
|
||||
|
||||
res.status(statusCode).send();
|
||||
|
||||
Reference in New Issue
Block a user