From f19fad431d26eae7314b786d3c71e3251d662330 Mon Sep 17 00:00:00 2001 From: Nils Ohlmeier Date: Mon, 7 Oct 2024 18:58:20 -0600 Subject: [PATCH] added check for CF Calls Anycast address --- app/utils/rxjs/getPacketLossStats$.ts | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/app/utils/rxjs/getPacketLossStats$.ts b/app/utils/rxjs/getPacketLossStats$.ts index 960b0afe..969f0eab 100644 --- a/app/utils/rxjs/getPacketLossStats$.ts +++ b/app/utils/rxjs/getPacketLossStats$.ts @@ -20,7 +20,42 @@ export function getPacketLossStats$( let inboundPacketsLost = 0 let outboundPacketsSent = 0 let outboundPacketsLost = 0 + let candidatePairID: any = undefined + let remoteCandidateID: any = undefined + let remoteAddress: any = undefined + // Is there a better way than iterating over all reports three times?! + newStatsReport.forEach((report) => { + console.log('Report type: ' + report.type) + if (report.type === 'transport') { + candidatePairID = report.selectedCandidatePairId + } + }) + if (candidatePairID !== undefined) { + newStatsReport.forEach((report) => { + if ( + report.type === 'candidate-pair' && + report.id === candidatePairID + ) { + remoteCandidateID = report.remoteCandidateId + } + }) + if (remoteCandidateID !== undefined) { + newStatsReport.forEach((report) => { + if ( + report.type === 'remote-candidate' && + report.id === remoteCandidateID + ) { + remoteAddress = report.address + } + }) + + if (remoteAddress !== undefined && remoteAddress !== '141.101.90.0') { + // TODO set a flag to indicate that it is not connect to the Calls + // anycast address (as expected) + } + } + } newStatsReport.forEach((report) => { const previous = previousStatsReport.get(report.id) if (!previous) return