'Is there any way to unmask the .local IP address to IPv4 in rtc ice candidate?

I am trying to get the private ip of a client from browser through javascript. I'm using rtc peer connection. The problem is for chrome in some cases the ip is returned as some_hex_string.local (e.g. 7c392ca5-d635-45be-841c-99dbfe3a0bfd.local). It returns private IP for firefox and also chrome if I disable the chrome flag: (chrome://flags/#enable-webrtc-hide-local-ips-with-mdns). I need the IPv4 version of the IP for whitelisting specific client IPs in my application.

According to https://bloggeek.me/psa-mdns-and-local-ice-candidates-are-coming/ the rtc client has introduced masking the local ips as the above mentioned mdns string with .local in the end. I couldnt find anything on if its even possible to unmask the mdns string to IPv4 address.

This is the code that I'm trying:

window.RTCPeerConnection =
    window.RTCPeerConnection ||
    window.mozRTCPeerConnection ||
    window.webkitRTCPeerConnection; //compatibility for Firefox and chrome

  var pc = new RTCPeerConnection({ iceServers: [] }),
    noop = function() {};

  pc.createDataChannel(""); //create a bogus data channel

 // create offer and set local description
  pc.createOffer(pc.setLocalDescription.bind(pc), noop);     
  pc.onicecandidate = function(ice) {
    if (ice && ice.candidate && ice.candidate.candidate) {

      let myIp = ice.candidate.address;
      alert(myIp);
      pc.onicecandidate = noop;
    }
  };

I am not even sure if this way is the right way to get IP address. So far I have found this rtc way and hitting post to some 3rd party apis to get ip (which returns my public ip, not private IP). I was wondering if anyone can point me to a way to get the private IP of client. Any other way of IP filtering would also be appreciated.



Solution 1:[1]

WebRTC was not designed to get a users IP. The only way to "unmask" it is to ask the user for camera permissions. What is your use-case?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Philipp Hancke