sebhildebrandt / systeminformation

System Information Library for Node.JS
MIT License
2.74k stars 311 forks source link

Not all interfaces shown (docking station) #762

Open tomas-reznak opened 1 year ago

tomas-reznak commented 1 year ago

Describe the bug

When trying to get list of all network interfaces on the laptop, si.networkInterfaces(cb) doesn't return all of them. I know about older similar issues, but this is some kind of special behavior which could be investigated.

To Reproduce

My laptop uses:

  1. default internal network interface (named Ethernet)
  2. docking station interface (named Ethernet HP Docking)
  3. Wi-Fi, Bluetooth, Loopback interfaces - skipped for simplicity

When internal interface is set as Disabled (via Windows Control Panel), si.networkInterfaces(cb) returns both interfaces correctly.

image

When internal interface is set as Enabled, si.networkInterfaces(cb) returns this interface only.

image

Current Output

When internal network interface is set as Enabled, it returns just this interface:

[
    {
        "iface": "Ethernet",
        "ifaceName": "Intel(R) Ethernet Connection (10) I219-LM",
        "default": false,
        "ip4": "",
        "ip4subnet": "",
        "ip6": "",
        "ip6subnet": "",
        "mac": "c8:5a:cf:6d:8f:5c",
        "internal": "undefined",
        "virtual": false,
        "operstate": "down",
        "type": "wired",
        "duplex": "",
        "mtu": "",
        "speed": 9223372036854.775,
        "dhcp": false,
        "dnsSuffix": "",
        "ieee8021xAuth": "Unknown",
        "ieee8021xState": "Unknown",
        "carrierChanges": 0
    }
]

When using ipconfig -all, both interfaces are returned correctly:

Ethernet adapter Ethernet:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Intel(R) Ethernet Connection (10) I219-LM
   Physical Address. . . . . . . . . : C8-5A-CF-6D-8F-5C
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes

Ethernet adapter Ethernet HP Docking:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Realtek USB GbE Family Controller
   Physical Address. . . . . . . . . : C8-5A-CF-6D-8F-5C
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes

Expected behavior

After fixing this bug, both interfaces (with some others, which I skipped for simplicity) should be returned as this:

[
    {
        "iface": "Ethernet",
        "ifaceName": "Intel(R) Ethernet Connection (10) I219-LM",
        "default": false,
        "ip4": "",
        "ip4subnet": "",
        "ip6": "",
        "ip6subnet": "",
        "mac": "c8:5a:cf:6d:8f:5c",
        "internal": "undefined",
        "virtual": false,
        "operstate": "down",
        "type": "wired",
        "duplex": "",
        "mtu": "",
        "speed": 9223372036854.775,
        "dhcp": false,
        "dnsSuffix": "",
        "ieee8021xAuth": "Unknown",
        "ieee8021xState": "Unknown",
        "carrierChanges": 0
    },
    {
        "iface": "Ethernet HP Docking",
        "ifaceName": "Realtek USB GbE Family Controller",
        "default": false,
        "ip4": "",
        "ip4subnet": "",
        "ip6": "",
        "ip6subnet": "",
        "mac": "c8:5a:cf:6d:8f:5c",
        "internal": "undefined",
        "virtual": false,
        "operstate": "down",
        "type": "wired",
        "duplex": "",
        "mtu": "",
        "speed": 9223372036854.775,
        "dhcp": false,
        "dnsSuffix": "",
        "ieee8021xAuth": "Unknown",
        "ieee8021xState": "Unknown",
        "carrierChanges": 0
    }
]

Environment (please complete the following information):

Additional context Add any other context about the problem here.

balk0t commented 1 year ago

systeminformation.networkInterfaces() is using os.networkInterfaces() to get interfaces, but nodejs os function doesn't return all interfaces (according to documentation should return all interfaces with IP set, but this is not true)

For Linux maybe it would be better to check all devices in /sys/class/net, not sure about other systems.

tomas-reznak commented 7 months ago

Hello, is there any progress on this?