systeminformation 6.0.0-beta.15 → 6.0.0-beta.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -376,8 +376,8 @@ On Linux, `si.gpu()` also covers the integrated GPU of NVIDIA Tegra / Jetson boa
376
376
  | | [0].deviceId | | | X | | | device ID |
377
377
  | | [0].bus | X | | X | X | | on which bus (e.g. PCIe) |
378
378
  | | [0].busAddress | X | | | X | | PCI bus address, e.g. '01:00.0' |
379
- | | [0].vram | X | | X | X | | VRAM size (in MB) |
380
- | | [0].vramDynamic | X | | X | X | | true if dynamically allocated ram |
379
+ | | [0].vram | X | | X | X | | VRAM size (in MB), `null` if shared |
380
+ | | [0].vramDynamic | X | | X | X | | true if dynamically allocated ram (integrated GPUs) |
381
381
  | | [0].external | | | X | | | is external GPU |
382
382
  | | [0].cores | | | X | | | Apple silicon only |
383
383
  | | [0].metalVersion | | | X | | | Apple Metal Version |
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.execSave = exports.timeout = exports.execSecure = exports.shareInflight = exports.execFile = exports.exec = void 0;
4
4
  const node_child_process_1 = require("node:child_process");
5
5
  const node_util_1 = require("node:util");
6
+ const const_1 = require("./const");
6
7
  exports.exec = (0, node_util_1.promisify)(node_child_process_1.exec);
7
8
  exports.execFile = (0, node_util_1.promisify)(node_child_process_1.execFile);
8
9
  const _inflight = new Map();
