-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
31 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import getLocalIPV4 from "@src/getLocalIPV4" | ||
|
||
describe("getLocalIPV4", () => { | ||
test("it works normal", () => { | ||
expect(getLocalIPV4()).toBeTypeOf("string") | ||
expect(getLocalIPV4().split(".").length).toEqual(4) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import os from "os" | ||
|
||
export default function getLocalIPV4() { | ||
const interfaces = os.networkInterfaces() | ||
let IPAdress = ''; | ||
for (let devName in interfaces) { | ||
let iface = interfaces[devName]; | ||
if (iface) { | ||
for (let i = 0; i < iface.length; i++) { | ||
let alias = iface[i]; | ||
if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) { | ||
IPAdress = alias.address; | ||
} | ||
} | ||
} | ||
} | ||
return IPAdress | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import getLocalIp from "./getLocalIp" | ||
import getLocalIp from "./getLocalIPV4" | ||
|
||
export default { | ||
getLocalIp | ||
|