Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more information to os.networkInterfaces() output? #14977

Closed
cwalther opened this issue Aug 22, 2017 · 4 comments
Closed

Add more information to os.networkInterfaces() output? #14977

cwalther opened this issue Aug 22, 2017 · 4 comments
Labels
feature request Issues that request new features to be added to Node.js. libuv Issues and PRs related to the libuv dependency or the uv binding.

Comments

@cwalther
Copy link

I had a need to get some detail information about the system’s IPv6 addresses, specifically whether they were temporary. It turned out that this was not extremely hard to add to the built-in os.networkInterfaces() function. Because I would rather not have to ship and maintain a patched node, I extracted the relevant code from node and libuv and put it into a module, then made my additions there: network-interfaces-plus.

Would there be interest in having this functionality added back to the original os.networkInterfaces()?

I don’t mind if the answer is “no” – I have seen similar requests declined in the past on the grounds that having os.networkInterfaces() in core is borderline feature-creep already.

My changes modify the libuv ABI (added struct fields) and would probably need to be coordinated with libuv/libuv#1371.

Example output

with node v6.11.2 on macOS 10.12.6

> os.networkInterfaces() // before
{ lo0: 
   [ { address: '127.0.0.1',
       netmask: '255.0.0.0',
       family: 'IPv4',
       mac: '00:00:00:00:00:00',
       internal: true },
     { address: '::1',
       netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
       family: 'IPv6',
       mac: '00:00:00:00:00:00',
       scopeid: 0,
       internal: true },
     { address: 'fe80::1',
       netmask: 'ffff:ffff:ffff:ffff::',
       family: 'IPv6',
       mac: '00:00:00:00:00:00',
       scopeid: 1,
       internal: true } ],
  en0: 
   [ { address: 'fe80::1ce9:2f8c:6663:ab03',
       netmask: 'ffff:ffff:ffff:ffff::',
       family: 'IPv6',
       mac: '00:25:00:f4:d8:75',
       scopeid: 4,
       internal: false },
     { address: 'fd49:351c:437d:0:4b6:e152:cd43:74af',
       netmask: 'ffff:ffff:ffff:ffff::',
       family: 'IPv6',
       mac: '00:25:00:f4:d8:75',
       scopeid: 0,
       internal: false },
     { address: 'fd49:351c:437d:0:449b:78a2:7370:4d3b',
       netmask: 'ffff:ffff:ffff:ffff::',
       family: 'IPv6',
       mac: '00:25:00:f4:d8:75',
       scopeid: 0,
       internal: false },
     { address: '192.168.1.59',
       netmask: '255.255.128.0',
       family: 'IPv4',
       mac: '00:25:00:f4:d8:75',
       internal: false } ],
  utun0: 
   [ { address: 'fe80::a9bf:ce39:e4f:2c53',
       netmask: 'ffff:ffff:ffff:ffff::',
       family: 'IPv6',
       mac: '00:00:00:00:00:00',
       scopeid: 7,
       internal: false } ],
  vnic0: 
   [ { address: '10.211.55.2',
       netmask: '255.255.255.0',
       family: 'IPv4',
       mac: '00:1c:42:00:00:08',
       internal: false } ],
  vnic1: 
   [ { address: '10.37.129.2',
       netmask: '255.255.255.0',
       family: 'IPv4',
       mac: '00:1c:42:00:00:09',
       internal: false } ] }