@@ -17,35 +18,50 @@ const shareInflight = (key, fn) => {
17
18
  exports.shareInflight = shareInflight;
18
19
  const execSecure = (cmd, args, options) => {
19
20
  let result = '';
20
- options = options || {};
21
+ const { timeout: timeoutMs, ...spawnOptions } = options || {};
21
22
  return new Promise((resolve) => {
22
23
  process.nextTick(() => {
23
- try {
24
- const child = (0, node_child_process_1.spawn)(cmd, args, options);
25
- if (child && !child.pid) {
26
- child.on('error', () => {
27
- resolve(result);
28
- });
24
+ let timer = null;
25
+ const done = () => {
26
+ if (timer) {
27
+ clearTimeout(timer);
28
+ timer = null;
29
29
  }
30
+ resolve(result);
31
+ };
32
+ try {
33
+ const child = (0, node_child_process_1.spawn)(cmd, args, { stdio: ['pipe', 'pipe', 'ignore'], ...spawnOptions });
30
34
  if (child?.pid) {
35
+ if (timeoutMs) {
36
+ timer = setTimeout(() => {
37
+ child.kill('SIGKILL');
38
+ child.stdout?.destroy();
39
+ child.stderr?.destroy();
40
+ child.unref();
41
+ done();
42
+ }, timeoutMs);
43
+ }
31
44
  child.stdout.on('data', (data) => {
32
- result += data.toString();
45
+ if (result.length < const_1.MAX_BUFFER_SIZE) {
46
+ result = (result + data.toString()).substring(0, const_1.MAX_BUFFER_SIZE);
47
+ }
33
48
  });
34
49
  child.on('close', () => {
35
50
  child.kill();
36
- resolve(result);
51
+ done();
37
52
  });
38
53
  child.on('error', () => {
39
54
  child.kill();
40
- resolve(result);
55
+ done();
41
56
  });
42
57
  }
43
58
  else {
44
- resolve(result);
59
+ child?.on('error', () => done());
60
+ done();
45
61
  }
46
62
  }
47
63
  catch {
48
- resolve(result);
64
+ done();
49
65
  }
50
66
  });
51
67
  });
@@ -1676,6 +1676,38 @@ const graphicsMetalVersion = (id) => {
1676
1676
  exports.graphicsMetalVersion = graphicsMetalVersion;
1677
1677
  const getAppleModel = (key) => {
1678
1678
  const appleModelIds = [
1679
+ {
1680
+ key: 'Mac18,5',
1681
+ name: 'Mac mini',
1682
+ size: '',
1683
+ processor: 'M6',
1684
+ year: '2026',
1685
+ additional: ''
1686
+ },
1687
+ {
1688
+ key: 'Mac17,16',
1689
+ name: 'Mac mini',
1690
+ size: '',
1691
+ processor: 'M5 Pro',
1692
+ year: '2026',
1693
+ additional: ''
1694
+ },
1695
+ {
1696
+ key: 'Mac17,15',
1697
+ name: 'Mac Studio',
1698
+ size: '',
1699
+ processor: 'M5 Ultra',
1700
+ year: '2026',
1701
+ additional: ''
1702
+ },
1703
+ {
1704
+ key: 'Mac17,14',
1705
+ name: 'Mac Studio',
1706
+ size: '',
1707
+ processor: 'M5 Max',
1708
+ year: '2026',
1709
+ additional: ''
1710
+ },
1679
1711
  {
1680
1712
  key: 'Mac17,9',
1681
1713
  name: 'MacBook Pro',
@@ -1,4 +1,4 @@
1
- import type { NetworkStatsData } from './types';
1
+ import type { NetworkInterfacesData, NetworkStatsData } from './types';
2
2
  export declare const wifiDBFromQuality: (quality: string) => number | null;
3
3
  export declare const wifiQualityFromDB: (db: number | string) => number | null;
4
4
  export declare const wifiFrequencyFromChannel: (channel: number) => any;
@@ -18,3 +18,4 @@ export type NetworkCounters = {
18
18
  operstate: string;
19
19
  };
20
20
  export declare const calcNetworkSpeed: (counters: NetworkCounters, _network: any) => NetworkStatsData;
21
+ export declare const filterDefaultInterface: (interfaces: NetworkInterfacesData[], defaultString: string) => NetworkInterfacesData[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calcNetworkSpeed = exports.testVirtualNic = exports.getFirstExternalNetworkInterface = exports.wifiChannelFromFrequencies = exports.wifiFrequencyFromChannel = exports.wifiQualityFromDB = exports.wifiDBFromQuality = void 0;
3
+ exports.filterDefaultInterface = exports.calcNetworkSpeed = exports.testVirtualNic = exports.getFirstExternalNetworkInterface = exports.wifiChannelFromFrequencies = exports.wifiFrequencyFromChannel = exports.wifiQualityFromDB = exports.wifiDBFromQuality = void 0;
4
4
  const index_1 = require("./index");
5
5
  const mappings_1 = require("./mappings");
6
6
  const wifiDBFromQuality = (quality) => {
@@ -154,3 +154,5 @@ const calcNetworkSpeed = (counters, _network) => {
154
154
  };
155
155
  };
156
156
  exports.calcNetworkSpeed = calcNetworkSpeed;
157
+ const filterDefaultInterface = (interfaces, defaultString) => defaultString.toLowerCase().indexOf('default') >= 0 ? interfaces.filter((item) => item.default).slice(0, 1) : interfaces.slice();
158
+ exports.filterDefaultInterface = filterDefaultInterface;
@@ -160,7 +160,8 @@ const sanitizeUrl = (url) => {
160
160
  }
161
161
  if (urlSanitized && !(0, exports.isPrototypePolluted)()) {
162
162
  Object.setPrototypeOf(urlSanitized, { startsWith: exports.stringStartWith });
163
- if (urlSanitized.startsWith('file:') ||
163
+ if (urlSanitized.startsWith('-') ||
164
+ urlSanitized.startsWith('file:') ||
164
165
  urlSanitized.startsWith('gopher:') ||
165
166
  urlSanitized.startsWith('telnet:') ||
166
167
  urlSanitized.startsWith('mailto:') ||
@@ -219,7 +220,8 @@ const sanitizeInterfacesString = (interfaces) => {
219
220
  startsWith: exports.stringStartWith
220
221
  });
221
222
  interfacesSanitized = interfacesSanitized.trim().replace(/,+/g, '|');
222
- return interfacesSanitized;
223
+ const kept = interfacesSanitized.split('|').filter((part) => part && !/^\s*-/.test(part));
224
+ return kept.length ? kept.join('|') : '-';
223
225
  };
224
226
  exports.sanitizeInterfacesString = sanitizeInterfacesString;
225
227
  const sanitizeString = (str, strict) => {
@@ -186,7 +186,7 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
186
186
  await (0, common_1.nextTick)();
187
187
  const interfaces = (0, node_os_1.networkInterfaces)();
188
188
  if (JSON.stringify(interfaces) === JSON.stringify(_interfaces) && !rescan) {
189
- return _networkInterfaces;
189
+ return (0, network_1.filterDefaultInterface)(_networkInterfaces, defaultString);
190
190
  }
191
191
  _interfaces = (0, index_1.cloneObj)(interfaces);
192
192
  let result = [];
@@ -264,10 +264,7 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
264
264
  });
265
265
  }
266
266
  _networkInterfaces = result;
267
- if (defaultString.toLowerCase().indexOf('default') >= 0) {
268
- result = result.filter((item) => item.default);
269
- return result.length ? [result[0]] : [];
270
- }
267
+ return (0, network_1.filterDefaultInterface)(result, defaultString);
271
268
  }
272
269
  catch { }
273
270
  return result;
@@ -7,7 +7,7 @@ const exec_1 = require("../common/exec");
7
7
  const users = async () => {
8
8
  await (0, common_1.nextTick)();
9
9
  let stdout = '';
10
- ({ stdout } = await (0, exec_1.execSave)('export LC_ALL=C; who; echo "---"; w -ih; unset LC_ALL'));
10
+ ({ stdout } = await (0, exec_1.execSave)('export LC_ALL=C.UTF-8; who; echo "---"; w -ih; unset LC_ALL'));
11
11
  return (0, darwin_1.parseUsersDarwin)(stdout);
12
12
  };
13
13
  exports.users = users;
@@ -16,7 +16,7 @@ const diskLayout = async () => {
16
16
  let cmd = '';
17
17
  let cmdFullSmart = '';
18
18
  try {
19
- ({ stdout } = await (0, exec_1.exec)('export LC_ALL=C; lsblk -ablJO 2>/dev/null; unset LC_ALL', const_1.execOptsLinux));
19
+ ({ stdout } = await (0, exec_1.exec)('export LC_ALL=C.UTF-8; lsblk -ablJO 2>/dev/null; unset LC_ALL', const_1.execOptsLinux));
20
20
  const out = stdout.trim();
21
21
  let devices = [];
22
22
  try {
@@ -37,7 +37,7 @@ const diskLayout = async () => {
37
37
  }
38
38
  catch (e) {
39
39
  try {
40
- ({ stdout } = await (0, exec_1.exec)('export LC_ALL=C; lsblk -bPo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,RM,LABEL,MODEL,OWNER,GROUP 2>/dev/null; unset LC_ALL', const_1.execOptsLinux));
40
+ ({ stdout } = await (0, exec_1.exec)('export LC_ALL=C.UTF-8; lsblk -bPo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,RM,LABEL,MODEL,OWNER,GROUP 2>/dev/null; unset LC_ALL', const_1.execOptsLinux));
41
41
  const lines = (0, filesys_1.blkStdoutToObject)(stdout).split('\n');
42
42
  const data = (0, filesys_1.parseLinuxBlk)(lines);
43
43
  devices = data.filter((item) => {
@@ -257,7 +257,7 @@ const fsSize = async (drives) => {
257
257
  if (linuxData) {
258
258
  return await applyZfsUsage(linuxData);
259
259
  }
260
- cmd = 'export LC_ALL=C; df -kPTx squashfs; unset LC_ALL';
260
+ cmd = 'export LC_ALL=C.UTF-8; df -kPTx squashfs; unset LC_ALL';
261
261
  }
262
262
  if (const_1.FREEBSD || const_1.NETBSD || const_1.OPENBSD) {
263
263
  try {
@@ -1,6 +1,7 @@
1
1
  import { GpuData } from '../common/types';
2
2
  type DrmMetrics = {
3
3
  busAddress: string;
4
+ sharedMemory: boolean;
4
5
  utilizationGpu: number | null;
5
6
  memoryTotal: number | null;
6
7
  memoryUsed: number | null;
package/dist/linux/gpu.js CHANGED
@@ -28,6 +28,7 @@ const parseAmdClock = (stdout) => {
28
28
  const value = line ? Number.parseFloat(line.replace(/^\d+:\s*/, '')) : Number.NaN;
29
29
  return Number.isNaN(value) ? null : value;
30
30
  };
31
+ const INTEGRATED_DRM_DRIVERS = ['i915', 'xe'];
31
32
  const drmDevices = async (drmPath = '/sys/class/drm') => {
32
33
  const devices = [];
33
34
  let cards = [];
@@ -50,6 +51,11 @@ const drmDevices = async (drmPath = '/sys/class/drm') => {
50
51
  if (!/^[\da-f]{2}:[\da-f]{2}\.[\da-f]$/i.test(busAddress)) {
51
52
  continue;
52
53
  }
54
+ let driver = '';
55
+ try {
56
+ driver = (await (0, promises_1.readlink)(`${devicePath}/driver`)).split('/').pop() || '';
57
+ }
58
+ catch { }
53
59
  let hwmon = [];
54
60
  try {
55
61
  hwmon = (await (0, promises_1.readdir)(`${devicePath}/hwmon`)).filter(security_1.isSafePathSegment).map((node) => `${devicePath}/hwmon/${node}`);
@@ -63,10 +69,12 @@ const drmDevices = async (drmPath = '/sys/class/drm') => {
63
69
  `${devicePath}/tile0/gt0/freq0/act_freq`,
64
70
  `${devicePath}/tile0/gt0/freq0/cur_freq`
65
71
  ], 1, true);
72
+ const memoryTotal = await readSysfsNumber([`${devicePath}/mem_info_vram_total`, `${cardPath}/lmem_total_bytes`, `${devicePath}/tile0/physical_vram_size_bytes`], 1024 * 1024, true);
66
73
  devices.push({
67
74
  busAddress,
75
+ sharedMemory: INTEGRATED_DRM_DRIVERS.includes(driver) && !memoryTotal,
68
76
  utilizationGpu: await readSysfsNumber([`${devicePath}/gpu_busy_percent`]),
69
- memoryTotal: await readSysfsNumber([`${devicePath}/mem_info_vram_total`], 1024 * 1024),
77
+ memoryTotal,
70
78
  memoryUsed: await readSysfsNumber([`${devicePath}/mem_info_vram_used`], 1024 * 1024),
71
79
  temperatureGpu: await readSysfsNumber(hwmon.map((node) => `${node}/temp1_input`), 1000),
72
80
  powerDraw: await readSysfsNumber(hwmon.map((node) => `${node}/power1_input`), 1000000),
@@ -145,10 +153,8 @@ const mergeControllerDrm = (controller, drm) => {
145
153
  }
146
154
  if (controller.memoryTotal === undefined && drm.memoryTotal) {
147
155
  controller.memoryTotal = drm.memoryTotal;
148
- if (controller.vram === null) {
149
- controller.vram = drm.memoryTotal;
150
- controller.vramDynamic = false;
151
- }
156
+ controller.vram = Math.round(drm.memoryTotal);
157
+ controller.vramDynamic = false;
152
158
  }
153
159
  if (controller.memoryUsed === undefined && drm.memoryUsed !== null) {
154
160
  controller.memoryUsed = drm.memoryUsed;
@@ -168,6 +174,10 @@ const mergeControllerDrm = (controller, drm) => {
168
174
  if (controller.clockCore === undefined && drm.clockCore !== null) {
169
175
  controller.clockCore = drm.clockCore;
170
176
  }
177
+ if (drm.sharedMemory) {
178
+ controller.vram = null;
179
+ controller.vramDynamic = true;
180
+ }
171
181
  return controller;
172
182
  };
173
183
  exports.mergeControllerDrm = mergeControllerDrm;
@@ -186,7 +196,7 @@ const parseLinesLinuxControllers = async (lines) => {
186
196
  let isGraphicsController = false;
187
197
  let pciIDs = [];
188
198
  try {
189
- const { stdout } = await (0, exec_1.exec)('export LC_ALL=C; dmidecode -t 9 2>/dev/null; unset LC_ALL | grep "Bus Address: "', const_1.execOptsLinux);
199
+ const { stdout } = await (0, exec_1.exec)('export LC_ALL=C; dmidecode -t 9 2>/dev/null | grep "Bus Address: "', const_1.execOptsLinux);
190
200
  pciIDs = stdout.split('\n');
191
201
  for (let i = 0; i < pciIDs.length; i++) {
192
202
  pciIDs[i] = pciIDs[i].replace('Bus Address:', '').replace('0000:', '').trim();
@@ -15,6 +15,9 @@ const security_1 = require("../common/security");
15
15
  const network_interface_default_1 = require("./network-interface-default");
16
16
  const pci_1 = require("./pci");
17
17
  const EXEC_OPTS = { timeout: 5000 };
18
+ const EXEC_OPTS_LINUX = { ...const_1.execOptsLinux, ...EXEC_OPTS };
19
+ const EXEC_OPTS_NMCLI = { ...EXEC_OPTS_LINUX, env: { ...process.env, LC_ALL: 'C.UTF-8' } };
20
+ const SCAN_CONCURRENCY = 8;
18
21
  let _interfaces = {};
19
22
  let _networkInterfaces = [];
20
23
  const splitSectionsNics = (lines) => {
@@ -35,21 +38,36 @@ const splitSectionsNics = (lines) => {
35
38
  return result;
36
39
  };
37
40
  const getLinuxDeviceStatus = async () => {
41
+ const result = new Map();
38
42
  try {
39
- const { stdout } = await (0, exec_1.execFile)('nmcli', ['device', 'status'], const_1.execOptsLinux);
43
+ const { stdout } = await (0, exec_1.execFile)('nmcli', ['-t', '-f', 'DEVICE,STATE,CONNECTION', 'device', 'status'], EXEC_OPTS_NMCLI);
44
+ for (const line of stdout.split('\n')) {
45
+ const [device, state, connection] = line.split(/(?<!\\):/).map((part) => part.replace(/\\:/g, ':'));
46
+ if (device && state !== undefined) {
47
+ result.set(device, { state, connection: connection && connection !== '--' ? connection : '' });
48
+ }
49
+ }
50
+ }
51
+ catch { }
52
+ return result;
53
+ };
54
+ const getLinuxIfaceConnectionName = (deviceStatus, interfaceName) => {
55
+ const device = deviceStatus.get(interfaceName);
56
+ return device && !device.state.includes('externally') ? device.connection : '';
57
+ };
58
+ const getLinuxConnectionDetails = async (connectionName) => {
59
+ if (!connectionName) {
60
+ return null;
61
+ }
62
+ try {
63
+ const { stdout } = await (0, exec_1.execFile)('nmcli', ['connection', 'show', 'id', connectionName], EXEC_OPTS_NMCLI);
40
64
  return stdout;
41
65
  }
42
66
  catch {
43
- return '';
67
+ return null;
44
68
  }
45
69
  };
46
- const getLinuxIfaceConnectionName = (deviceStatus, interfaceName) => {
47
- const result = (0, common_1.grep)(deviceStatus, interfaceName);
48
- const resultFormat = result.replace(/\s+/g, ' ').trim();
49
- const connectionNameLines = resultFormat.split(' ').slice(3);
50
- const connectionName = connectionNameLines.join(' ');
51
- return connectionName !== '--' ? connectionName : '';
52
- };
70
+ const getNmcliValue = (stdout, property) => (0, common_1.grep)(stdout, property).replace(/\s+/g, ' ').trim().split(' ').slice(1).toString();
53
71
  const readInterfacesLines = async (file) => {
54
72
  if (file.includes('*') || file.includes('?')) {
55
73
  try {
@@ -94,7 +112,7 @@ exports.checkLinuxDCHPInterfaces = checkLinuxDCHPInterfaces;
94
112
  const getLinuxDHCPNics = async () => {
95
113
  let result = [];
96
114
  try {
97
- const { stdout } = await (0, exec_1.exec)('ip a 2> /dev/null', const_1.execOptsLinux);
115
+ const { stdout } = await (0, exec_1.exec)('ip a 2> /dev/null', EXEC_OPTS_LINUX);
98
116
  const lines = stdout.split('\n');
99
117
  const nsections = splitSectionsNics(lines);
100
118
  result = parseLinuxDHCPNics(nsections);
@@ -125,65 +143,25 @@ const parseLinuxDHCPNics = (sections) => {
125
143
  }
126
144
  return result;
127
145
  };
128
- const getLinuxIfaceDHCPstatus = async (iface, connectionName, DHCPNics) => {
129
- let result = false;
130
- if (connectionName) {
131
- try {
132
- const { stdout } = await (0, exec_1.execFile)('nmcli', ['connection', 'show', connectionName], const_1.execOptsLinux);
133
- const res = (0, common_1.grep)(stdout, 'ipv4.method');
134
- const resultFormat = res.replace(/\s+/g, ' ').trim();
135
- const dhcStatus = resultFormat.split(' ').slice(1).toString();
136
- switch (dhcStatus) {
137
- case 'auto':
138
- result = true;
139
- break;
140
- default:
141
- result = false;
142
- break;
143
- }
144
- return result;
145
- }
146
- catch {
147
- return DHCPNics.indexOf(iface) >= 0;
148
- }
149
- }
150
- else {
146
+ const getLinuxIfaceDHCPstatus = (iface, details, DHCPNics) => {
147
+ if (details === null) {
151
148
  return DHCPNics.indexOf(iface) >= 0;
152
149
  }
150
+ return getNmcliValue(details, 'ipv4.method') === 'auto';
153
151
  };
154
- const getLinuxIfaceDNSsuffix = async (connectionName) => {
155
- if (connectionName) {
156
- try {
157
- const { stdout } = await (0, exec_1.execFile)('nmcli', ['connection', 'show', connectionName], const_1.execOptsLinux);
158
- const res = (0, common_1.grep)(stdout, 'ipv4.dns-search');
159
- const resultFormat = res.replace(/\s+/g, ' ').trim();
160
- const dnsSuffix = resultFormat.split(' ').slice(1).toString();
161
- return dnsSuffix === '--' ? 'Not defined' : dnsSuffix;
162
- }
163
- catch {
164
- return 'Unknown';
165
- }
166
- }
167
- else {
152
+ const getLinuxIfaceDNSsuffix = (details) => {
153
+ if (details === null) {
168
154
  return 'Unknown';
169
155
  }
156
+ const dnsSuffix = getNmcliValue(details, 'ipv4.dns-search');
157
+ return dnsSuffix === '--' ? 'Not defined' : dnsSuffix;
170
158
  };
171
- const getLinuxIfaceIEEE8021xAuth = async (connectionName) => {
172
- if (connectionName) {
173
- try {
174
- const { stdout } = await (0, exec_1.execFile)('nmcli', ['connection', 'show', connectionName], const_1.execOptsLinux);
175
- const res = (0, common_1.grep)(stdout, '802-1x.eap');
176
- const resultFormat = res.replace(/\s+/g, ' ').trim();
177
- const authenticationProtocol = resultFormat.split(' ').slice(1).toString();
178
- return authenticationProtocol === '--' ? '' : authenticationProtocol;
179
- }
180
- catch {
181
- return 'Not defined';
182
- }
183
- }
184
- else {
159
+ const getLinuxIfaceIEEE8021xAuth = (details) => {
160
+ if (details === null) {
185
161
  return 'Not defined';
186
162
  }
163
+ const authenticationProtocol = getNmcliValue(details, '802-1x.eap');
164
+ return authenticationProtocol === '--' ? '' : authenticationProtocol;
187
165
  };
188
166
  const getLinuxIfaceIEEE8021xState = (authenticationProtocol) => {
189
167
  if (authenticationProtocol) {
@@ -199,7 +177,7 @@ const getLinuxIfaceIEEE8021xState = (authenticationProtocol) => {
199
177
  const getLinuxGateways = async () => {
200
178
  const result = {};
201
179
  try {
202
- const { stdout } = await (0, exec_1.exec)('ip -4 route show default 2> /dev/null', const_1.execOptsLinux);
180
+ const { stdout } = await (0, exec_1.exec)('ip -4 route show default 2> /dev/null', EXEC_OPTS_LINUX);
203
181
  for (const line of stdout.split('\n')) {
204
182
  for (const match of line.matchAll(/(?:via\s+(\S+)\s+)?dev\s+(\S+)/g)) {
205
183
  if (!result[match[2]]) {
@@ -260,26 +238,27 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
260
238
  await (0, common_1.nextTick)();
261
239
  const interfaces = (0, node_os_1.networkInterfaces)();
262
240
  if (JSON.stringify(interfaces) === JSON.stringify(_interfaces) && !rescan) {
263
- return _networkInterfaces;
241
+ return (0, network_1.filterDefaultInterface)(_networkInterfaces, defaultString);
264
242
  }
265
243
  _interfaces = (0, index_1.cloneObj)(interfaces);
266
244
  let result = [];
267
245
  try {
268
- const _dhcpNics = await getLinuxDHCPNics();
269
- const defaultInterface = await (0, network_interface_default_1.networkInterfaceDefault)();
270
- const deviceStatus = await getLinuxDeviceStatus();
246
+ const [_dhcpNics, defaultInterface, deviceStatus, gateways, sysfsDevices, wirelessLines] = await Promise.all([
247
+ getLinuxDHCPNics(),
248
+ (0, network_interface_default_1.networkInterfaceDefault)(),
249
+ getLinuxDeviceStatus(),
250
+ getLinuxGateways(),
251
+ (0, promises_1.readdir)('/sys/class/net').catch(() => []),
252
+ (0, files_1.readFileLines)('/proc/net/wireless')
253
+ ]);
271
254
  const devices = Object.keys(interfaces);
272
- try {
273
- for (const dev of await (0, promises_1.readdir)('/sys/class/net')) {
274
- if (!devices.some((device) => device.split(':')[0] === dev)) {
275
- devices.push(dev);
276
- }
255
+ for (const dev of sysfsDevices) {
256
+ if (!devices.some((device) => device.split(':')[0] === dev)) {
257
+ devices.push(dev);
277
258
  }
278
259
  }
279
- catch { }
280
- const gateways = await getLinuxGateways();
281
260
  const hardware = await getLinuxNicHardware(devices);
282
- for (const dev of devices) {
261
+ const scanInterface = async (dev) => {
283
262
  const iface = dev;
284
263
  let ip4 = '';
285
264
  let ip4subnet = '';
@@ -334,19 +313,23 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
334
313
  const ifaceDevName = dev.split(':')[0].trim();
335
314
  const ifaceSanitized = (0, security_1.sanitizeString)(ifaceDevName, true);
336
315
  let lines = [];
316
+ let hasDevice = true;
337
317
  try {
338
- const [sysfsLines, wirelessLines, iwOut] = await Promise.all([
339
- (0, security_1.isSafePathSegment)(ifaceSanitized) ? (0, files_1.readSysfsMany)(`/sys/class/net/${ifaceSanitized}`, ['address', 'carrier_changes', 'duplex', 'mtu', 'operstate', 'speed', 'type']) : [],
340
- (0, files_1.readFileLines)('/proc/net/wireless'),
341
- (0, exec_1.execSecure)('iw', ['dev', ifaceSanitized, 'link'], EXEC_OPTS)
318
+ const safe = (0, security_1.isSafePathSegment)(ifaceSanitized);
319
+ const connectionName = getLinuxIfaceConnectionName(deviceStatus, ifaceSanitized);
320
+ const [sysfsLines, iwOut, details, device] = await Promise.all([
321
+ safe ? (0, files_1.readSysfsMany)(`/sys/class/net/${ifaceSanitized}`, ['address', 'carrier_changes', 'duplex', 'mtu', 'operstate', 'speed', 'type']) : [],
322
+ safe ? (0, files_1.fileExists)(`/sys/class/net/${ifaceSanitized}/phy80211`).then((wifi) => (wifi ? (0, exec_1.execSecure)('iw', ['dev', ifaceSanitized, 'link'], EXEC_OPTS) : '')) : '',
323
+ getLinuxConnectionDetails(connectionName),
324
+ safe ? (0, files_1.fileExists)(`/sys/class/net/${ifaceSanitized}/device`) : true
342
325
  ]);
326
+ hasDevice = device;
343
327
  lines = sysfsLines;
344
328
  lines.push(`wireless: ${wirelessLines.find((line) => line.indexOf(ifaceSanitized) >= 0) || ''}`);
345
329
  lines.push(...iwOut.split('\n').filter((line) => line.indexOf('bitrate') >= 0).map((line) => line.trim()));
346
- const connectionName = getLinuxIfaceConnectionName(deviceStatus, ifaceSanitized);
347
- dhcp = await getLinuxIfaceDHCPstatus(ifaceSanitized, connectionName, _dhcpNics);
348
- dnsSuffix = await getLinuxIfaceDNSsuffix(connectionName);
349
- ieee8021xAuth = await getLinuxIfaceIEEE8021xAuth(connectionName);
330
+ dhcp = getLinuxIfaceDHCPstatus(ifaceSanitized, details, _dhcpNics);
331
+ dnsSuffix = getLinuxIfaceDNSsuffix(details);
332
+ ieee8021xAuth = getLinuxIfaceIEEE8021xAuth(details);
350
333
  ieee8021xState = getLinuxIfaceIEEE8021xState(ieee8021xAuth);
351
334
  }
352
335
  catch { }
@@ -372,8 +355,8 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
372
355
  if (dev.toLowerCase().indexOf('loopback') > -1 || ifaceName.toLowerCase().indexOf('loopback') > -1) {
373
356
  internal = true;
374
357
  }
375
- const virtual = internal ? false : (0, network_1.testVirtualNic)(dev, ifaceName, mac);
376
- result.push({
358
+ const virtual = internal ? false : !hasDevice || (0, network_1.testVirtualNic)(dev, ifaceName, mac);
359
+ return {
377
360
  ...defaults_1.initNetworkInterface,
378
361
  iface: ifaceSanitized,
379
362
  ifaceName,
@@ -398,20 +381,14 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
398
381
  ieee8021xAuth,
399
382
  ieee8021xState,
400
383
  carrierChanges
401
- });
384
+ };
385
+ };
386
+ for (let i = 0; i < devices.length; i += SCAN_CONCURRENCY) {
387
+ result.push(...(await Promise.all(devices.slice(i, i + SCAN_CONCURRENCY).map(scanInterface))));
402
388
  }
403
389
  }
404
390
  catch { }
405
391
  _networkInterfaces = result;
406
- if (defaultString.toLowerCase().indexOf('default') >= 0) {
407
- result = result.filter((item) => item.default);
408
- if (result.length > 0) {
409
- return [result[0]];
410
- }
411
- else {
412
- result = [];
413
- }
414
- }
415
- return result;
392
+ return (0, network_1.filterDefaultInterface)(result, defaultString);
416
393
  };
417
394
  exports.networkInterfaces = networkInterfaces;
@@ -61,7 +61,7 @@ const printer = async () => {
61
61
  }
62
62
  if (result.length === 0) {
63
63
  if (const_1.LINUX) {
64
- const { stdout } = await (0, exec_1.execSave)('export LC_ALL=C; lpstat -lp 2>/dev/null; unset LC_ALL');
64
+ const { stdout } = await (0, exec_1.execSave)('export LC_ALL=C.UTF-8; lpstat -lp 2>/dev/null; unset LC_ALL');
65
65
  const parts = ('\n' + stdout.toString()).split('\nprinter ');
66
66
  for (let i = 1; i < parts.length; i++) {
67
67
  const printers = parseLinuxLpstatPrinter(parts[i].split('\n'), i);
@@ -283,10 +283,10 @@ const processes = async () => {
283
283
  if ((_processes_cpu.ms && Date.now() - _processes_cpu.ms >= 500) || _processes_cpu.ms === 0) {
284
284
  try {
285
285
  if (const_1.LINUX || const_1.ANDROID) {
286
- cmd = 'export LC_ALL=C; ps -axo pid:11,ppid:11,pcpu:6,pmem:6,pri:5,vsz:11,rss:11,ni:5,etime:30,state:5,tty:15,user:20,time,command; unset LC_ALL';
286
+ cmd = 'export LC_ALL=C.UTF-8; ps -axo pid:11,ppid:11,pcpu:6,pmem:6,pri:5,vsz:11,rss:11,ni:5,etime:30,state:5,tty:15,user:20,time,command; unset LC_ALL';
287
287
  }
288
288
  if (const_1.FREEBSD || const_1.NETBSD || const_1.OPENBSD) {
289
- cmd = 'export LC_ALL=C; ps -axo pid,ppid,pcpu,pmem,pri,vsz,rss,ni,etime,state,tty,user,time,command; unset LC_ALL';
289
+ cmd = 'export LC_ALL=C.UTF-8; ps -axo pid,ppid,pcpu,pmem,pri,vsz,rss,ni,etime,state,tty,user,time,command; unset LC_ALL';
290
290
  }
291
291
  if (const_1.DARWIN) {
292
292
  cmd = 'ps -axo pid,ppid,pcpu,pmem,pri,vsz=temp_title_1,rss=temp_title_2,nice,etime=temp_title_3,state,tty,user,time,command -r';
@@ -89,7 +89,7 @@ const parseUsersLinux = (lines, phase) => {
89
89
  const users = async () => {
90
90
  await (0, common_1.nextTick)();
91
91
  let result = [];
92
- let { stdout } = await (0, exec_1.exec)('export LC_ALL=C; who --ips; echo "---"; w; unset LC_ALL | tail -n +2', const_1.execOptsLinux);
92
+ let { stdout } = await (0, exec_1.exec)('export LC_ALL=C.UTF-8; who --ips; echo "---"; w | tail -n +2', const_1.execOptsLinux);
93
93
  let lines = stdout.toString().split('\n');
94
94
  result = parseUsersLinux(lines, 1);
95
95
  if (result.length === 0) {
@@ -43,7 +43,7 @@ const getWifiNetworkListNmi = async () => {
43
43
  const getWifiNetworkListIw = async (networkInterface) => {
44
44
  const result = [];
45
45
  try {
46
- const { stdout } = await (0, exec_1.exec)(`export LC_ALL=C; iwlist ${networkInterface} scan 2>&1; unset LC_ALL`, const_1.execOptsLinux);
46
+ const { stdout } = await (0, exec_1.exec)(`export LC_ALL=C.UTF-8; iwlist ${networkInterface} scan 2>&1; unset LC_ALL`, const_1.execOptsLinux);
47
47
  let iwlistParts = stdout.split(' Cell ');
48
48
  if (iwlistParts[0].indexOf('resource busy') >= 0) {
49
49
  return -1;
@@ -137,7 +137,7 @@ const wifiNetworks = async () => {
137
137
  let result = await getWifiNetworkListNmi();
138
138
  if (result.length === 0) {
139
139
  try {
140
- const { stdout } = await (0, exec_1.exec)('export LC_ALL=C; iwconfig 2>/dev/null; unset LC_ALL', const_1.execOptsLinux);
140
+ const { stdout } = await (0, exec_1.exec)('export LC_ALL=C.UTF-8; iwconfig 2>/dev/null; unset LC_ALL', const_1.execOptsLinux);
141
141
  const iwconfigParts = stdout.split('\n\n');
142
142
  let networkInterface = '';
143
143
  iwconfigParts.forEach((element) => {
@@ -229,7 +229,7 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
229
229
  await (0, common_1.nextTick)();
230
230
  const interfaces = (0, node_os_1.networkInterfaces)();
231
231
  if (JSON.stringify(interfaces) === JSON.stringify(_interfaces) && !rescan) {
232
- return _networkInterfaces;
232
+ return (0, network_1.filterDefaultInterface)(_networkInterfaces, defaultString);
233
233
  }
234
234
  _interfaces = (0, index_1.cloneObj)(interfaces);
235
235
  let result = [];
@@ -336,15 +336,6 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
336
336
  }
337
337
  catch { }
338
338
  _networkInterfaces = result;
339
- if (defaultString.toLowerCase().indexOf('default') >= 0) {
340
- result = result.filter((item) => item.default);
341
- if (result.length > 0) {
342
- return [result[0]];
343
- }
344
- else {
345
- return [];
346
- }
347
- }
348
- return result;
339
+ return (0, network_1.filterDefaultInterface)(result, defaultString);
349
340
  };
350
341
  exports.networkInterfaces = networkInterfaces;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "6.0.0-beta.15",
3
+ "version": "6.0.0-beta.17",
4
4
  "description": "Advanced, lightweight system and OS information library",
5
5
  "license": "MIT",
6
6
  "author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",