MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / checkPublicConnectivity

Function checkPublicConnectivity

src/utils/network-check.ts:140–152  ·  view source on GitHub ↗
(timeoutMs = DEFAULT_TIMEOUT_MS)

Source from the content-addressed store, hash-verified

138 * Result is returned as a structured diagnostic; never throws.
139 */
140export async function checkPublicConnectivity(timeoutMs = DEFAULT_TIMEOUT_MS): Promise<NetworkDiagnostic> {
141 const probes = await Promise.all(
142 PUBLIC_ENDPOINTS.map(e => probeEndpoint(e.url, e.label, timeoutMs)),
143 );
144 // "Internet" = can we reach Cloudflare 1.1.1.1? Other probes can be blocked
145 // by ISP without that meaning the machine is offline.
146 const cf = probes.find(p => p.endpoint === 'https://1.1.1.1');
147 let internet: 'ok' | 'blocked' | 'unknown' = 'unknown';
148 if (cf?.status === 'ok') internet = 'ok';
149 else if (cf?.status === 'dns_failed' || cf?.status === 'connection_refused') internet = 'blocked';
150 else if (probes.some(p => p.status === 'ok')) internet = 'ok'; // CF blocked but something works
151 return { internet, probes, timestamp: Date.now() };
152}
153
154/**
155 * Quick probe of local model backends. Used by startup banner so we can tell

Callers 1

runFullDiagnosticFunction · 0.85

Calls 1

probeEndpointFunction · 0.85

Tested by

no test coverage detected