correctly parse non-numeric ip addresses
correctly address mDNS addresses used to anonimize in desktop Chromium and Firefox
This commit is contained in:
parent
ba63ef512c
commit
5079f05d5b
1 changed files with 7 additions and 6 deletions
13
index.html
13
index.html
|
@ -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');
|
||||
|
|
Loading…
Reference in a new issue