Skip to content

Conversation

@jelveh
Copy link
Contributor

@jelveh jelveh commented Sep 21, 2025

Node.js 18+ changed the os.networkInterfaces() API to return numeric family values (4, 6) instead of strings ('IPv4', 'IPv6'). This caused the server startup message to not display any available network addresses on newer Node versions.

This PR updates the interface filtering logic to handle both string and numeric family formats, ensuring compatibility across all Node.js versions.

Changes:

  • Modified IPv4 interface detection to accept both 'IPv4' and 4 as valid family values
  • Added tests covering both string and numeric family formats
  • Added test coverage for IPv6 link-local address filtering
Relevant issues

Fixes #810

Contributor checklist
  • Provide tests for the changes (unless documentation-only)
  • Documented any new features, CLI switches, etc. (if applicable)
    • Server --help output
    • README.md
    • doc/http-server.1 (use the same format as other entries)
  • The pull request is being made against the master branch

Support both string ('IPv4') and numeric (4) family values from
os.networkInterfaces() to handle the API change in Node.js 18+.

Fixes #810
Verify that interface filtering handles both string and numeric
family values from `os.networkInterfaces()` across Node versions.

Related to #810
@jelveh
Copy link
Contributor Author

jelveh commented Sep 22, 2025

A contribution was made 3 years ago (#811) aiming to fix this issue. Since the PR was not merged in the time being, based on experience, it is very difficult to revive it (contributors move on, context is lost, ...). So I decided to submit a new PR that fixes this issue and close the old one.

@jelveh jelveh merged commit 38eec0a into master Sep 22, 2025
29 of 30 checks passed
@jelveh jelveh mentioned this pull request Sep 22, 2025
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Printing interfaces filters incorrectly on node 18 (in server listening message)

1 participant