RTCIceCandidate 不再返回 IP [英] RTCIceCandidate no longer returning IP
问题描述
刚刚注意到,仅在 Chrome 上,RTCIceCandidate 不再返回 IP,而是一个混淆的地址.
Just noticed that on Chrome only, RTCIceCandidate no longer returns an IP, but rather an obfuscated address.
RTCIceCandidate
address: "a5b3ef18-2e66-4e24-91d2-893b93bbc1c1.local"
candidate: "candidate:169888242 1 udp 2113937151 a5b3ef18-2e66-4e24-91d2-893b93bbc1c1.local 47871 typ host generation 0 ufrag 7dHv network-cost 999"
component: "rtp"
foundation: "169888242"
port: 47871
priority: 2113937151
protocol: "udp"
relatedAddress: null
relatedPort: null
sdpMLineIndex: 0
sdpMid: "0"
tcpType: ""
type: "host"
usernameFragment: "7dHv"
注意 RTCIceCanadate 的第一个属性是address",而ip"不再是这个对象的一部分.
以下代码确定浏览器的本地 IP 地址.仍在 MOZ 上工作.
The following code determines the local IP address of a browser. Still works on MOZ.
function discover()
{
try{
//Get Local IP
window.RTCPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection; //compatibility for firefox and chrome
if (pc)
pc.close();
pc = new RTCPeerConnection({iceServers:[]});
pc.onicecandidate = onIceCandidate;
pc.createDataChannel("");
pc.createOffer(pc.setLocalDescription.bind(pc), noop);
} catch (e)
{ console.log(e.message);}
}
function noop()
{
}
function onIceCandidate(ice)
{
console.log(ice.candidate);
if(!ice || !ice.candidate || !ice.candidate.candidate) return;
var my_ip = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/.exec(ice.candidate.candidate)[1];
this.onicecandidate = noop;
ip = my_ip.split(".")[0]+'.'+my_ip.split(".")[1]+'.'+my_ip.split(".")[2];
}
WebRTC 现在正式是一个支离破碎的标准了吗?MOZ 仍然将ip"列为 RTCIceCandidate 的成员,其中没有提到 Chrome 返回的地址"成员.
Is WebRTC officially now a fractured standard? MOZ still lists "ip" as a member of RTCIceCandidate, with no mention of the "address" member that Chrome returns.
有没有一种方法可以将 mDNS 地址反混淆为一个 IP 地址, 不会强迫用户搞乱他们不理解的浏览器设置?
Is there a way to de-obfusucate the mDNS address back to an ip address without forcing users to mess around with browser settings they don't uderstand?
推荐答案
Chrome 并未损坏,WebRTC 标准正在不断发展,以防止网站通过转移 WebRTC API 来收集本地地址.如果您使用此 hack 获取本地地址,则可能需要寻找其他方法.
Chrome is not broken, the WebRTC standard is evolving to prevent sites from collecting local addresses by diverting the WebRTC API. If you used this hack to obtain local addresses, you might need to find another approach.
以下是 Chromium 和
Here are the corresponding issues for Chromium and Firefox, and the current IETF draft for WebRTC mDNS candidates.
这篇关于RTCIceCandidate 不再返回 IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!