| 4.12.0 |
2019-06-21 |
diff --git a/docs/index.html b/docs/index.html
index 4493ab7..c96c8c6 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -168,7 +168,7 @@
systeminformation
- Current Version: 4.12.0
+ Current Version: 4.12.1
diff --git a/lib/network.js b/lib/network.js
index 86f917d..59e99a3 100644
--- a/lib/network.js
+++ b/lib/network.js
@@ -64,15 +64,26 @@ function getDefaultNetworkInterface() {
// https://www.inetdaemon.com/tutorials/internet/ip/routing/default_route.shtml
const cmd = 'netstat -r';
const result = execSync(cmd);
- const lines = result.toString().split(os.EOL)[0];
- const defaultIp = util.getValue('Default Gateway', lines, ':');
- for (let dev in ifaces) {
- if (ifaces.hasOwnProperty(dev)) {
- ifaces[dev].forEach(function (details) {
- if (details && details.address && details.address === defaultIp) {
- ifacename = dev;
- }
- });
+ const lines = result.toString().split(os.EOL);
+ let defaultIp = '';
+ lines.forEach(line => {
+ line = line.replace(/\s+/g, ' ').trim();
+ if (line.indexOf('0.0.0.0 0.0.0.0') > -1 && !(/[a-zA-Z]/.test(line))) {
+ const parts = line.split(' ');
+ if (parts.length >= 5) {
+ defaultIp = parts[parts.length - 2];
+ }
+ }
+ })
+ if (defaultIp) {
+ for (let dev in ifaces) {
+ if (ifaces.hasOwnProperty(dev)) {
+ ifaces[dev].forEach(function (details) {
+ if (details && details.address && details.address === defaultIp) {
+ ifacename = dev;
+ }
+ });
+ }
}
}
}
@@ -330,7 +341,7 @@ function networkInterfaces(callback) {
ip6: nic.ip6,
mac: nic.mac,
internal: nic.internal,
- virtual: testVirtualNic(nic.iface, nic.iface, nic.mac),
+ virtual: nic.internal ? false : testVirtualNic(nic.iface, nic.iface, nic.mac),
operstate: nic.operstate,
type: nic.type,
duplex: nic.duplex,
@@ -432,12 +443,6 @@ function networkInterfaces(callback) {
operstate = util.getValue(lines, 'operstate');
type = operstate === 'up' ? (util.getValue(lines, 'wireless').trim() ? 'wireless' : 'wired') : 'unknown';
if (iface === 'lo' || iface.startsWith('bond')) { type = 'virtual'; }
- // rx_bytes = parseInt(util.getValue(lines, 'rx_bytes'), 10);
- // rx_dropped = parseInt(util.getValue(lines, 'rx_dropped'), 10);
- // rx_errors = parseInt(util.getValue(lines, 'rx_errors'), 10);
- // tx_bytes = parseInt(util.getValue(lines, 'tx_bytes'), 10);
- // tx_dropped = parseInt(util.getValue(lines, 'tx_dropped'), 10);
- // tx_errors = parseInt(util.getValue(lines, 'tx_errors'), 10);
}
if (_windows) {
nics.forEach(detail => {
@@ -453,7 +458,7 @@ function networkInterfaces(callback) {
}
}
let internal = (ifaces[dev] && ifaces[dev][0]) ? ifaces[dev][0].internal : null;
- const virtual = testVirtualNic(dev, ifaceName, mac);
+ const virtual = internal ? false : testVirtualNic(dev, ifaceName, mac);
result.push({
iface: dev,
ifaceName,