How to get geo data as a return from an ip on omegle?

speed7861 picture speed7861 · Jul 30, 2020 · Viewed 11.3k times · Source
  1. 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
}

Answer

Geronimo picture Geronimo · Jan 18, 2021

This 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.