> require('network-interfaces-plus').networkInterfaces() // after
{ lo0: 
   [ { address: '127.0.0.1',
       netmask: '255.0.0.0',
       family: 'IPv4',
       mac: '00:00:00:00:00:00',
       internal: true,
       cidr: '127.0.0.1/8' },
     { address: '::1',
       netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
       family: 'IPv6',
       mac: '00:00:00:00:00:00',
       scopeid: 0,
       internal: true,
       temporary: false,
       valid_lifetime: 4294967295,
       preferred_lifetime: 4294967295,
       cidr: '::1/128' },
     { address: 'fe80::1',
       netmask: 'ffff:ffff:ffff:ffff::',
       family: 'IPv6',
       mac: '00:00:00:00:00:00',
       scopeid: 1,
       internal: true,
       temporary: false,
       valid_lifetime: 4294967295,
       preferred_lifetime: 4294967295,
       cidr: 'fe80::1/64' } ],
  en0: 
   [ { address: 'fe80::1ce9:2f8c:6663:ab03',
       netmask: 'ffff:ffff:ffff:ffff::',
       family: 'IPv6',
       mac: '00:25:00:f4:d8:75',
       scopeid: 4,
       internal: false,
       temporary: false,
       valid_lifetime: 4294967295,
       preferred_lifetime: 4294967295,
       cidr: 'fe80::1ce9:2f8c:6663:ab03/64' },
     { address: 'fd49:351c:437d:0:4b6:e152:cd43:74af',
       netmask: 'ffff:ffff:ffff:ffff::',
       family: 'IPv6',
       mac: '00:25:00:f4:d8:75',
       scopeid: 0,
       internal: false,
       temporary: false,
       valid_lifetime: 2591982,
       preferred_lifetime: 604782,
       cidr: 'fd49:351c:437d:0:4b6:e152:cd43:74af/64' },
     { address: 'fd49:351c:437d:0:449b:78a2:7370:4d3b',
       netmask: 'ffff:ffff:ffff:ffff::',
       family: 'IPv6',
       mac: '00:25:00:f4:d8:75',
       scopeid: 0,
       internal: false,
       temporary: true,
       valid_lifetime: 596355,
       preferred_lifetime: 77955,
       cidr: 'fd49:351c:437d:0:449b:78a2:7370:4d3b/64' },
     { address: '192.168.1.59',
       netmask: '255.255.128.0',
       family: 'IPv4',
       mac: '00:25:00:f4:d8:75',
       internal: false,
       cidr: '192.168.1.59/17' } ],
  utun0: 
   [ { address: 'fe80::a9bf:ce39:e4f:2c53',
       netmask: 'ffff:ffff:ffff:ffff::',
       family: 'IPv6',
       mac: '00:00:00:00:00:00',
       scopeid: 7,
       internal: false,
       temporary: false,
       valid_lifetime: 4294967295,
       preferred_lifetime: 4294967295,
       cidr: 'fe80::a9bf:ce39:e4f:2c53/64' } ],
  vnic0: 
   [ { address: '10.211.55.2',
       netmask: '255.255.255.0',
       family: 'IPv4',
       mac: '00:1c:42:00:00:08',
       internal: false,
       cidr: '10.211.55.2/24' } ],
  vnic1: 
   [ { address: '10.37.129.2',
       netmask: '255.255.255.0',
       family: 'IPv4',
       mac: '00:1c:42:00:00:09',
       internal: false,
       cidr: '10.37.129.2/24' } ] }

@Fishrock123
Copy link
Member

related to and possibly a duplicate of #498?

@Fishrock123 Fishrock123 added the libuv Issues and PRs related to the libuv dependency or the uv binding. label Aug 22, 2017
@cwalther
Copy link
Author

Definitely related in that it touches the same code (like mentioned libuv/libuv#1371, which is basically its implementation), but not a duplicate in my opinion, but orthogonal – it is asking for more interfaces, while my implementation adds more information inside each interface.

@mscdex mscdex added the feature request Issues that request new features to be added to Node.js. label Aug 22, 2017
@bzoz
Copy link
Contributor

bzoz commented Aug 24, 2017

PRs to libuv are always welcomed, feel free to open one. ABI stability is very important in libuv though. If your code changes structs then it will have hard time being accepted into the v1.x branch.

@refack
Copy link
Contributor

refack commented Nov 11, 2018

Put into https://github.com/nodejs/node/projects/13 backlog

@refack refack closed this as completed Nov 11, 2018
@refack refack added this to backlog/orphan in feature requests via automation Nov 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. libuv Issues and PRs related to the libuv dependency or the uv binding.
Projects
No open projects
feature requests
  
backlog/orphan
Development

No branches or pull requests

5 participants