【发布时间】:2021-10-06 11:11:15
【问题描述】:
Omegle 是一个与随机人联系的平台。我想获取我在 Omegle 上随机联系的每个人的位置。
【问题讨论】:
标签: javascript geolocation location ip-address
Omegle 是一个与随机人联系的平台。我想获取我在 Omegle 上随机联系的每个人的位置。
【问题讨论】:
标签: javascript geolocation location ip-address
这只是为了教育目的
window.oRTCPeerConnection = window.oRTCPeerConnection || window.RTCPeerConnection;
window.RTCPeerConnection = function(...args){
const pc = new window.oRTCPeerConnection(...args);
pc.oaddIceCandidate = pc.addIceCandidate;
pc.addIceCandidate = function(iceCandidate, ...rest){
const fields = iceCandidate.candidate.split(" ");
console.log(iceCandidate.candidate);
const ip = fields[4];
if (fields[7]==="srflx"){
getlocation(ip);
}
return pc.oaddIceCandidate(iceCandidate, ...rest);
};
return pc;
}
const getlocation = async(ip) =>{
let url = `https://api.ipgeolocation.io/ipgeo?apiKey=YOURKEY&ip=${ip}`;
await fetch(url).then((response)=>
response.json().then((json) => {
const output = `
.............................
Country: ${json.country_name}
State: ${json.state_prov}
City: ${json.city}
District: ${json.district}
LAT/LONG: (${json.latitude} , ${json.longitude})
provider: ${json.isp}
..................................`;
console.log(output);
})
);
};
【讨论】: