Last active
May 4, 2024 17:19
-
-
Save leptoquark1/51a7836e67938606d391bf3600de5a89 to your computer and use it in GitHub Desktop.
NodeJS - Get relevant Local IP-Address to further determ subnet
This file contains hidden or 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
| function getLocalIpAddress() { | |
| return Object.values(os.networkInterfaces()) | |
| .flat() | |
| .filter(ifq => ifq.family === 'IPv4' && !ifq.internal && ifq.mac !== '00:00:00:00:00:00') | |
| .map(ifq => ({ address: ifq.address, cidr: ifq.cidr })); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment