networkInterfaces() sanitizing device names
This commit is contained in:
parent
b9abbbdb15
commit
f997fb2d6f
@ -82,7 +82,8 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
|
|||||||
|
|
||||||
| Version | Date | Comment |
|
| Version | Date | Comment |
|
||||||
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
|
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
|
||||||
| 5.17.3 | 2023-01-10 | `processes` fix elapsed time parsing (linux) |
|
| 5.17.4 | 2023-01-24 | `networkInterfaces()` sanitizing networkInterfaces device names |
|
||||||
|
| 5.17.3 | 2023-01-10 | `processes()` fix elapsed time parsing (linux) |
|
||||||
| 5.17.2 | 2023-01-10 | `utils` fix killing powershell (windows) |
|
| 5.17.2 | 2023-01-10 | `utils` fix killing powershell (windows) |
|
||||||
| 5.17.1 | 2023-01-06 | `graphics()` positionX, positionY Ventura fix (max OS) |
|
| 5.17.1 | 2023-01-06 | `graphics()` positionX, positionY Ventura fix (max OS) |
|
||||||
| 5.17.0 | 2023-01-06 | `graphics()` added positionX, positionY (max OS) |
|
| 5.17.0 | 2023-01-06 | `graphics()` added positionX, positionY (max OS) |
|
||||||
|
|||||||
@ -57,6 +57,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">5.17.4</th>
|
||||||
|
<td>2023-01-24</td>
|
||||||
|
<td><span class="code">networkInterfaces()</span> sanitizing interface names</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">5.17.3</th>
|
<th scope="row">5.17.3</th>
|
||||||
<td>2023-01-10</td>
|
<td>2023-01-10</td>
|
||||||
|
|||||||
@ -170,7 +170,7 @@
|
|||||||
<img class="logo" src="assets/logo.png" alt="logo">
|
<img class="logo" src="assets/logo.png" alt="logo">
|
||||||
<div class="title">systeminformation</div>
|
<div class="title">systeminformation</div>
|
||||||
<div class="subtitle"><span id="typed"></span> </div>
|
<div class="subtitle"><span id="typed"></span> </div>
|
||||||
<div class="version">New Version: <span id="version">5.17.3</span></div>
|
<div class="version">New Version: <span id="version">5.17.4</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>
|
<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>
|
||||||
<div class="down">
|
<div class="down">
|
||||||
|
|||||||
@ -743,6 +743,14 @@ function networkInterfaces(callback, rescan, defaultString) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let ifaceSanitized = '';
|
||||||
|
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(nic.iface);
|
||||||
|
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
|
||||||
|
if (s[i] !== undefined) {
|
||||||
|
ifaceSanitized = ifaceSanitized + s[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
result.push({
|
result.push({
|
||||||
iface: nic.iface,
|
iface: nic.iface,
|
||||||
ifaceName: nic.iface,
|
ifaceName: nic.iface,
|
||||||
@ -759,7 +767,7 @@ function networkInterfaces(callback, rescan, defaultString) {
|
|||||||
duplex: nic.duplex,
|
duplex: nic.duplex,
|
||||||
mtu: nic.mtu,
|
mtu: nic.mtu,
|
||||||
speed: nic.speed,
|
speed: nic.speed,
|
||||||
dhcp: getDarwinIfaceDHCPstatus(nic.iface),
|
dhcp: getDarwinIfaceDHCPstatus(ifaceSanitized),
|
||||||
dnsSuffix: '',
|
dnsSuffix: '',
|
||||||
ieee8021xAuth: '',
|
ieee8021xAuth: '',
|
||||||
ieee8021xState: '',
|
ieee8021xState: '',
|
||||||
@ -830,37 +838,44 @@ function networkInterfaces(callback, rescan, defaultString) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
let iface = dev.split(':')[0].trim().toLowerCase();
|
let iface = dev.split(':')[0].trim().toLowerCase();
|
||||||
const cmd = `echo -n "addr_assign_type: "; cat /sys/class/net/${iface}/addr_assign_type 2>/dev/null; echo;
|
let ifaceSanitized = '';
|
||||||
echo -n "address: "; cat /sys/class/net/${iface}/address 2>/dev/null; echo;
|
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(iface);
|
||||||
echo -n "addr_len: "; cat /sys/class/net/${iface}/addr_len 2>/dev/null; echo;
|
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
|
||||||
echo -n "broadcast: "; cat /sys/class/net/${iface}/broadcast 2>/dev/null; echo;
|
if (s[i] !== undefined) {
|
||||||
echo -n "carrier: "; cat /sys/class/net/${iface}/carrier 2>/dev/null; echo;
|
ifaceSanitized = ifaceSanitized + s[i];
|
||||||
echo -n "carrier_changes: "; cat /sys/class/net/${iface}/carrier_changes 2>/dev/null; echo;
|
}
|
||||||
echo -n "dev_id: "; cat /sys/class/net/${iface}/dev_id 2>/dev/null; echo;
|
}
|
||||||
echo -n "dev_port: "; cat /sys/class/net/${iface}/dev_port 2>/dev/null; echo;
|
const cmd = `echo -n "addr_assign_type: "; cat /sys/class/net/${ifaceSanitized}/addr_assign_type 2>/dev/null; echo;
|
||||||
echo -n "dormant: "; cat /sys/class/net/${iface}/dormant 2>/dev/null; echo;
|
echo -n "address: "; cat /sys/class/net/${ifaceSanitized}/address 2>/dev/null; echo;
|
||||||
echo -n "duplex: "; cat /sys/class/net/${iface}/duplex 2>/dev/null; echo;
|
echo -n "addr_len: "; cat /sys/class/net/${ifaceSanitized}/addr_len 2>/dev/null; echo;
|
||||||
echo -n "flags: "; cat /sys/class/net/${iface}/flags 2>/dev/null; echo;
|
echo -n "broadcast: "; cat /sys/class/net/${ifaceSanitized}/broadcast 2>/dev/null; echo;
|
||||||
echo -n "gro_flush_timeout: "; cat /sys/class/net/${iface}/gro_flush_timeout 2>/dev/null; echo;
|
echo -n "carrier: "; cat /sys/class/net/${ifaceSanitized}/carrier 2>/dev/null; echo;
|
||||||
echo -n "ifalias: "; cat /sys/class/net/${iface}/ifalias 2>/dev/null; echo;
|
echo -n "carrier_changes: "; cat /sys/class/net/${ifaceSanitized}/carrier_changes 2>/dev/null; echo;
|
||||||
echo -n "ifindex: "; cat /sys/class/net/${iface}/ifindex 2>/dev/null; echo;
|
echo -n "dev_id: "; cat /sys/class/net/${ifaceSanitized}/dev_id 2>/dev/null; echo;
|
||||||
echo -n "iflink: "; cat /sys/class/net/${iface}/iflink 2>/dev/null; echo;
|
echo -n "dev_port: "; cat /sys/class/net/${ifaceSanitized}/dev_port 2>/dev/null; echo;
|
||||||
echo -n "link_mode: "; cat /sys/class/net/${iface}/link_mode 2>/dev/null; echo;
|
echo -n "dormant: "; cat /sys/class/net/${ifaceSanitized}/dormant 2>/dev/null; echo;
|
||||||
echo -n "mtu: "; cat /sys/class/net/${iface}/mtu 2>/dev/null; echo;
|
echo -n "duplex: "; cat /sys/class/net/${ifaceSanitized}/duplex 2>/dev/null; echo;
|
||||||
echo -n "netdev_group: "; cat /sys/class/net/${iface}/netdev_group 2>/dev/null; echo;
|
echo -n "flags: "; cat /sys/class/net/${ifaceSanitized}/flags 2>/dev/null; echo;
|
||||||
echo -n "operstate: "; cat /sys/class/net/${iface}/operstate 2>/dev/null; echo;
|
echo -n "gro_flush_timeout: "; cat /sys/class/net/${ifaceSanitized}/gro_flush_timeout 2>/dev/null; echo;
|
||||||
echo -n "proto_down: "; cat /sys/class/net/${iface}/proto_down 2>/dev/null; echo;
|
echo -n "ifalias: "; cat /sys/class/net/${ifaceSanitized}/ifalias 2>/dev/null; echo;
|
||||||
echo -n "speed: "; cat /sys/class/net/${iface}/speed 2>/dev/null; echo;
|
echo -n "ifindex: "; cat /sys/class/net/${ifaceSanitized}/ifindex 2>/dev/null; echo;
|
||||||
echo -n "tx_queue_len: "; cat /sys/class/net/${iface}/tx_queue_len 2>/dev/null; echo;
|
echo -n "iflink: "; cat /sys/class/net/${ifaceSanitized}/iflink 2>/dev/null; echo;
|
||||||
echo -n "type: "; cat /sys/class/net/${iface}/type 2>/dev/null; echo;
|
echo -n "link_mode: "; cat /sys/class/net/${ifaceSanitized}/link_mode 2>/dev/null; echo;
|
||||||
echo -n "wireless: "; cat /proc/net/wireless 2>/dev/null | grep ${iface}; echo;
|
echo -n "mtu: "; cat /sys/class/net/${ifaceSanitized}/mtu 2>/dev/null; echo;
|
||||||
echo -n "wirelessspeed: "; iw dev ${iface} link 2>&1 | grep bitrate; echo;`;
|
echo -n "netdev_group: "; cat /sys/class/net/${ifaceSanitized}/netdev_group 2>/dev/null; echo;
|
||||||
|
echo -n "operstate: "; cat /sys/class/net/${ifaceSanitized}/operstate 2>/dev/null; echo;
|
||||||
|
echo -n "proto_down: "; cat /sys/class/net/${ifaceSanitized}/proto_down 2>/dev/null; echo;
|
||||||
|
echo -n "speed: "; cat /sys/class/net/${ifaceSanitized}/speed 2>/dev/null; echo;
|
||||||
|
echo -n "tx_queue_len: "; cat /sys/class/net/${ifaceSanitized}/tx_queue_len 2>/dev/null; echo;
|
||||||
|
echo -n "type: "; cat /sys/class/net/${ifaceSanitized}/type 2>/dev/null; echo;
|
||||||
|
echo -n "wireless: "; cat /proc/net/wireless 2>/dev/null | grep ${ifaceSanitized}; echo;
|
||||||
|
echo -n "wirelessspeed: "; iw dev ${ifaceSanitized} link 2>&1 | grep bitrate; echo;`;
|
||||||
|
|
||||||
let lines = [];
|
let lines = [];
|
||||||
try {
|
try {
|
||||||
lines = execSync(cmd).toString().split('\n');
|
lines = execSync(cmd).toString().split('\n');
|
||||||
const connectionName = getLinuxIfaceConnectionName(iface);
|
const connectionName = getLinuxIfaceConnectionName(ifaceSanitized);
|
||||||
dhcp = getLinuxIfaceDHCPstatus(iface, connectionName, _dhcpNics);
|
dhcp = getLinuxIfaceDHCPstatus(ifaceSanitized, connectionName, _dhcpNics);
|
||||||
dnsSuffix = getLinuxIfaceDNSsuffix(connectionName);
|
dnsSuffix = getLinuxIfaceDNSsuffix(connectionName);
|
||||||
ieee8021xAuth = getLinuxIfaceIEEE8021xAuth(connectionName);
|
ieee8021xAuth = getLinuxIfaceIEEE8021xAuth(connectionName);
|
||||||
ieee8021xState = getLinuxIfaceIEEE8021xState(ieee8021xAuth);
|
ieee8021xState = getLinuxIfaceIEEE8021xState(ieee8021xAuth);
|
||||||
@ -880,7 +895,7 @@ function networkInterfaces(callback, rescan, defaultString) {
|
|||||||
carrierChanges = parseInt(util.getValue(lines, 'carrier_changes'), 10);
|
carrierChanges = parseInt(util.getValue(lines, 'carrier_changes'), 10);
|
||||||
const operstate = util.getValue(lines, 'operstate');
|
const operstate = util.getValue(lines, 'operstate');
|
||||||
type = operstate === 'up' ? (util.getValue(lines, 'wireless').trim() ? 'wireless' : 'wired') : 'unknown';
|
type = operstate === 'up' ? (util.getValue(lines, 'wireless').trim() ? 'wireless' : 'wired') : 'unknown';
|
||||||
if (iface === 'lo' || iface.startsWith('bond')) { type = 'virtual'; }
|
if (ifaceSanitized === 'lo' || ifaceSanitized.startsWith('bond')) { type = 'virtual'; }
|
||||||
|
|
||||||
let internal = (ifaces[dev] && ifaces[dev][0]) ? ifaces[dev][0].internal : false;
|
let internal = (ifaces[dev] && ifaces[dev][0]) ? ifaces[dev][0].internal : false;
|
||||||
if (dev.toLowerCase().indexOf('loopback') > -1 || ifaceName.toLowerCase().indexOf('loopback') > -1) {
|
if (dev.toLowerCase().indexOf('loopback') > -1 || ifaceName.toLowerCase().indexOf('loopback') > -1) {
|
||||||
@ -888,7 +903,7 @@ function networkInterfaces(callback, rescan, defaultString) {
|
|||||||
}
|
}
|
||||||
const virtual = internal ? false : testVirtualNic(dev, ifaceName, mac);
|
const virtual = internal ? false : testVirtualNic(dev, ifaceName, mac);
|
||||||
result.push({
|
result.push({
|
||||||
iface,
|
iface: ifaceSanitized,
|
||||||
ifaceName,
|
ifaceName,
|
||||||
default: iface === defaultInterface,
|
default: iface === defaultInterface,
|
||||||
ip4,
|
ip4,
|
||||||
@ -955,6 +970,15 @@ function networkInterfaces(callback, rescan, defaultString) {
|
|||||||
nics8021xInfo = getWindowsWiredProfilesInformation();
|
nics8021xInfo = getWindowsWiredProfilesInformation();
|
||||||
dnsSuffixes = getWindowsDNSsuffixes();
|
dnsSuffixes = getWindowsDNSsuffixes();
|
||||||
for (let dev in ifaces) {
|
for (let dev in ifaces) {
|
||||||
|
|
||||||
|
let ifaceSanitized = '';
|
||||||
|
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(dev);
|
||||||
|
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
|
||||||
|
if (s[i] !== undefined) {
|
||||||
|
ifaceSanitized = ifaceSanitized + s[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let iface = dev;
|
let iface = dev;
|
||||||
let ip4 = '';
|
let ip4 = '';
|
||||||
let ip4subnet = '';
|
let ip4subnet = '';
|
||||||
@ -998,7 +1022,7 @@ function networkInterfaces(callback, rescan, defaultString) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.ifaces, dev);
|
dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.ifaces, ifaceSanitized);
|
||||||
let foundFirst = false;
|
let foundFirst = false;
|
||||||
nics.forEach(detail => {
|
nics.forEach(detail => {
|
||||||
if (detail.mac === mac && !foundFirst) {
|
if (detail.mac === mac && !foundFirst) {
|
||||||
@ -1016,7 +1040,7 @@ function networkInterfaces(callback, rescan, defaultString) {
|
|||||||
type = 'wireless';
|
type = 'wireless';
|
||||||
}
|
}
|
||||||
|
|
||||||
const IEEE8021x = getWindowsIEEE8021x(type, dev, nics8021xInfo);
|
const IEEE8021x = getWindowsIEEE8021x(type, ifaceSanitized, nics8021xInfo);
|
||||||
ieee8021xAuth = IEEE8021x.protocol;
|
ieee8021xAuth = IEEE8021x.protocol;
|
||||||
ieee8021xState = IEEE8021x.state;
|
ieee8021xState = IEEE8021x.state;
|
||||||
let internal = (ifaces[dev] && ifaces[dev][0]) ? ifaces[dev][0].internal : false;
|
let internal = (ifaces[dev] && ifaces[dev][0]) ? ifaces[dev][0].internal : false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user