correctly parse non-numeric ip addresses

correctly address mDNS addresses used to anonimize in desktop Chromium and Firefox
This commit is contained in:
Cat /dev/Nulo 2023-03-05 23:09:30 -03:00
parent ba63ef512c
commit 5079f05d5b

View file

@ -58,10 +58,12 @@
var pc = new RTCPeerConnection(servers, mediaConstraints);
function handleCandidate(candidate){
//match just the IP address
var ip_regex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/
var ip_addr = ip_regex.exec(candidate)[1];
if (!candidate) return
//https://datatracker.ietf.org/doc/html/rfc5245#section-15.1
console.debug(candidate)
const things = candidate.split(' ')
const ip_addr = things[4]
//remove duplicates
if(ip_dups[ip_addr] === undefined)
callback(ip_addr);
@ -71,7 +73,6 @@
//listen for candidate events
pc.onicecandidate = function(ice){
//skip non-candidate events
if(ice.candidate)
handleCandidate(ice.candidate.candidate);
@ -88,7 +89,7 @@
}, function(){});
//wait for a while to let everything done
// wait for a while to let everything done
setTimeout(function(){
//read candidate info from local description
var lines = pc.localDescription.sdp.split('\n');