systeminformation 6.0.0-beta.8 → 6.0.0-beta.9
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 +1 -0
- package/dist/common/files.d.ts +8 -0
- package/dist/common/files.js +58 -3
- package/dist/common/nvidia.js +2 -1
- package/dist/common/parse.d.ts +4 -6
- package/dist/common/parse.js +24 -69
- package/dist/common/security.d.ts +1 -0
- package/dist/common/security.js +3 -1
- package/dist/common/types.d.ts +1 -2
- package/dist/cpu-current-load.js +5 -5
- package/dist/cpu-current-speed.js +5 -3
- package/dist/darwin/serial-ports.js +2 -1
- package/dist/linux/audio.js +11 -2
- package/dist/linux/baseboard.js +9 -20
- package/dist/linux/bios.js +6 -15
- package/dist/linux/camera.js +2 -1
- package/dist/linux/chassis.js +4 -10
- package/dist/linux/cpu-temperature.js +34 -19
- package/dist/linux/cpu.js +3 -1
- package/dist/linux/disk-layout.js +2 -5
- package/dist/linux/disks-io.js +6 -6
- package/dist/linux/fans.js +3 -2
- package/dist/linux/fs-size.js +120 -26
- package/dist/linux/fs-stats.js +6 -9
- package/dist/linux/gpu.js +2 -1
- package/dist/linux/mem-layout.js +2 -2
- package/dist/linux/network-interfaces.js +10 -29
- package/dist/linux/network-stats.js +1 -1
- package/dist/linux/npu.js +2 -1
- package/dist/linux/os-info.js +19 -4
- package/dist/linux/printer.js +4 -4
- package/dist/linux/process-load.js +9 -12
- package/dist/linux/processes.js +88 -79
- package/dist/linux/serial-ports.js +3 -2
- package/dist/linux/services.js +12 -12
- package/dist/linux/system.js +1 -7
- package/dist/linux/uuid.js +4 -10
- package/dist/windows/process-load.js +5 -4
- package/dist/windows/processes.js +10 -6
- package/package.json +1 -1
package/dist/linux/cpu.js
CHANGED
|
@@ -8,6 +8,7 @@ const const_1 = require("../common/const");
|
|
|
8
8
|
const cpu_1 = require("../common/cpu");
|
|
9
9
|
const defaults_1 = require("../common/defaults");
|
|
10
10
|
const exec_1 = require("../common/exec");
|
|
11
|
+
const files_1 = require("../common/files");
|
|
11
12
|
const mappings_1 = require("../common/mappings");
|
|
12
13
|
const parse_1 = require("../common/parse");
|
|
13
14
|
const raspberry_1 = require("./../common/raspberry");
|
|
@@ -25,8 +26,9 @@ const cpu = async () => {
|
|
|
25
26
|
if ((0, node_os_1.cpus)()[0] && (0, node_os_1.cpus)()[0].model) {
|
|
26
27
|
modelline = (0, node_os_1.cpus)()[0].model;
|
|
27
28
|
}
|
|
28
|
-
let { stdout } = await (0, exec_1.exec)('export LC_ALL=C; lscpu;
|
|
29
|
+
let { stdout } = await (0, exec_1.exec)('export LC_ALL=C; lscpu; unset LC_ALL', const_1.execOptsLinux);
|
|
29
30
|
let lines = stdout.toString().split('\n');
|
|
31
|
+
lines.push(`Governor: ${await (0, files_1.readSysfs)('/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor')}`);
|
|
30
32
|
modelline = (0, common_1.getValue)(lines, 'model name') || modelline;
|
|
31
33
|
modelline = (0, common_1.getValue)(lines, 'bios model name') || modelline;
|
|
32
34
|
modelline = (0, common_1.cleanString)(modelline);
|
|
@@ -4,6 +4,7 @@ exports.diskLayout = void 0;
|
|
|
4
4
|
const common_1 = require("../common");
|
|
5
5
|
const const_1 = require("../common/const");
|
|
6
6
|
const exec_1 = require("../common/exec");
|
|
7
|
+
const files_1 = require("../common/files");
|
|
7
8
|
const filesys_1 = require("../common/filesys");
|
|
8
9
|
const mappings_1 = require("../common/mappings");
|
|
9
10
|
const security_1 = require("../common/security");
|
|
@@ -51,11 +52,7 @@ const diskLayout = async () => {
|
|
|
51
52
|
let mediumType = '';
|
|
52
53
|
const logical = (0, security_1.sanitizeShellString)(device.name || '', true);
|
|
53
54
|
const bsdName = '/dev/' + logical;
|
|
54
|
-
|
|
55
|
-
({ stdout } = await (0, exec_1.exec)('cat /sys/block/' + logical + '/queue/rotational 2>/dev/null', const_1.execOptsLinux));
|
|
56
|
-
mediumType = stdout.split('\n')[0];
|
|
57
|
-
}
|
|
58
|
-
catch { }
|
|
55
|
+
mediumType = (0, security_1.isSafePathSegment)(logical) ? await (0, files_1.readSysfs)(`/sys/block/${logical}/queue/rotational`) : '';
|
|
59
56
|
let interfaceType = device.tran ? device.tran.toUpperCase().trim() : '';
|
|
60
57
|
if (interfaceType === 'NVME') {
|
|
61
58
|
mediumType = '2';
|
package/dist/linux/disks-io.js
CHANGED
|
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.disksIO = void 0;
|
|
4
4
|
const defaults_1 = require("../common/defaults");
|
|
5
5
|
const index_1 = require("../common/index");
|
|
6
|
-
const exec_1 = require("../common/exec");
|
|
7
6
|
const common_1 = require("../common");
|
|
8
7
|
const filesys_1 = require("../common/filesys");
|
|
9
|
-
const
|
|
8
|
+
const promises_1 = require("node:fs/promises");
|
|
9
|
+
const files_1 = require("../common/files");
|
|
10
|
+
const security_1 = require("../common/security");
|
|
10
11
|
const disksIO = async () => {
|
|
11
12
|
await (0, common_1.nextTick)();
|
|
12
13
|
if ((filesys_1._disk_io && !filesys_1._disk_io.ms) || (filesys_1._disk_io && filesys_1._disk_io.ms && Date.now() - filesys_1._disk_io.ms >= 500)) {
|
|
@@ -17,14 +18,13 @@ const disksIO = async () => {
|
|
|
17
18
|
let wWaitTime = 0;
|
|
18
19
|
let tWaitTime = 0;
|
|
19
20
|
try {
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const lines = stdout.split('\n');
|
|
21
|
+
const disks = (await (0, promises_1.readdir)('/sys/block')).filter((dev) => !/^(loop|ram|dm-|md|sr|fd|nbd)/.test(dev) && (0, security_1.isSafePathSegment)(dev));
|
|
22
|
+
const lines = await Promise.all(disks.map((dev) => (0, files_1.readSysfs)(`/sys/block/${dev}/stat`)));
|
|
23
23
|
lines.forEach(function (line) {
|
|
24
24
|
if (!line) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
const stats = line.split(
|
|
27
|
+
const stats = line.trim().split(/\s+/);
|
|
28
28
|
rIO += (0, common_1.toInt)(stats[0]);
|
|
29
29
|
wIO += (0, common_1.toInt)(stats[4]);
|
|
30
30
|
rWaitTime += (0, common_1.toInt)(stats[3]);
|
package/dist/linux/fans.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.fans = void 0;
|
|
|
4
4
|
const promises_1 = require("fs/promises");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const files_1 = require("../common/files");
|
|
7
|
+
const security_1 = require("../common/security");
|
|
7
8
|
const toNumber = (value) => {
|
|
8
9
|
const result = Number.parseFloat(value);
|
|
9
10
|
return Number.isNaN(result) ? null : result;
|
|
@@ -16,7 +17,7 @@ const hwmonFans = async (hwmonPath) => {
|
|
|
16
17
|
const fans = [];
|
|
17
18
|
let nodes = [];
|
|
18
19
|
try {
|
|
19
|
-
nodes = await (0, promises_1.readdir)(hwmonPath);
|
|
20
|
+
nodes = (await (0, promises_1.readdir)(hwmonPath)).filter(security_1.isSafePathSegment);
|
|
20
21
|
}
|
|
21
22
|
catch {
|
|
22
23
|
return fans;
|
|
@@ -55,7 +56,7 @@ const coolingDeviceFans = async (thermalPath) => {
|
|
|
55
56
|
const fans = [];
|
|
56
57
|
let nodes = [];
|
|
57
58
|
try {
|
|
58
|
-
nodes = (await (0, promises_1.readdir)(thermalPath)).filter((entry) => entry.startsWith('cooling_device'));
|
|
59
|
+
nodes = (await (0, promises_1.readdir)(thermalPath)).filter((entry) => entry.startsWith('cooling_device') && (0, security_1.isSafePathSegment)(entry));
|
|
59
60
|
}
|
|
60
61
|
catch {
|
|
61
62
|
return fans;
|
package/dist/linux/fs-size.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fsSize = void 0;
|
|
4
|
+
const promises_1 = require("node:fs/promises");
|
|
4
5
|
const common_1 = require("../common");
|
|
5
6
|
const const_1 = require("../common/const");
|
|
6
7
|
const exec_1 = require("../common/exec");
|
|
8
|
+
const files_1 = require("../common/files");
|
|
7
9
|
let macOsDisks = [];
|
|
8
10
|
let osMounts = {};
|
|
9
11
|
const getmacOsFsType = (fs) => {
|
|
@@ -78,6 +80,107 @@ const parseNixFsSize = (lines) => {
|
|
|
78
80
|
});
|
|
79
81
|
return data;
|
|
80
82
|
};
|
|
83
|
+
const unescapeMount = (value) => value.replace(/\\(\d{3})/g, (_, octal) => String.fromCharCode(parseInt(octal, 8)));
|
|
84
|
+
const statfsSafeTypes = [
|
|
85
|
+
'bcachefs',
|
|
86
|
+
'btrfs',
|
|
87
|
+
'erofs',
|
|
88
|
+
'exfat',
|
|
89
|
+
'ext2',
|
|
90
|
+
'ext3',
|
|
91
|
+
'ext4',
|
|
92
|
+
'efivarfs',
|
|
93
|
+
'f2fs',
|
|
94
|
+
'gfs2',
|
|
95
|
+
'hfs',
|
|
96
|
+
'hfsplus',
|
|
97
|
+
'iso9660',
|
|
98
|
+
'jffs2',
|
|
99
|
+
'jfs',
|
|
100
|
+
'msdos',
|
|
101
|
+
'nilfs2',
|
|
102
|
+
'ntfs',
|
|
103
|
+
'ntfs3',
|
|
104
|
+
'ocfs2',
|
|
105
|
+
'overlay',
|
|
106
|
+
'reiserfs',
|
|
107
|
+
'tmpfs',
|
|
108
|
+
'ubifs',
|
|
109
|
+
'udf',
|
|
110
|
+
'vfat',
|
|
111
|
+
'xfs',
|
|
112
|
+
'zfs'
|
|
113
|
+
];
|
|
114
|
+
const linuxFsSize = async (drives) => {
|
|
115
|
+
const data = [];
|
|
116
|
+
const mounts = await (0, files_1.readFileLines)('/proc/mounts');
|
|
117
|
+
if (!mounts.length) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
const osMountsKnown = Object.keys(osMounts).length > 0;
|
|
121
|
+
for (const line of mounts) {
|
|
122
|
+
const parts = line.split(' ');
|
|
123
|
+
if (parts.length < 4) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const fs = unescapeMount(parts[0]);
|
|
127
|
+
const mount = unescapeMount(parts[1]);
|
|
128
|
+
const type = parts[2];
|
|
129
|
+
if (type === 'squashfs') {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
if (!(fs.startsWith('/') || mount === '/' || fs.indexOf('/') > 0 || fs.indexOf(':') === 1 || !isLinuxTmpFs(type))) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
const [stats, { dev }] = await Promise.all([(0, promises_1.statfs)(mount), (0, promises_1.stat)(mount)]);
|
|
137
|
+
const size = stats.blocks * stats.bsize;
|
|
138
|
+
if (!size) {
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
const used = (stats.blocks - stats.bfree) * stats.bsize;
|
|
142
|
+
const available = stats.bavail * stats.bsize;
|
|
143
|
+
const item = {
|
|
144
|
+
dev,
|
|
145
|
+
entry: {
|
|
146
|
+
fs,
|
|
147
|
+
type,
|
|
148
|
+
size,
|
|
149
|
+
used,
|
|
150
|
+
available,
|
|
151
|
+
use: parseFloat((100.0 * (used / (used + available))).toFixed(2)),
|
|
152
|
+
mount,
|
|
153
|
+
rw: osMountsKnown ? osMounts[fs] || false : null
|
|
154
|
+
},
|
|
155
|
+
trusted: statfsSafeTypes.includes(type)
|
|
156
|
+
};
|
|
157
|
+
const duplicate = data.findIndex((el) => el.dev === dev);
|
|
158
|
+
if (duplicate >= 0) {
|
|
159
|
+
if (data[duplicate].entry.mount.length > mount.length) {
|
|
160
|
+
data[duplicate] = item;
|
|
161
|
+
}
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
data.push(item);
|
|
165
|
+
}
|
|
166
|
+
catch { }
|
|
167
|
+
}
|
|
168
|
+
if (!data.length) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
const requested = data.filter((item) => matchesDrives(item.entry.fs, item.entry.mount, drives));
|
|
172
|
+
if (requested.some((item) => !item.trusted)) {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
return requested.map((item) => item.entry);
|
|
176
|
+
};
|
|
177
|
+
const matchesDrives = (fs, mount, drives) => {
|
|
178
|
+
if (!drives.length) {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
return drives.some((drive) => fs.toLowerCase().indexOf(drive.toLowerCase()) >= 0 || mount.toLowerCase().indexOf(drive.toLowerCase()) >= 0);
|
|
182
|
+
};
|
|
183
|
+
const filterDrives = (data, drives) => data.filter((item) => matchesDrives(item.fs, item.mount, drives));
|
|
81
184
|
const fsSize = async (drives) => {
|
|
82
185
|
await (0, common_1.nextTick)();
|
|
83
186
|
let data = [];
|
|
@@ -107,23 +210,21 @@ const fsSize = async (drives) => {
|
|
|
107
210
|
catch { }
|
|
108
211
|
}
|
|
109
212
|
if (const_1.LINUX) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const fs = line.split(' ')[0].replace(/\\(\d{3})/g, (_, octal) => String.fromCharCode(parseInt(octal, 8)));
|
|
120
|
-
osMounts[fs] = osMounts[fs] || false;
|
|
121
|
-
if (line.indexOf('/snap/') === -1) {
|
|
122
|
-
osMounts[fs] = line.toLowerCase().indexOf('rw,') >= 0 || line.toLowerCase().indexOf(' rw ') >= 0;
|
|
123
|
-
}
|
|
124
|
-
});
|
|
213
|
+
for (const line of await (0, files_1.readFileLines)('/proc/mounts')) {
|
|
214
|
+
if (!line.startsWith('/')) {
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
const fs = unescapeMount(line.split(' ')[0]);
|
|
218
|
+
osMounts[fs] = osMounts[fs] || false;
|
|
219
|
+
if (line.indexOf('/snap/') === -1) {
|
|
220
|
+
osMounts[fs] = line.toLowerCase().indexOf('rw,') >= 0 || line.toLowerCase().indexOf(' rw ') >= 0;
|
|
221
|
+
}
|
|
125
222
|
}
|
|
126
|
-
|
|
223
|
+
const linuxData = await linuxFsSize(drives);
|
|
224
|
+
if (linuxData) {
|
|
225
|
+
return linuxData;
|
|
226
|
+
}
|
|
227
|
+
cmd = 'export LC_ALL=C; df -kPTx squashfs; unset LC_ALL';
|
|
127
228
|
}
|
|
128
229
|
if (const_1.FREEBSD || const_1.NETBSD || const_1.OPENBSD) {
|
|
129
230
|
try {
|
|
@@ -135,23 +236,16 @@ const fsSize = async (drives) => {
|
|
|
135
236
|
}
|
|
136
237
|
catch { }
|
|
137
238
|
}
|
|
138
|
-
({ stdout, stderr } = await (0, exec_1.
|
|
239
|
+
({ stdout, stderr } = await (0, exec_1.execSave)(cmd, const_1.execOptsLinux));
|
|
139
240
|
if (!stderr) {
|
|
140
241
|
lines = filterFsLines(stdout);
|
|
141
242
|
data = parseNixFsSize(lines);
|
|
142
243
|
}
|
|
143
244
|
else {
|
|
144
|
-
({ stdout } = await (0, exec_1.
|
|
245
|
+
({ stdout } = await (0, exec_1.execSave)('df -kPT 2>/dev/null', const_1.execOptsLinux));
|
|
145
246
|
lines = filterFsLines(stdout);
|
|
146
247
|
data = parseNixFsSize(lines);
|
|
147
248
|
}
|
|
148
|
-
|
|
149
|
-
data = data.filter((item) => {
|
|
150
|
-
return drives.some((drive) => {
|
|
151
|
-
return item.fs.toLowerCase().indexOf(drive.toLowerCase()) >= 0 || item.mount.toLowerCase().indexOf(drive.toLowerCase()) >= 0;
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
return data;
|
|
249
|
+
return filterDrives(data, drives);
|
|
156
250
|
};
|
|
157
251
|
exports.fsSize = fsSize;
|
package/dist/linux/fs-stats.js
CHANGED
|
@@ -6,6 +6,7 @@ const index_1 = require("../common/index");
|
|
|
6
6
|
const exec_1 = require("../common/exec");
|
|
7
7
|
const common_1 = require("../common");
|
|
8
8
|
const filesys_1 = require("../common/filesys");
|
|
9
|
+
const files_1 = require("../common/files");
|
|
9
10
|
const security_1 = require("../common/security");
|
|
10
11
|
const const_1 = require("../common/const");
|
|
11
12
|
const fsStats = async () => {
|
|
@@ -16,8 +17,8 @@ const fsStats = async () => {
|
|
|
16
17
|
let rx = 0;
|
|
17
18
|
let wx = 0;
|
|
18
19
|
try {
|
|
19
|
-
({ stdout } = await (0, exec_1.exec)('lsblk -r 2>/dev/null
|
|
20
|
-
const lines = stdout.toString().split('\n');
|
|
20
|
+
({ stdout } = await (0, exec_1.exec)('lsblk -r 2>/dev/null', const_1.execOptsLinux));
|
|
21
|
+
const lines = stdout.toString().split('\n').filter((line) => line.indexOf('/') >= 0);
|
|
21
22
|
const fs_filter = [];
|
|
22
23
|
lines.forEach((line) => {
|
|
23
24
|
if (line !== '') {
|
|
@@ -28,14 +29,10 @@ const fsStats = async () => {
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
});
|
|
31
|
-
const output = fs_filter.join('|');
|
|
32
32
|
try {
|
|
33
|
-
(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
line = line.trim();
|
|
37
|
-
if (line !== '') {
|
|
38
|
-
const lineParts = line.replace(/ +/g, ' ').split(' ');
|
|
33
|
+
(await (0, files_1.readFileLines)('/proc/diskstats')).forEach((line) => {
|
|
34
|
+
const lineParts = line.trim().split(/\s+/);
|
|
35
|
+
if (fs_filter.indexOf(lineParts[2]) >= 0) {
|
|
39
36
|
rx += (0, common_1.toInt)(lineParts[5]) * 512;
|
|
40
37
|
wx += (0, common_1.toInt)(lineParts[9]) * 512;
|
|
41
38
|
}
|
package/dist/linux/gpu.js
CHANGED
|
@@ -8,6 +8,7 @@ const exec_1 = require("../common/exec");
|
|
|
8
8
|
const files_1 = require("../common/files");
|
|
9
9
|
const nvidia_1 = require("../common/nvidia");
|
|
10
10
|
const raspberry_1 = require("../common/raspberry");
|
|
11
|
+
const security_1 = require("../common/security");
|
|
11
12
|
const readSysfsNumber = async (files, divisor = 1, preferNonZero = false) => {
|
|
12
13
|
let fallback = null;
|
|
13
14
|
for (const file of files) {
|
|
@@ -51,7 +52,7 @@ const drmDevices = async (drmPath = '/sys/class/drm') => {
|
|
|
51
52
|
}
|
|
52
53
|
let hwmon = [];
|
|
53
54
|
try {
|
|
54
|
-
hwmon = (await (0, promises_1.readdir)(`${devicePath}/hwmon`)).map((node) => `${devicePath}/hwmon/${node}`);
|
|
55
|
+
hwmon = (await (0, promises_1.readdir)(`${devicePath}/hwmon`)).filter(security_1.isSafePathSegment).map((node) => `${devicePath}/hwmon/${node}`);
|
|
55
56
|
}
|
|
56
57
|
catch { }
|
|
57
58
|
const clockCore = await readSysfsNumber([
|
package/dist/linux/mem-layout.js
CHANGED
|
@@ -5,6 +5,7 @@ const node_os_1 = require("node:os");
|
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const const_1 = require("../common/const");
|
|
7
7
|
const exec_1 = require("../common/exec");
|
|
8
|
+
const files_1 = require("../common/files");
|
|
8
9
|
const mappings_1 = require("../common/mappings");
|
|
9
10
|
const raspberry_1 = require("../common/raspberry");
|
|
10
11
|
const memLayout = async () => {
|
|
@@ -78,8 +79,7 @@ const memLayout = async () => {
|
|
|
78
79
|
voltageMin: null,
|
|
79
80
|
voltageMax: null
|
|
80
81
|
});
|
|
81
|
-
|
|
82
|
-
let lines = stdout.split('\n');
|
|
82
|
+
let lines = await (0, files_1.readFileLines)('/proc/cpuinfo');
|
|
83
83
|
const version = (0, common_1.getValue)(lines, 'revision', ':', true).toLowerCase();
|
|
84
84
|
if (await (0, raspberry_1.isRaspberry)(lines)) {
|
|
85
85
|
result[0].type = 'LPDDR2';
|
|
@@ -8,6 +8,7 @@ const common_1 = require("../common");
|
|
|
8
8
|
const const_1 = require("../common/const");
|
|
9
9
|
const defaults_1 = require("../common/defaults");
|
|
10
10
|
const exec_1 = require("../common/exec");
|
|
11
|
+
const files_1 = require("../common/files");
|
|
11
12
|
const index_1 = require("../common/index");
|
|
12
13
|
const network_1 = require("../common/network");
|
|
13
14
|
const security_1 = require("../common/security");
|
|
@@ -51,7 +52,7 @@ const readInterfacesLines = async (file) => {
|
|
|
51
52
|
if (file.includes('*') || file.includes('?')) {
|
|
52
53
|
try {
|
|
53
54
|
const rx = new RegExp(`^${(0, node_path_1.basename)(file).replace(/\./g, '\\.').replace(/\*/g, '.*').replace(/\?/g, '.')}$`);
|
|
54
|
-
const names = (await (0, promises_1.readdir)((0, node_path_1.dirname)(file))).filter((n) => rx.test(n)).sort();
|
|
55
|
+
const names = (await (0, promises_1.readdir)((0, node_path_1.dirname)(file))).filter((n) => rx.test(n) && (0, security_1.isSafePathSegment)(n)).sort();
|
|
55
56
|
const out = [];
|
|
56
57
|
for (const n of names) {
|
|
57
58
|
out.push(...(await readInterfacesLines((0, node_path_1.join)((0, node_path_1.dirname)(file), n))));
|
|
@@ -268,35 +269,16 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
268
269
|
}
|
|
269
270
|
const ifaceDevName = dev.split(':')[0].trim();
|
|
270
271
|
const ifaceSanitized = (0, security_1.sanitizeString)(ifaceDevName, true);
|
|
271
|
-
const cmd = `echo -n "addr_assign_type: "; cat /sys/class/net/${ifaceSanitized}/addr_assign_type 2>/dev/null; echo;
|
|
272
|
-
echo -n "address: "; cat /sys/class/net/${ifaceSanitized}/address 2>/dev/null; echo;
|
|
273
|
-
echo -n "addr_len: "; cat /sys/class/net/${ifaceSanitized}/addr_len 2>/dev/null; echo;
|
|
274
|
-
echo -n "broadcast: "; cat /sys/class/net/${ifaceSanitized}/broadcast 2>/dev/null; echo;
|
|
275
|
-
echo -n "carrier: "; cat /sys/class/net/${ifaceSanitized}/carrier 2>/dev/null; echo;
|
|
276
|
-
echo -n "carrier_changes: "; cat /sys/class/net/${ifaceSanitized}/carrier_changes 2>/dev/null; echo;
|
|
277
|
-
echo -n "dev_id: "; cat /sys/class/net/${ifaceSanitized}/dev_id 2>/dev/null; echo;
|
|
278
|
-
echo -n "dev_port: "; cat /sys/class/net/${ifaceSanitized}/dev_port 2>/dev/null; echo;
|
|
279
|
-
echo -n "dormant: "; cat /sys/class/net/${ifaceSanitized}/dormant 2>/dev/null; echo;
|
|
280
|
-
echo -n "duplex: "; cat /sys/class/net/${ifaceSanitized}/duplex 2>/dev/null; echo;
|
|
281
|
-
echo -n "flags: "; cat /sys/class/net/${ifaceSanitized}/flags 2>/dev/null; echo;
|
|
282
|
-
echo -n "gro_flush_timeout: "; cat /sys/class/net/${ifaceSanitized}/gro_flush_timeout 2>/dev/null; echo;
|
|
283
|
-
echo -n "ifalias: "; cat /sys/class/net/${ifaceSanitized}/ifalias 2>/dev/null; echo;
|
|
284
|
-
echo -n "ifindex: "; cat /sys/class/net/${ifaceSanitized}/ifindex 2>/dev/null; echo;
|
|
285
|
-
echo -n "iflink: "; cat /sys/class/net/${ifaceSanitized}/iflink 2>/dev/null; echo;
|
|
286
|
-
echo -n "link_mode: "; cat /sys/class/net/${ifaceSanitized}/link_mode 2>/dev/null; echo;
|
|
287
|
-
echo -n "mtu: "; cat /sys/class/net/${ifaceSanitized}/mtu 2>/dev/null; echo;
|
|
288
|
-
echo -n "netdev_group: "; cat /sys/class/net/${ifaceSanitized}/netdev_group 2>/dev/null; echo;
|
|
289
|
-
echo -n "operstate: "; cat /sys/class/net/${ifaceSanitized}/operstate 2>/dev/null; echo;
|
|
290
|
-
echo -n "proto_down: "; cat /sys/class/net/${ifaceSanitized}/proto_down 2>/dev/null; echo;
|
|
291
|
-
echo -n "speed: "; cat /sys/class/net/${ifaceSanitized}/speed 2>/dev/null; echo;
|
|
292
|
-
echo -n "tx_queue_len: "; cat /sys/class/net/${ifaceSanitized}/tx_queue_len 2>/dev/null; echo;
|
|
293
|
-
echo -n "type: "; cat /sys/class/net/${ifaceSanitized}/type 2>/dev/null; echo;
|
|
294
|
-
echo -n "wireless: "; cat /proc/net/wireless 2>/dev/null | grep ${ifaceSanitized}; echo;
|
|
295
|
-
echo -n "wirelessspeed: "; iw dev ${ifaceSanitized} link 2>&1 | grep bitrate; echo;`;
|
|
296
272
|
let lines = [];
|
|
297
273
|
try {
|
|
298
|
-
const
|
|
299
|
-
|
|
274
|
+
const [sysfsLines, wirelessLines, iwOut] = await Promise.all([
|
|
275
|
+
(0, security_1.isSafePathSegment)(ifaceSanitized) ? (0, files_1.readSysfsMany)(`/sys/class/net/${ifaceSanitized}`, ['address', 'carrier_changes', 'duplex', 'mtu', 'operstate', 'speed', 'type']) : [],
|
|
276
|
+
(0, files_1.readFileLines)('/proc/net/wireless'),
|
|
277
|
+
(0, exec_1.execSecure)('iw', ['dev', ifaceSanitized, 'link'])
|
|
278
|
+
]);
|
|
279
|
+
lines = sysfsLines;
|
|
280
|
+
lines.push(`wireless: ${wirelessLines.find((line) => line.indexOf(ifaceSanitized) >= 0) || ''}`);
|
|
281
|
+
lines.push(...iwOut.split('\n').filter((line) => line.indexOf('bitrate') >= 0).map((line) => line.trim()));
|
|
300
282
|
const connectionName = getLinuxIfaceConnectionName(deviceStatus, ifaceSanitized);
|
|
301
283
|
dhcp = await getLinuxIfaceDHCPstatus(ifaceSanitized, connectionName, _dhcpNics);
|
|
302
284
|
dnsSuffix = await getLinuxIfaceDNSsuffix(connectionName);
|
|
@@ -305,7 +287,6 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
305
287
|
}
|
|
306
288
|
catch { }
|
|
307
289
|
duplex = (0, common_1.getValue)(lines, 'duplex');
|
|
308
|
-
duplex = duplex.startsWith('cat') ? '' : duplex;
|
|
309
290
|
mtu = (0, common_1.toInt)((0, common_1.getValue)(lines, 'mtu'));
|
|
310
291
|
let myspeed = (0, common_1.toInt)((0, common_1.getValue)(lines, 'speed'));
|
|
311
292
|
speed = Number.isNaN(myspeed) ? null : myspeed;
|
|
@@ -13,7 +13,7 @@ const networkStatsSingle = async (iface) => {
|
|
|
13
13
|
const defaults = { ...defaults_1.initNetworkSpeed, iface };
|
|
14
14
|
if (!_network[iface] || (_network[iface] && !_network[iface].ms) || (_network[iface] && _network[iface].ms && Date.now() - _network[iface].ms >= 500)) {
|
|
15
15
|
const dir = '/sys/class/net/' + iface;
|
|
16
|
-
if (
|
|
16
|
+
if ((0, security_1.isSafePathSegment)(iface) && (await (0, files_1.fileExists)(dir))) {
|
|
17
17
|
const [operstate, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_dropped, tx_errors] = await Promise.all([
|
|
18
18
|
(0, files_1.readSysfs)(dir + '/operstate'),
|
|
19
19
|
...['rx_bytes', 'tx_bytes', 'rx_dropped', 'rx_errors', 'tx_dropped', 'tx_errors'].map(async (f) => (0, common_1.toInt)(await (0, files_1.readSysfs)(dir + '/statistics/' + f)))
|
package/dist/linux/npu.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.npu = void 0;
|
|
|
4
4
|
const promises_1 = require("node:fs/promises");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const defaults_1 = require("../common/defaults");
|
|
7
|
+
const security_1 = require("../common/security");
|
|
7
8
|
const ACCEL_PATH = '/sys/class/accel';
|
|
8
9
|
const readAttr = async (path) => {
|
|
9
10
|
try {
|
|
@@ -41,7 +42,7 @@ const npu = async () => {
|
|
|
41
42
|
const result = [];
|
|
42
43
|
const seen = new Set();
|
|
43
44
|
try {
|
|
44
|
-
const nodes = (await (0, promises_1.readdir)(ACCEL_PATH)).filter((node) => node.startsWith('accel')).sort();
|
|
45
|
+
const nodes = (await (0, promises_1.readdir)(ACCEL_PATH)).filter((node) => node.startsWith('accel') && (0, security_1.isSafePathSegment)(node)).sort();
|
|
45
46
|
for (const node of nodes) {
|
|
46
47
|
let dev;
|
|
47
48
|
try {
|
package/dist/linux/os-info.js
CHANGED
|
@@ -6,9 +6,11 @@ const codepage_1 = require("../common/codepage");
|
|
|
6
6
|
const const_1 = require("../common/const");
|
|
7
7
|
const defaults_1 = require("../common/defaults");
|
|
8
8
|
const exec_1 = require("../common/exec");
|
|
9
|
+
const promises_1 = require("node:fs/promises");
|
|
9
10
|
const files_1 = require("../common/files");
|
|
10
11
|
const mappings_1 = require("../common/mappings");
|
|
11
12
|
const uuid_1 = require("./uuid");
|
|
13
|
+
const security_1 = require("../common/security");
|
|
12
14
|
const getInstallDate = async () => {
|
|
13
15
|
try {
|
|
14
16
|
const { stdout } = await (0, exec_1.exec)('stat -c %W / 2>/dev/null', const_1.execOptsLinux);
|
|
@@ -19,8 +21,8 @@ const getInstallDate = async () => {
|
|
|
19
21
|
}
|
|
20
22
|
catch { }
|
|
21
23
|
try {
|
|
22
|
-
const
|
|
23
|
-
const dev =
|
|
24
|
+
const rootMount = (await (0, files_1.readFileLines)('/proc/mounts')).filter((line) => line.split(' ')[1] === '/').pop() || '';
|
|
25
|
+
const dev = rootMount.split(' ')[0] || '';
|
|
24
26
|
if (/^\/dev\/[\w./-]+$/.test(dev)) {
|
|
25
27
|
const { stdout } = await (0, exec_1.exec)(`tune2fs -l ${dev} 2>/dev/null`, const_1.execOptsLinux);
|
|
26
28
|
const line = stdout
|
|
@@ -105,8 +107,21 @@ const osInfo = async () => {
|
|
|
105
107
|
await (0, common_1.nextTick)();
|
|
106
108
|
const defaults = (0, common_1.cloneObj)(await (0, defaults_1.initOsInfo)());
|
|
107
109
|
try {
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
+
const releaseFiles = (await (0, promises_1.readdir)('/etc').catch(() => [])).filter((file) => file.endsWith('-release') && (0, security_1.isSafePathSegment)(file)).sort();
|
|
111
|
+
const files = [...releaseFiles.map((file) => `/etc/${file}`), '/usr/lib/os-release', '/etc/openwrt_release'];
|
|
112
|
+
let budget = 1024 * 1024;
|
|
113
|
+
const parts = [];
|
|
114
|
+
for (const file of files) {
|
|
115
|
+
if (budget <= 0) {
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
const content = await (0, files_1.readFileMax)(file, budget);
|
|
119
|
+
if (content) {
|
|
120
|
+
parts.push(content);
|
|
121
|
+
budget -= content.length;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return await parseOsInfo(parts.join('\n') + '\n', defaults);
|
|
110
125
|
}
|
|
111
126
|
catch { }
|
|
112
127
|
return defaults;
|
package/dist/linux/printer.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.printer = void 0;
|
|
4
|
-
const exec_1 = require("
|
|
4
|
+
const exec_1 = require("../common/exec");
|
|
5
|
+
const files_1 = require("../common/files");
|
|
5
6
|
const common_1 = require("../common");
|
|
6
7
|
const const_1 = require("../common/const");
|
|
7
8
|
const parseLinuxCupsHeader = (lines) => {
|
|
@@ -48,8 +49,7 @@ const parseLinuxLpstatPrinter = (lines, id) => {
|
|
|
48
49
|
const printer = async () => {
|
|
49
50
|
await (0, common_1.nextTick)();
|
|
50
51
|
const result = [];
|
|
51
|
-
|
|
52
|
-
const parts = stdout.toString().split('<Printer ');
|
|
52
|
+
const parts = (await (0, files_1.readFileMax)('/etc/cups/printers.conf')).split('<Printer ');
|
|
53
53
|
const printerHeader = parseLinuxCupsHeader(parts[0].split('\n'));
|
|
54
54
|
for (let i = 1; i < parts.length; i++) {
|
|
55
55
|
const printers = parseLinuxCupsPrinter(parts[i].split('\n'));
|
|
@@ -61,7 +61,7 @@ const printer = async () => {
|
|
|
61
61
|
}
|
|
62
62
|
if (result.length === 0) {
|
|
63
63
|
if (const_1.LINUX) {
|
|
64
|
-
|
|
64
|
+
const { stdout } = await (0, exec_1.execSave)('export LC_ALL=C; 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);
|
|
@@ -6,6 +6,7 @@ const const_1 = require("../common/const");
|
|
|
6
6
|
const common_1 = require("../common");
|
|
7
7
|
const security_1 = require("../common/security");
|
|
8
8
|
const parse_1 = require("../common/parse");
|
|
9
|
+
const files_1 = require("../common/files");
|
|
9
10
|
const _process_cpu = {
|
|
10
11
|
all: 0,
|
|
11
12
|
all_utime: 0,
|
|
@@ -108,19 +109,17 @@ const processLoad = async (proc) => {
|
|
|
108
109
|
result.forEach(function (item) {
|
|
109
110
|
item.cpu = 0;
|
|
110
111
|
});
|
|
111
|
-
|
|
112
|
+
const pids = [];
|
|
112
113
|
for (const i in result) {
|
|
113
|
-
|
|
114
|
-
cmd += ';cat /proc/' + result[i].pids[j] + '/stat';
|
|
115
|
-
}
|
|
114
|
+
pids.push(...result[i].pids);
|
|
116
115
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const all = (0, parse_1.parseProcStat)(
|
|
120
|
-
curr_processes =
|
|
116
|
+
const cpuBaseline = { ..._process_cpu };
|
|
117
|
+
const stats = await (0, files_1.readProcStats)(pids);
|
|
118
|
+
const all = (0, parse_1.parseProcStat)(stats.all);
|
|
119
|
+
const curr_processes = stats.procs;
|
|
121
120
|
const list_new = {};
|
|
122
121
|
curr_processes.forEach((element) => {
|
|
123
|
-
const resultProcess = (0, parse_1.calcProcStatLinux)(element, all,
|
|
122
|
+
const resultProcess = (0, parse_1.calcProcStatLinux)(element, all, cpuBaseline);
|
|
124
123
|
if (resultProcess.pid) {
|
|
125
124
|
let resultItemId = -1;
|
|
126
125
|
for (let i = 0; i < result.length; i++) {
|
|
@@ -135,9 +134,7 @@ const processLoad = async (proc) => {
|
|
|
135
134
|
cpuu: resultProcess.cpuu,
|
|
136
135
|
cpus: resultProcess.cpus,
|
|
137
136
|
utime: resultProcess.utime,
|
|
138
|
-
stime: resultProcess.stime
|
|
139
|
-
cutime: resultProcess.cutime,
|
|
140
|
-
cstime: resultProcess.cstime
|
|
137
|
+
stime: resultProcess.stime
|
|
141
138
|
};
|
|
142
139
|
}
|
|
143
140
|
});
|