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())
})();