0

I connected to the Kaspersky VPN and tried to get the ICE candidate via RTCPeerConnection in JavaScript using the code below.

I have used two different Wi-Fi connections such that the local IP allocated to the computer is different in each case and also the VPN's public IP address keeps changing automatically but the foundation value remains the same in every case.

Can anyone please help understand why the foundation does not change with a change in the IP address when on a VPN but is does change when not on a VPN and the local IP address changes?

According to RFC-5245, foundation is an identifier that is equivalent for two candidates that are of the same type, share the same base, and come from the same STUN server.

async function getLocalAddress(){
    const conn = new RTCPeerConnection();
    conn.createDataChannel('');
    const offer =  await conn.createOffer();
    await conn.setLocalDescription(offer);
    return new Promise(resolve =>  conn.onicecandidate = event => resolve(event));
}

(async () => {
    console.log(await getLocalAddress())
})();
A. Sinha
  • 2,666
  • 3
  • 26
  • 45
  • can you show the candidates? Given that you resolve on the first candidate it is not clear your code is working as intended... – Philipp Hancke Jul 24 '22 at 20:21
  • @PhilippHancke, I have updated my code snippet to print the candidate. Please let me know if other input concerning this question is needed. – A. Sinha Jul 24 '22 at 20:43

0 Answers0