Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions iran_connectivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,17 @@ ${error.stderr || ''}`;
let score = 0;
if (results.sourcePing) score += 10;
if (results.sourcePort443) score += 10;
if (results.targetPing) score += 20;
if (results.port80) score += 20;
if (results.port443) score += 25;
if (results.port22) score += 7;
if (results.port53) score += 8;
if (results.tracerouteAvailable && results.tracerouteReachedTarget) score += 5;
if (results.mtrAvailable && results.mtrLossPercent !== null) {
if (results.mtrLossPercent <= 5) score += 5;
else if (results.mtrLossPercent <= 20) score += 2;
if (results.targetPing) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve TCP scoring when ICMP is blocked

Placing all target-side score terms behind if (results.targetPing) drops the score for hosts that block ICMP but still have reachable TCP services (80/443/22/53), even though those ports are explicitly tested just above. In ICMP-filtered networks this under-scores actually reachable targets and distorts ranking/selection output; applying a ping penalty is reasonable, but zeroing all target-port contributions is a functional regression.

Useful? React with 👍 / 👎.

score += 20;
if (results.port80) score += 20;
if (results.port443) score += 25;
if (results.port22) score += 7;
if (results.port53) score += 8;
if (results.tracerouteAvailable && results.tracerouteReachedTarget) score += 5;
if (results.mtrAvailable && results.mtrLossPercent !== null) {
if (results.mtrLossPercent <= 5) score += 5;
else if (results.mtrLossPercent <= 20) score += 2;
}
}
results.targetReachability = Math.min(
100,
Expand Down Expand Up @@ -305,23 +307,26 @@ ${error.stderr || ''}`;

const testResults = await this.runWithConcurrency(tasks, this.maxConcurrent);
testResults.filter(Boolean).forEach((result) => {
if (result.connectivityScore > 0) {
const isMtrPassed = result.stageResults?.mtr === 'passed';
const pingStats = result.targetPingStats || {};
const pingBadge = (pingStats.transmitted !== null && pingStats.received !== null)
? `{ping ${pingStats.received}/${pingStats.transmitted}}`
: '{ping N/A}';
const latencyBadge = pingStats.averageLatencyMs !== null
? `{latency ${pingStats.averageLatencyMs} ms}`
: '{latency N/A}';

if (isMtrPassed) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Fall back when MTR cannot run

This branch makes mtr a hard prerequisite for any successful path (stageResults.mtr must equal passed). In environments where mtr is missing or returns no parsable loss (which currently maps to unavailable/no-data), every candidate is forced into failedConnections even when ping and TCP checks succeed, so the analyzer can report zero viable providers due to tooling availability rather than network reachability. Consider gating on MTR only when the stage is actually available.

Useful? React with 👍 / 👎.

providerResults.successfulConnections.push(result);
if (!providerResults.bestConnection ||
result.connectivityScore > providerResults.bestConnection.connectivityScore) {
providerResults.bestConnection = result;
}
const pingStats = result.targetPingStats || {};
const pingBadge = (pingStats.transmitted !== null && pingStats.received !== null)
? `{ping ${pingStats.received}/${pingStats.transmitted}}`
: '{ping N/A}';
const latencyBadge = pingStats.averageLatencyMs !== null
? `{latency ${pingStats.averageLatencyMs} ms}`
: '{latency N/A}';
this.log(`✓ Connection path score ${result.ip} -> ${this.targetIp} (${result.connectivityScore}) ${pingBadge} ${latencyBadge}`, 'success');
this.log(`✓ Connection path score ${result.ip} -> ${this.targetIp} (${result.connectivityScore}) ${pingBadge} ${latencyBadge} {mtr ✓}`, 'success');
} else {
providerResults.failedConnections.push(result);
this.log(`✗ Connection path failed ${result.ip} -> ${this.targetIp}`, 'error');
const mtrState = result.stageResults?.mtr || 'skipped';
this.log(`✗ Connection path failed ${result.ip} -> ${this.targetIp} ${pingBadge} ${latencyBadge} {mtr ${mtrState}}`, 'error');
}
});

Expand Down
Loading