Skip to content

Commit 7fd3e4c

Browse files
fix time(), networkConnections() fixed wrond PID parsing (macOS)
1 parent edba2b3 commit 7fd3e4c

File tree

5 files changed

+34
-20
lines changed

5 files changed

+34
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
9090

9191
| Version | Date | Comment |
9292
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
93+
| 5.23.11 | 2024-12-13 | `networkConnections()` fixed wrond PID parsing (macOS) |
9394
| 5.23.10 | 2024-12-12 | `time()` changed retrieval of timezones (linux, macOS) |
9495
| 5.23.9 | 2024-12-11 | `typings` added definitions with overload |
9596
| 5.23.8 | 2024-12-10 | `system()` added Raspberry 500 detection |

docs/history.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ <h3>Full version history</h3>
5757
</tr>
5858
</thead>
5959
<tbody>
60+
<tr>
61+
<th scope="row">5.23.11</th>
62+
<td>2024-12-13</td>
63+
<td><span class="code">networkConnections()</span> fixed wrong PID parsing (macOS)</td>
64+
</tr>
6065
<tr>
6166
<th scope="row">5.23.10</th>
6267
<td>2024-12-12</td>

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
<img class="logo" src="assets/logo.png" alt="logo">
171171
<div class="title">systeminformation</div>
172172
<div class="subtitle"><span id="typed"></span>&nbsp;</div>
173-
<div class="version">New Version: <span id="version">5.23.10</span></div>
173+
<div class="version">New Version: <span id="version">5.23.11</span></div>
174174
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
175175
</div>
176176
<div class="down">

lib/network.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,7 @@ function networkConnections(callback) {
15361536
if (_darwin) {
15371537
// let cmd = 'netstat -natv | grep "ESTABLISHED\\|SYN_SENT\\|SYN_RECV\\|FIN_WAIT1\\|FIN_WAIT2\\|TIME_WAIT\\|CLOSE\\|CLOSE_WAIT\\|LAST_ACK\\|LISTEN\\|CLOSING\\|UNKNOWN"';
15381538
let cmd = 'netstat -natvln | grep "tcp4\\|tcp6\\|udp4\\|udp6"';
1539-
const states = 'ESTABLISHED|SYN_SENT|SYN_RECV|FIN_WAIT1|FIN_WAIT2|TIME_WAIT|CLOSE|CLOSE_WAIT|LAST_ACK|LISTEN|CLOSING|UNKNOWN';
1539+
const states = 'ESTABLISHED|SYN_SENT|SYN_RECV|FIN_WAIT1|FIN_WAIT_1|FIN_WAIT2|FIN_WAIT_2|TIME_WAIT|CLOSE|CLOSE_WAIT|LAST_ACK|LISTEN|CLOSING|UNKNOWN';
15401540
exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
15411541
if (!error) {
15421542
exec('ps -axo pid,command', { maxBuffer: 1024 * 20000 }, function (err2, stdout2) {

lib/osinfo.js

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,34 @@ const _sunos = (_platform === 'sunos');
3434

3535
function time() {
3636
let t = new Date().toString().split(' ');
37+
const result = {
38+
current: Date.now(),
39+
uptime: os.uptime(),
40+
timezone: (t.length >= 7) ? t[5] : '',
41+
timezoneName: Intl ? Intl.DateTimeFormat().resolvedOptions().timeZone : (t.length >= 7) ? t.slice(6).join(' ').replace(/\(/g, '').replace(/\)/g, '') : ''
42+
};
3743
if (_darwin || _linux) {
38-
const stdout = execSync('date +%Z && date +%z && ls -l /etc/localtime 2>/dev/null', util.execOptsLinux);
39-
const lines = stdout.toString().split(os.EOL);
40-
if (lines.length > 3 && !lines[0]) {
41-
lines.shift();
44+
try {
45+
const stdout = execSync('date +%Z && date +%z && ls -l /etc/localtime 2>/dev/null', util.execOptsLinux);
46+
const lines = stdout.toString().split(os.EOL);
47+
if (lines.length > 3 && !lines[0]) {
48+
lines.shift();
49+
}
50+
let timezone = lines[0] || '';
51+
if (timezone.startsWith('+') || timezone.startsWith('-')) {
52+
timezone = 'GMT';
53+
}
54+
return {
55+
current: Date.now(),
56+
uptime: os.uptime(),
57+
timezone: lines[1] ? timezone + lines[1] : timezone,
58+
timezoneName: lines[2] && lines[2].indexOf('/zoneinfo/') > 0 ? (lines[2].split('/zoneinfo/')[1] || '') : ''
59+
};
60+
} catch (e) {
61+
util.noop();
4262
}
43-
return {
44-
current: Date.now(),
45-
uptime: os.uptime(),
46-
timezone: lines[0] && lines[1] ? lines[0] + lines[1] : '',
47-
timezoneName: lines[2] && lines[2].indexOf('/zoneinfo/') > 0 ? (lines[2].split('/zoneinfo/')[1] || '') : ''
48-
};
49-
} else {
50-
return {
51-
current: Date.now(),
52-
uptime: os.uptime(),
53-
timezone: (t.length >= 7) ? t[5] : '',
54-
timezoneName: Intl ? Intl.DateTimeFormat().resolvedOptions().timeZone : (t.length >= 7) ? t.slice(6).join(' ').replace(/\(/g, '').replace(/\)/g, '') : ''
55-
};
56-
};
63+
}
64+
return result;
5765
}
5866

5967
exports.time = time;

0 commit comments

Comments
 (0)