gpt4 book ai didi

webrtc - RTCIceCandidate不再返回IP

转载 作者:行者123 更新时间:2023-12-02 04:20:45 26 4
gpt4 key购买 nike

只是注意到,仅在Chrome上,RTCIceCandidate不再返回IP,而是一个模糊的地址。

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的第一个属性是“地址”,而“ip”不再是该对象的一部分。

以下代码确定浏览器的本地IP地址。仍适用于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返回的“address”成员。

有没有一种方法可以将mDNS地址反混淆为ip地址,而又不强制用户弄乱他们不理解的浏览器设置?

最佳答案

Chrome并未损坏,WebRTC标准正在发展,以通过转移WebRTC API来防止站点收集本地地址。如果您使用此技巧来获取本地地址,则可能需要寻找另一种方法。

这是ChromiumFirefox的相应问题,以及WebRTC mDNS候选对象的当前IETF draft

关于webrtc - RTCIceCandidate不再返回IP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56755747/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com