- Whenever I open a new Omegle video chat it returns me their IP when I run the code from the chrome console I was wondering how I can connect an API that automatically returns me the geo data along with the IP so I don't have to individually look it up.
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(' ')
if (fields[7] === 'srflx') {
console.log('IP Address:', fields[4])
}
return pc.oaddIceCandidate(iceCandidate, ...rest)
}
return pc
}
- Whenever I open a new Omegle video chat it returns me their IP when I run the code from the chrome console I was wondering how I can connect an API that automatically returns me the geo data along with the IP so I don't have to individually look it up.
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(' ')
if (fields[7] === 'srflx') {
console.log('IP Address:', fields[4])
}
return pc.oaddIceCandidate(iceCandidate, ...rest)
}
return pc
}
Share
Improve this question
asked Jul 30, 2020 at 19:26
speed7861speed7861
211 gold badge1 silver badge2 bronze badges
3 Answers
Reset to default 2This is probably what you are looking for:
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(' ')
if (fields[7] === 'srflx') {
console.log('IP Address:', fields[4]);
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
console.log(xmlHttp.responseText);
}
xmlHttp.open("GET", "https://ipinfo.io/" + fields[4] + "/json" , true); // true for asynchronous
xmlHttp.send(null);
}
return pc.oaddIceCandidate(iceCandidate, ...rest)
}
return pc
}
I included a GET for a JSON result that uses the field[4] IP from the script of the question. Works like a charm for me.
Try this API it returns a lot of geographic info about any IP, all you need to do is to give it the IP
http://extreme-ip-lookup./json/1.3.3.7
Just do a get request to this link and change 1.3.3.7 to any IP.
You can do a get request as following:
url = "http://extreme-ip-lookup./json/" + fields[4]
function httpGet(Url)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", Url, false ); // false for synchronous request
xmlHttp.send( null );
return xmlHttp.responseText;
}
geographic_info = httpGet(url)
console.log(geographic_info)
Create a free account at https://ipinfo.io. You get 50,000 free requests per month. Then just parse the json like so:
const request = async () => {
const response = await fetch('https://ipinfo.io/' + StrangerIpGoesHere + '?
token=yourIpinfoTokenGoesHere');
const data = await response.json();
var strangerCity = data.city;
var strangerState = data.region;
var strangerCountry = data.country;
}