Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
fix: 🐛 windows ip fix for vmWare
Browse files Browse the repository at this point in the history
  • Loading branch information
ahwelgemoed committed Mar 13, 2021
1 parent 4cbcee7 commit f9e22f1
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/renderer/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,20 @@ export function getAppDataPath() {
export function getWindowsIp() {
if (process.platform == "win32") {
const nets = networkInterfaces();
const { Ethernet } = nets;
if (!Ethernet) return "NO IP FOUND";
const foundIP = Ethernet.find((ips: any) => {
if (ips.family === "IPv4") {
return ips.address;
let address;
for (const key1 in nets) {
if (Object.prototype.hasOwnProperty.call(nets, key1)) {
const element1 = nets[key1];
for (const key2 in element1) {
if (Object.prototype.hasOwnProperty.call(element1, key2)) {
const element2 = element1[key2 as any];
if (element2.family === "IPv4") {
return (address = element2.address);
}
}
}
}
});
return foundIP && foundIP.address ? foundIP.address : "NO IP FOUND";
}
}
return "NO IP FOUND";
}

0 comments on commit f9e22f1

Please sign in to comment.