function getLocalIP() { window.RTCPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
if (window.RTCPeerConnection) {
const pc = new RTCPeerConnection({iceServers: []});
pc.createDataChannel('');
pc.createOffer(pc.setLocalDescription.bind(pc), () => {});
pc.onicecandidate = (ice) => {
if (ice && ice.candidate && ice.candidate.candidate) {
const myIP = /([0-9]{1,3}(\.[0-9]{1,3}){3})/.exec(ice.candidate.candidate)[1];
console.log('My IP:', myIP);
pc.close();
}
};
}
}
getLocalIP();