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