systeminformation
systeminformation copied to clipboard
si.networkInterfaces(cb) should contain gateway information
Is your feature request related to a problem? Please describe.
I implememted a network overview system using your library, but i noticed that the gateway information is not associated with the interfaces directly when calling si.networkInterfaces(cb)
.
Describe the solution you'd like
The json array returned by calling si.networkInterfaces(cb)
should contain an additional gateway
property.
@mkreuzmayr thank you for your suggestion. Not quite sure how you mean this, as gateway is part of the routing (and not necessarily part to the interface, or am I wrong?
@sebhildebrandt of course you are right, the default gateway is part of the routing, but it is also associated with an interface.
By calling the si.networkGatewayDefault(cb)
function you are only getting the address of one gateway. If there is a second connection with a different network, the information of the other default gateway is missing.
On windows the wmic class NICConfig
also provides default gateways associated with the interfaces.
@mkreuzmayr thank you, good point ... need to make some research here ...
Windows: do you mean this class: Win32_NetworkAdapterConfiguration
So basically wmic Win32_NetworkAdapterConfiguration get /value
Do you ave a good example output from a machine with 2 network interfaces where I can see what you mean here? For Linux / Darwin I need also to dig into getting this right ...
@sebhildebrandt i wired up an example network to show you.
The wmic command i used is wmic path Win32_NetworkAdapterConfiguration get Caption, IPAddress, DefaultIPGateway
.
I only specified Caption, IPAddress and DeafultIPGatway and disabed IPv6 for a less bloated output, but there is way more information in there.
Caption DefaultIPGateway IPAddress
[00000001] Intel(R) Dual Band Wireless-AC 8275 {"192.168.1.254"} {"192.168.1.250"}
... Removed unnecessary adapters in between
[00000011] Realtek USB GbE Family Controller {"192.168.123.254"} {"192.168.123.1"}
Parsing this into a JSON would not be that hard.
Did you ever think about using Powershell on windows? There is an easy way to convert PS-Objects to JSON.
Get-WmiObject Win32_NetworkAdapterConfiguration | Select-Object Caption, IPAddress, DefaultIPGateway | ConvertTo-Json
Using Powershell would not be a huge deal in my opinion, because you can specify the shell you want to use with exec()
as a parameter.
@mkreuzmayr thank you, awesome. I need to also find examples on linux and macOS ... will try to do that in the next days (if possible).
Powershell: yes, I am using powershell for multiple calls, so no problem at all.
Thank you once again! I will come back as soon as I have a first approach here...