networkConnections() fix missing PIDs ss command (linux)
This commit is contained in:
parent
7797367bc3
commit
e717459a95
@ -90,6 +90,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
|
||||
|
||||
| Version | Date | Comment |
|
||||
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
|
||||
| 5.28.2 | 2025-12-27 | `networkConnections()` fix missing PIDs ss command (linux) |
|
||||
| 5.28.1 | 2025-12-26 | `networkInterface()` fix secondary and link-local ip (linux, macOS) |
|
||||
| 5.28.0 | 2025-12-25 | `cpuTemperature()` added suppurt for macos-temperature-sensor (macOS) |
|
||||
| 5.27.17 | 2025-12-24 | `graphics()` fix nvidia-smi candidateDir (windows) |
|
||||
|
||||
@ -57,6 +57,11 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">5.28.2</th>
|
||||
<td>2025-12-27</td>
|
||||
<td><span class="code">networkConnections()</span> fix missing PIDs ss command (linux)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">5.28.1</th>
|
||||
<td>2025-12-26</td>
|
||||
|
||||
@ -170,7 +170,7 @@
|
||||
<img class="logo" src="assets/logo.png" alt="logo">
|
||||
<div class="title">systeminformation</div>
|
||||
<div class="subtitle"><span id="typed"></span> </div>
|
||||
<div class="version">New Version: <span id="version">5.28.1</span></div>
|
||||
<div class="version">New Version: <span id="version">5.28.2</span></div>
|
||||
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
|
||||
</div>
|
||||
<div class="down">
|
||||
|
||||
@ -19,7 +19,7 @@ const execSync = require('child_process').execSync;
|
||||
const fs = require('fs');
|
||||
const util = require('./util');
|
||||
|
||||
let _platform = process.platform;
|
||||
const _platform = process.platform;
|
||||
|
||||
const _linux = _platform === 'linux' || _platform === 'android';
|
||||
const _darwin = _platform === 'darwin';
|
||||
@ -29,7 +29,7 @@ const _openbsd = _platform === 'openbsd';
|
||||
const _netbsd = _platform === 'netbsd';
|
||||
const _sunos = _platform === 'sunos';
|
||||
|
||||
let _network = {};
|
||||
const _network = {};
|
||||
let _default_iface = '';
|
||||
let _ifaces = {};
|
||||
let _dhcpNics = [];
|
||||
@ -41,14 +41,14 @@ function getDefaultNetworkInterface() {
|
||||
let ifacename = '';
|
||||
let ifacenameFirst = '';
|
||||
try {
|
||||
let ifaces = os.networkInterfaces();
|
||||
const ifaces = os.networkInterfaces();
|
||||
|
||||
let scopeid = 9999;
|
||||
|
||||
// fallback - "first" external interface (sorted by scopeid)
|
||||
for (let dev in ifaces) {
|
||||
if ({}.hasOwnProperty.call(ifaces, dev)) {
|
||||
ifaces[dev].forEach(function (details) {
|
||||
ifaces[dev].forEach((details) => {
|
||||
if (details && details.internal === false) {
|
||||
ifacenameFirst = ifacenameFirst || dev; // fallback if no scopeid
|
||||
if (details.scopeid && details.scopeid < scopeid) {
|
||||
@ -79,7 +79,7 @@ function getDefaultNetworkInterface() {
|
||||
if (defaultIp) {
|
||||
for (let dev in ifaces) {
|
||||
if ({}.hasOwnProperty.call(ifaces, dev)) {
|
||||
ifaces[dev].forEach(function (details) {
|
||||
ifaces[dev].forEach((details) => {
|
||||
if (details && details.address && details.address === defaultIp) {
|
||||
ifacename = dev;
|
||||
}
|
||||
@ -89,9 +89,9 @@ function getDefaultNetworkInterface() {
|
||||
}
|
||||
}
|
||||
if (_linux) {
|
||||
let cmd = 'ip route 2> /dev/null | grep default';
|
||||
let result = execSync(cmd, util.execOptsLinux);
|
||||
let parts = result.toString().split('\n')[0].split(/\s+/);
|
||||
const cmd = 'ip route 2> /dev/null | grep default';
|
||||
const result = execSync(cmd, util.execOptsLinux);
|
||||
const parts = result.toString().split('\n')[0].split(/\s+/);
|
||||
if (parts[0] === 'none' && parts[5]) {
|
||||
ifacename = parts[5];
|
||||
} else if (parts[4]) {
|
||||
@ -113,7 +113,7 @@ function getDefaultNetworkInterface() {
|
||||
if (_freebsd || _openbsd || _netbsd || _sunos) {
|
||||
cmd = 'route get 0.0.0.0 | grep interface:';
|
||||
}
|
||||
let result = execSync(cmd);
|
||||
const result = execSync(cmd);
|
||||
ifacename = result.toString().split('\n')[0];
|
||||
if (ifacename.indexOf(':') > -1) {
|
||||
ifacename = ifacename.split(':')[1].trim();
|
||||
@ -133,7 +133,7 @@ exports.getDefaultNetworkInterface = getDefaultNetworkInterface;
|
||||
function getMacAddresses() {
|
||||
let iface = '';
|
||||
let mac = '';
|
||||
let result = {};
|
||||
const result = {};
|
||||
if (_linux || _freebsd || _openbsd || _netbsd) {
|
||||
if (typeof pathToIp === 'undefined') {
|
||||
try {
|
||||
@ -149,12 +149,12 @@ function getMacAddresses() {
|
||||
}
|
||||
try {
|
||||
const cmd = 'export LC_ALL=C; ' + (pathToIp ? pathToIp + ' link show up' : '/sbin/ifconfig') + '; unset LC_ALL';
|
||||
let res = execSync(cmd, util.execOptsLinux);
|
||||
const res = execSync(cmd, util.execOptsLinux);
|
||||
const lines = res.toString().split('\n');
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
if (lines[i] && lines[i][0] !== ' ') {
|
||||
if (pathToIp) {
|
||||
let nextline = lines[i + 1].trim().split(' ');
|
||||
const nextline = lines[i + 1].trim().split(' ');
|
||||
if (nextline[0] === 'link/ether') {
|
||||
iface = lines[i].split(' ')[1];
|
||||
iface = iface.slice(0, iface.length - 1);
|
||||
@ -203,7 +203,7 @@ function getMacAddresses() {
|
||||
function networkInterfaceDefault(callback) {
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
let result = getDefaultNetworkInterface();
|
||||
const result = getDefaultNetworkInterface();
|
||||
if (callback) {
|
||||
callback(result);
|
||||
}
|
||||
@ -218,7 +218,7 @@ exports.networkInterfaceDefault = networkInterfaceDefault;
|
||||
// NET - interfaces
|
||||
|
||||
function parseLinesWindowsNics(sections, nconfigsections) {
|
||||
let nics = [];
|
||||
const nics = [];
|
||||
for (let i in sections) {
|
||||
try {
|
||||
if ({}.hasOwnProperty.call(sections, i)) {
|
||||
@ -230,10 +230,10 @@ function parseLinesWindowsNics(sections, nconfigsections) {
|
||||
} catch (e) {
|
||||
util.noop();
|
||||
}
|
||||
let netEnabled = util.getValue(lines, 'NetEnabled', ':');
|
||||
const netEnabled = util.getValue(lines, 'NetEnabled', ':');
|
||||
let adapterType = util.getValue(lines, 'AdapterTypeID', ':') === '9' ? 'wireless' : 'wired';
|
||||
let ifacename = util.getValue(lines, 'Name', ':').replace(/\]/g, ')').replace(/\[/g, '(');
|
||||
let iface = util.getValue(lines, 'NetConnectionID', ':').replace(/\]/g, ')').replace(/\[/g, '(');
|
||||
const ifacename = util.getValue(lines, 'Name', ':').replace(/\]/g, ')').replace(/\[/g, '(');
|
||||
const iface = util.getValue(lines, 'NetConnectionID', ':').replace(/\]/g, ')').replace(/\[/g, '(');
|
||||
if (ifacename.toLowerCase().indexOf('wi-fi') >= 0 || ifacename.toLowerCase().indexOf('wireless') >= 0) {
|
||||
adapterType = 'wireless';
|
||||
}
|
||||
@ -448,7 +448,7 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) {
|
||||
function splitSectionsNics(lines) {
|
||||
const result = [];
|
||||
let section = [];
|
||||
lines.forEach(function (line) {
|
||||
lines.forEach((line) => {
|
||||
if (!line.startsWith('\t') && !line.startsWith(' ')) {
|
||||
if (section.length) {
|
||||
result.push(section);
|
||||
@ -480,7 +480,7 @@ function parseLinesDarwinNics(sections) {
|
||||
};
|
||||
const first = section[0];
|
||||
nic.iface = first.split(':')[0].trim();
|
||||
let parts = first.split('> mtu');
|
||||
const parts = first.split('> mtu');
|
||||
nic.mtu = parts.length > 1 ? parseInt(parts[1], 10) : null;
|
||||
if (isNaN(nic.mtu)) {
|
||||
nic.mtu = null;
|
||||
@ -562,7 +562,7 @@ function checkLinuxDCHPInterfaces(file) {
|
||||
}
|
||||
}
|
||||
if (line.toLowerCase().includes('source')) {
|
||||
let file = line.split(' ')[1];
|
||||
const file = line.split(' ')[1];
|
||||
result = result.concat(checkLinuxDCHPInterfaces(file));
|
||||
}
|
||||
});
|
||||
@ -574,7 +574,7 @@ function checkLinuxDCHPInterfaces(file) {
|
||||
|
||||
function getLinuxDHCPNics() {
|
||||
// alternate methods getting interfaces using DHCP
|
||||
let cmd = 'ip a 2> /dev/null';
|
||||
const cmd = 'ip a 2> /dev/null';
|
||||
let result = [];
|
||||
try {
|
||||
const lines = execSync(cmd, util.execOptsLinux).toString().split('\n');
|
||||
@ -621,7 +621,7 @@ function getLinuxIfaceDHCPstatus(iface, connectionName, DHCPNics) {
|
||||
const lines = execSync(cmd, util.execOptsLinux).toString();
|
||||
const resultFormat = lines.replace(/\s+/g, ' ').trim();
|
||||
|
||||
let dhcStatus = resultFormat.split(' ').slice(1).toString();
|
||||
const dhcStatus = resultFormat.split(' ').slice(1).toString();
|
||||
switch (dhcStatus) {
|
||||
case 'auto':
|
||||
result = true;
|
||||
@ -762,7 +762,7 @@ function networkInterfaces(callback, rescan, defaultString) {
|
||||
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
let ifaces = os.networkInterfaces();
|
||||
const ifaces = os.networkInterfaces();
|
||||
|
||||
let result = [];
|
||||
let nics = [];
|
||||
@ -1066,7 +1066,7 @@ function networkInterfaces(callback, rescan, defaultString) {
|
||||
_ifaces = JSON.parse(JSON.stringify(ifaces));
|
||||
const defaultInterface = getDefaultNetworkInterface();
|
||||
|
||||
getWindowsNics().then(function (nics) {
|
||||
getWindowsNics().then((nics) => {
|
||||
nics.forEach((nic) => {
|
||||
let found = false;
|
||||
Object.keys(ifaces).forEach((key) => {
|
||||
@ -1114,7 +1114,7 @@ function networkInterfaces(callback, rescan, defaultString) {
|
||||
|
||||
if ({}.hasOwnProperty.call(ifaces, dev)) {
|
||||
let ifaceName = dev;
|
||||
ifaces[dev].forEach(function (details) {
|
||||
ifaces[dev].forEach((details) => {
|
||||
if (details.family === 'IPv4' || details.family === 4) {
|
||||
ip4 = details.address;
|
||||
ip4subnet = details.netmask;
|
||||
@ -1219,7 +1219,7 @@ exports.networkInterfaces = networkInterfaces;
|
||||
// NET - Speed
|
||||
|
||||
function calcNetworkSpeed(iface, rx_bytes, tx_bytes, operstate, rx_dropped, rx_errors, tx_dropped, tx_errors) {
|
||||
let result = {
|
||||
const result = {
|
||||
iface,
|
||||
operstate,
|
||||
rx_bytes,
|
||||
@ -1420,7 +1420,7 @@ function networkStatsSingle(iface) {
|
||||
'cat /sys/class/net/' +
|
||||
ifaceSanitized +
|
||||
'/statistics/tx_errors; ';
|
||||
exec(cmd, function (error, stdout) {
|
||||
exec(cmd, (error, stdout) => {
|
||||
if (!error) {
|
||||
lines = stdout.toString().split('\n');
|
||||
operstate = lines[0].trim();
|
||||
@ -1441,7 +1441,7 @@ function networkStatsSingle(iface) {
|
||||
}
|
||||
if (_freebsd || _openbsd || _netbsd) {
|
||||
cmd = 'netstat -ibndI ' + ifaceSanitized; // lgtm [js/shell-command-constructed-from-input]
|
||||
exec(cmd, function (error, stdout) {
|
||||
exec(cmd, (error, stdout) => {
|
||||
if (!error) {
|
||||
lines = stdout.toString().split('\n');
|
||||
for (let i = 1; i < lines.length; i++) {
|
||||
@ -1471,7 +1471,7 @@ function networkStatsSingle(iface) {
|
||||
}
|
||||
if (_darwin) {
|
||||
cmd = 'ifconfig ' + ifaceSanitized + ' | grep "status"'; // lgtm [js/shell-command-constructed-from-input]
|
||||
exec(cmd, function (error, stdout) {
|
||||
exec(cmd, (error, stdout) => {
|
||||
result.operstate = (stdout.toString().split(':')[1] || '').trim();
|
||||
result.operstate = (result.operstate || '').toLowerCase();
|
||||
result.operstate = result.operstate === 'active' ? 'up' : result.operstate === 'inactive' ? 'down' : 'unknown';
|
||||
@ -1796,11 +1796,11 @@ function networkConnections(callback) {
|
||||
if (_windows) {
|
||||
let cmd = 'netstat -nao';
|
||||
try {
|
||||
exec(cmd, util.execOptsWin, function (error, stdout) {
|
||||
exec(cmd, util.execOptsWin, (error, stdout) => {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\r\n');
|
||||
|
||||
lines.forEach(function (line) {
|
||||
lines.forEach((line) => {
|
||||
line = line.trim().replace(/ +/g, ' ').split(' ');
|
||||
if (line.length >= 4) {
|
||||
let localip = line[1];
|
||||
@ -1902,7 +1902,7 @@ function networkGatewayDefault(callback) {
|
||||
if (_linux || _freebsd || _openbsd || _netbsd) {
|
||||
let cmd = 'ip route get 1';
|
||||
try {
|
||||
exec(cmd, { maxBuffer: 1024 * 102400 }, function (error, stdout) {
|
||||
exec(cmd, { maxBuffer: 1024 * 102400 }, (error, stdout) => {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
const line = lines && lines[0] ? lines[0] : '';
|
||||
@ -1932,7 +1932,7 @@ function networkGatewayDefault(callback) {
|
||||
if (_darwin) {
|
||||
let cmd = 'route -n get default';
|
||||
try {
|
||||
exec(cmd, { maxBuffer: 1024 * 102400 }, function (error, stdout) {
|
||||
exec(cmd, { maxBuffer: 1024 * 102400 }, (error, stdout) => {
|
||||
if (!error) {
|
||||
const lines = stdout
|
||||
.toString()
|
||||
@ -1942,7 +1942,7 @@ function networkGatewayDefault(callback) {
|
||||
}
|
||||
if (!result) {
|
||||
cmd = "netstat -rn | awk '/default/ {print $2}'";
|
||||
exec(cmd, { maxBuffer: 1024 * 102400 }, function (error, stdout) {
|
||||
exec(cmd, { maxBuffer: 1024 * 102400 }, (error, stdout) => {
|
||||
const lines = stdout
|
||||
.toString()
|
||||
.split('\n')
|
||||
@ -1971,7 +1971,7 @@ function networkGatewayDefault(callback) {
|
||||
}
|
||||
if (_windows) {
|
||||
try {
|
||||
exec('netstat -r', util.execOptsWin, function (error, stdout) {
|
||||
exec('netstat -r', util.execOptsWin, (error, stdout) => {
|
||||
const lines = stdout.toString().split(os.EOL);
|
||||
lines.forEach((line) => {
|
||||
line = line.replace(/\s+/g, ' ').trim();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user