systeminformation
Advanced tools
Comparing version 3.23.7 to 3.24.0
@@ -101,2 +101,3 @@ # Changelog | ||
| -------------- | -------------- | -------- | | ||
| 3.24.0 | 2017-08-05 | extended windows support `networkStats()`, `networkConnections()` | | ||
| 3.23.7 | 2017-07-11 | bug fix `diskLayout()` | | ||
@@ -103,0 +104,0 @@ | 3.23.6 | 2017-07-11 | added `cpuFlags()` to `getStaticData()`, bug fix `graphics()` (Win) | |
@@ -168,10 +168,8 @@ 'use strict'; | ||
process.nextTick(() => { | ||
if (_windows) { | ||
let error = new Error(NOT_SUPPORTED); | ||
if (callback) { callback(NOT_SUPPORTED) } | ||
reject(error); | ||
} | ||
_default_iface = _default_iface || getDefaultNetworkInterface(); | ||
iface = iface || _default_iface; // (_darwin ? 'en0' : 'eth0'); | ||
if (_windows) { | ||
iface = 'all' | ||
} | ||
@@ -244,2 +242,20 @@ let result = { | ||
} | ||
if (_windows) { | ||
cmd = "netstat -e"; | ||
exec(cmd, function (error, stdout) { | ||
const lines = stdout.split('\r\n'); | ||
for (let i = 0; i < lines.length; i++) { | ||
if (lines[i].toLowerCase().startsWith('bytes')) { | ||
const parts = lines[i].substr(5).trim().replace(/ +/g, " ").split(' '); | ||
if (parts.length > 1) { | ||
rx = parseInt(parts[0]); | ||
tx = parseInt(parts[1]); | ||
result = calcNetworkSpeed(iface, rx, tx, operstate); | ||
} | ||
} | ||
} | ||
if (callback) { callback(result) } | ||
resolve(result); | ||
}); | ||
} | ||
} else { | ||
@@ -267,8 +283,2 @@ result.rx = _network[iface].rx; | ||
process.nextTick(() => { | ||
if (_windows) { | ||
let error = new Error(NOT_SUPPORTED); | ||
if (callback) { callback(NOT_SUPPORTED) } | ||
reject(error); | ||
} | ||
let result = []; | ||
@@ -412,2 +422,58 @@ if (_linux) { | ||
} | ||
if (_windows) { | ||
let cmd = "netstat -na"; | ||
exec(cmd, function (error, stdout) { | ||
if (!error) { | ||
let lines = stdout.toString().split('\r\n'); | ||
lines.forEach(function (line) { | ||
line = line.trim().replace(/ +/g, " ").split(' '); | ||
if (line.length >= 4) { | ||
let localip = line[1]; | ||
let localport = ''; | ||
let localaddress = line[1].split(':'); | ||
if (localaddress.length > 1) { | ||
localport = localaddress[localaddress.length - 1]; | ||
localaddress.pop(); | ||
localip = localaddress.join(':'); | ||
} | ||
let peerip = line[2]; | ||
let peerport = ''; | ||
let peeraddress = line[2].split(':'); | ||
if (peeraddress.length > 1) { | ||
peerport = peeraddress[peeraddress.length - 1]; | ||
peeraddress.pop(); | ||
peerip = peeraddress.join(':'); | ||
} | ||
let connstate = line[3]; | ||
if (connstate === 'HERGESTELLT') connstate = 'ESTABLISHED'; | ||
if (connstate.startsWith('ABH')) connstate = 'LISTEN'; | ||
if (connstate === 'SCHLIESSEN_WARTEN') connstate = 'CLOSE_WAIT'; | ||
if (connstate === 'WARTEND') connstate = 'TIME_WAIT'; | ||
if (connstate === 'SYN_GESENDET') connstate = 'SYN_SENT'; | ||
if (connstate === 'LISTENING') connstate = 'LISTEN'; | ||
if (connstate === 'SYN_RECEIVED') connstate = 'SYN_RECV'; | ||
if (connstate === 'FIN_WAIT_1') connstate = 'FIN_WAIT1'; | ||
if (connstate === 'FIN_WAIT_2') connstate = 'FIN_WAIT2'; | ||
if (connstate) { | ||
result.push({ | ||
protocol: line[0].toLowerCase(), | ||
localaddress: localip, | ||
localport: localport, | ||
peeraddress: peerip, | ||
peerport: peerport, | ||
state: connstate | ||
}) | ||
} | ||
} | ||
}); | ||
if (callback) { | ||
callback(result) | ||
} | ||
resolve(result); | ||
} | ||
}) | ||
} | ||
}); | ||
@@ -414,0 +480,0 @@ }); |
{ | ||
"name": "systeminformation", | ||
"version": "3.23.7", | ||
"version": "3.24.0", | ||
"description": "Simple system and OS information library", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -44,2 +44,3 @@ # systeminformation | ||
### Latest Activity | ||
- Version 3.24.0: extended windows support `networkStats()`, `networkConnections()` | ||
- Version 3.23.0: added `memLayout`, `diskLayout`, extended windows support (`inetChecksite`) | ||
@@ -282,18 +283,18 @@ - Version 3.22.0: extended windows support (`users`, `inetLatency`) | ||
| | [0].internal | X | X | X | true if internal interface | | ||
| si.networkInterfaceDefault(cb) | : string | X | X | | get name of default network interface | | ||
| si.networkStats(iface,cb) | {...} | X | X | | current network stats of given interface<br>iface parameter is optional<br>defaults to first external network interface| | ||
| | iface | X | X | | interface | | ||
| si.networkInterfaceDefault(cb) | : string | X | X | X | get name of default network interface | | ||
| si.networkStats(iface,cb) | {...} | X | X | X | current network stats of given interface<br>iface parameter is optional<br>defaults to first external network interface<br>Windows: no iface, only overall stats!| | ||
| | iface | X | X | | interface (Windows: only overall stats)| | ||
| | operstate | X | X | | up / down | | ||
| | rx | X | X | | received bytes overall | | ||
| | tx | X | X | | transferred bytes overall| | ||
| | rx_sec | X | X | | received bytes / second (* see notes) | | ||
| | tx_sec | X | X | | transferred bytes per second (* see notes) | | ||
| | ms | X | X | | interval length (for per second values) | | ||
| si.networkConnections(cb) | [{...}] | X | X | | current network network connections<br>returns an array of all connections| | ||
| | [0].protocol | X | X | | tcp or udp | | ||
| | [0].localaddress | X | X | | local address | | ||
| | [0].localport | X | X | | local port | | ||
| | [0].peeraddress | X | X | | peer address | | ||
| | [0].peerport | X | X | | peer port | | ||
| | [0].state | X | X | | like ESTABLISHED, TIME_WAIT, ... | | ||
| | rx | X | X | X | received bytes overall | | ||
| | tx | X | X | X | transferred bytes overall| | ||
| | rx_sec | X | X | X | received bytes / second (* see notes) | | ||
| | tx_sec | X | X | X | transferred bytes per second (* see notes) | | ||
| | ms | X | X | X | interval length (for per second values) | | ||
| si.networkConnections(cb) | [{...}] | X | X | X | current network network connections<br>returns an array of all connections| | ||
| | [0].protocol | X | X | X | tcp or udp | | ||
| | [0].localaddress | X | X | X | local address | | ||
| | [0].localport | X | X | X | local port | | ||
| | [0].peeraddress | X | X | X | peer address | | ||
| | [0].peerport | X | X | X | peer port | | ||
| | [0].state | X | X | X | like ESTABLISHED, TIME_WAIT, ... | | ||
| si.inetChecksite(url, cb) | {...} | X | X | X | response-time (ms) to fetch given URL | | ||
@@ -300,0 +301,0 @@ | | url | X | X | X | given url | |
212487
4441
570