myIP = {
let pc = new RTCPeerConnection({ iceServers: [] }),
np = function () {};
pc.createDataChannel("");
pc.createOffer(pc.setLocalDescription.bind(pc), np);
return new Promise((keep, drop) => {
pc.onicecandidate = (ice) =>{
var myIP = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/.exec(
ice?.candidate?.candidate ?? pc.localDescription.sdp
);
keep(myIP[1] || 'not available');
pc.onicecandidate = np;
}
})
}