Closed GerritKuilder closed 2 years ago
@GerritKuilder thank you for supporting the project!! I will have a look at it later today.
@GerritKuilder I made a first implementation but I am not sure about a good name for the function ... currently I have something like:
si.networkInterfaceIP()
which returns
{
iface: 'en0',
ip4: '192.168.1.102',
ip6: 'fd08:2a3e:62b8:2416:18d2:536a:823b:3718'
}
What do you think?
Sounds good, but rather than a new function what about adding it to si.osInfo() as this already has the hostname too? Or add the hostname to si.networkInterfaceIP? And then maybe loose the IP? si.networkInterface() This does identify the machine uniquely by netWorkInterface.
I am a bit too tired of thinking semantics about what is the best name is or if osInfo is a good place too.
I will have another bit of thinking tomorrow.
Thanks for your efforts sofar.
@GerritKuilder thank you! Appreciate all your ideas! Take your time.
Morning,
Not being a specialist in Discovery/cmdb [1] but running into it on a daily basis I would say that the mac address and hostname would be very useful addition in the si.networkInterface() (so without the IP). This would make it very easy to identify a device.
What do you think?
Rgeards,
Gerrit Kuilder
@GerritKuilder Hmmmm ... feels like this information should be in networkInterfaces()
. Would it make sense to just add a default: true/false
property in the networkInterfaces()
array? And then a simple filter would then bring up the wanted information (IP address, mac address, ...)
What do you think?
Hi Seb,
this is what I currently have:
const defaultIf = await si.networkInterfaceDefault()
const nwInterfaces = await si.networkInterfaces()
const myip = nwInterfaces.find(x => x.ifaceName === defaultIf)
I think it would be more userfriendly if we could do
const mydefault = await si.networkInterfaces('defaultInterFace')
Which would return the interface where default = true returning the required info with si.networkInterfaceDefault would be a breaking change, so that's not really an option.
Regards,
Gerrit Kuilder
@GerritKuilder this is a nice idea ... I will think of implementing it this way. Maybe I would make the parameter more flexible to allow several ways to get just the default interface e.g.
mydefault = await si.networkInterfaces('defaultInterFace')
mydefault = await si.networkInterfaces('default')
mydefault = await si.networkInterfaces(true)
mydefault = await si.networkInterfaces({default: true})
Would this make sense?
perfect
@GerritKuilder Version 5.11.0 just released, can you check it on your side?
I only implemmented the following parameter options:
mydefault = await si.networkInterfaces('defaultInterFace')
mydefault = await si.networkInterfaces('default')
which returns only the default interface (as an object). If this works on your side, I will close the issue.
const si = require('systeminformation')
start()
async function start() {
mydefault = await si.networkInterfaces('defaultInterFace')
console.log(mydefault)
mydefault = await si.networkInterfaces('default')
console.log(mydefault)
}
Result:
node index.js
{
iface: 'enp2s0',
ifaceName: 'enp2s0',
default: true,
ip4: '192.168.2.17',
ip4subnet: '255.255.255.0',
ip6: 'fe80::7e10:c9ff:fe50:1df9',
ip6subnet: 'ffff:ffff:ffff:ffff::',
mac: '7c:10:c9:50:1d:f9',
internal: false,
virtual: false,
operstate: 'up',
type: 'wired',
duplex: 'full',
mtu: 1500,
speed: 1000,
dhcp: false,
dnsSuffix: 'Unknown',
ieee8021xAuth: 'Not defined',
ieee8021xState: 'Disabled',
carrierChanges: 2
}
{
iface: 'enp2s0',
ifaceName: 'enp2s0',
default: true,
ip4: '192.168.2.17',
ip4subnet: '255.255.255.0',
ip6: 'fe80::7e10:c9ff:fe50:1df9',
ip6subnet: 'ffff:ffff:ffff:ffff::',
mac: '7c:10:c9:50:1d:f9',
internal: false,
virtual: false,
operstate: 'up',
type: 'wired',
duplex: 'full',
mtu: 1500,
speed: 1000,
dhcp: false,
dnsSuffix: 'Unknown',
ieee8021xAuth: 'Not defined',
ieee8021xState: 'Disabled',
carrierChanges: 2
}
Works perfect, Also tested on my raspberry pi. The first one is an asus pn51.
Let me know if you want more details.
@GerritKuilder thank you. closing it for now.
For the next major release I will make a brewing change here ... then networkInterfaceDefault()
will no longer give just a string, it will then give back what we now have with networkInterfaces('default')
. I guess this makes more sense then.
Is your feature request related to a problem? Please describe. It looks like I can only get the default ip number of a system through networkInterfaceDefault -> networkInterfaces and find the right one
Describe the solution you'd like
as the hostname is set in osInfo, it would be nice if it was available there
Describe alternatives you've considered https://www.npmjs.com/package/ip