network
network copied to clipboard
Can't get a IP address
Hi, I can't get a certain IP address, got a 'undefined' instead :) After I dive into the source code,I found that os.networkInterfaces() returned a weried NetConnectionID(yes, it's on Windows 7) with "????",actually is "本地连接"。So,in my guess,it's a case of string encoding,however, I don't know how dose this happen.
Can you show the full output?
@tomas Hi,I just added three lines of code in win32.js (in line 74)as follows to debug:
console.log(obj.name)
console.log(node_nics)
console.log(node_nics[obj.name])
Then it outputs:
????
{ '????':
[ { address: '******',
netmask: 'ffff:ffff:ffff:ffff::',
family: 'IPv6',
mac: '********',
scopeid: 11,
internal: false,
cidr: '*******' },
{ address: '192.****',
netmask: '255.255.255.0',
family: 'IPv4',
mac: '******',
internal: false,
cidr: '********' } ],
'Loopback Pseudo-Interface 1':
[ { address: '::1',
netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
family: 'IPv6',
mac: '00:00:00:00:00:00',
scopeid: 0,
internal: true,
cidr: '::1/128' },
{ 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' } ] }
undefined
And this is the output for os.networkInterfaces():
> os.networkInterfaces()
{ '????':
[ { address: '*****',
netmask: 'ffff:ffff:ffff:ffff::',
family: 'IPv6',
mac: '******',
scopeid: 11,
internal: false,
cidr: '******' },
{ address: '*******',
netmask: '255.255.255.0',
family: 'IPv4',
mac: '*********',
internal: false,
cidr: '**********' } ],
'Loopback Pseudo-Interface 1':
[ { address: '::1',
netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
family: 'IPv6',
mac: '00:00:00:00:00:00',
scopeid: 0,
internal: true,
cidr: '::1/128' },
{ 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' } ] }