Skip to content

os.networkInterfaces does not list all interfaces.  #498

@zenoamaro

Description

@zenoamaro

Adoption of nodejs/node-v0.x-archive#9029.

os.networkInterfaces() does not list all interfaces, but only those that have addresses, excluding for example an unplugged eth0, which can be surprising.

This happens because os.networkInterfaces is actually implemented in terms of GetInterfaceAddresses which calls into uv_interface_addresses (which among other things filters out everything except AF_INET*) making networkInterfaces a bit of a misnomer for what is basically networkInterfaceAddresses.

Though os is at stability 4 already, this behavior can be a bit unexpected. Perhaps we could correct it somewhat without breaking the API, or at least document it. I can think of a few ways to work this out:

  • Leave the method as it is, but document the exceptional behavior in the docs, and leave it to a community module to solve this correctly; or
  • Alias it to os.networkInterfaceAddresses, thus reflecting GetInterfaceAddresses and uv_interface_addresses; or
  • Implement uv_interfaces and rebase os.networkInterfaces() on that and uv_interface_addresses, preserving the current behavior, but listing all interfaces when given a flag.
  1. yes
  2. os
  3. v0.10, v0.12, v1.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedPRs that are blocked by other issues or PRs.feature requestIssues that request new features to be added to Node.js.libuvIssues and PRs related to the libuv dependency or the uv binding.osIssues and PRs related to the os subsystem.stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions