Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c5ba588
Added punicode translation to default.monitor.hostname
iotux Jan 9, 2026
2923f6a
Added punicode translation to pingAsync
iotux Jan 9, 2026
febca21
Merge branch 'louislam:master' into fix/idn-ping-errors
iotux Jan 9, 2026
70400d6
Added comment to pingAsync
iotux Jan 9, 2026
69b40ea
Added comment to pingAsync
iotux Jan 9, 2026
0664642
Trigger re-check
iotux Jan 9, 2026
69d763a
Added IDN ping test
iotux Jan 10, 2026
1f9e922
test-idn-ping.js -> test/backend-test/test-util-server
iotux Jan 10, 2026
b2845b0
Solidified tests
iotux Jan 10, 2026
76747aa
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 10, 2026
9d50f3d
Merge branch 'louislam:master' into fix/idn-ping-errors
iotux Jan 10, 2026
d660507
Reworked tests
iotux Jan 10, 2026
261d772
Changed test IPv6 address because of the test "Network is unreachable…
iotux Jan 10, 2026
b67f9df
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 10, 2026
8b0325b
Added bracket stripping
iotux Jan 10, 2026
9c4db57
Corrected test to account for "Network unreachable" message
iotux Jan 10, 2026
92eb8c8
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 10, 2026
b2470ea
Refactor IPv6 error message assertions in tests
iotux Jan 10, 2026
4b56b25
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 10, 2026
d561f58
Fix regex for stripping brackets from destAddr
iotux Jan 10, 2026
9e66be2
Added MacOS specific workaround fur unusual error message
iotux Jan 11, 2026
bdfeee9
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 11, 2026
746f074
Removed redundant bracket stripping from destAddr
iotux Jan 11, 2026
18f57b4
Merge branch 'louislam:master' into fix/idn-ping-errors
iotux Jan 11, 2026
c78c492
Merge branch 'louislam:master' into fix/idn-ping-errors
iotux Jan 11, 2026
af19d21
Reverted defaultFriendlyName to previous behaviour
iotux Jan 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions server/util-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ exports.pingAsync = function (
deadline = PING_GLOBAL_TIMEOUT_DEFAULT,
timeout = PING_PER_REQUEST_TIMEOUT_DEFAULT
) {
try {
// Convert IDN to punycode, then keep hostname
const url = new URL(`http://${destAddr}`);
destAddr = url.hostname;
// Enforce valid IPv6 address
if (destAddr.startsWith("[") && destAddr.endsWith("]")) {
destAddr = destAddr.slice(1, -1);
}
} catch (e) {
// ignore
}

return new Promise((resolve, reject) => {
ping.promise
.probe(destAddr, {
Expand Down
8 changes: 7 additions & 1 deletion src/pages/EditMonitor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2260,7 +2260,13 @@ export default {

defaultFriendlyName() {
if (this.monitor.hostname) {
return this.monitor.hostname;
try {
// Convert IDN to punycode
const url = new URL(`http://${this.monitor.hostname}`);
return url.hostname;
Comment thread
iotux marked this conversation as resolved.
Outdated
} catch (e) {
return this.monitor.hostname;
}
}
if (this.monitor.system_service_name) {
return this.monitor.system_service_name;
Expand Down
47 changes: 47 additions & 0 deletions test/backend-test/test-util-server.js
Comment thread
iotux marked this conversation as resolved.
Comment thread
iotux marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const { describe, test } = require("node:test");
const assert = require("node:assert");
const { pingAsync } = require("../../server/util-server");

describe("Server Utilities: pingAsync", () => {
test("should convert IDN domains to Punycode before pinging", async () => {
try {
// timeout 1s
await pingAsync("münchen.de", false, 1, "", true, 56, 1, 1);
} catch (e) {
if (e.message.includes("Parameter string not correctly encoded")) {
assert.fail("Ping failed with encoding error: IDN was not converted");
}
assert.ok(
e.message.includes("xn--mnchen-3ya.de"),
`Error message should contain "xn--mnchen-3ya.de". Got: ${e.message}`
);
}
Comment thread
iotux marked this conversation as resolved.
Outdated
});

test("should strip brackets from IPv6 addresses before pinging", async () => {
try {
// Cloudflare DNS
await pingAsync("[2606:4700:4700::1111]", true, 1, "", true, 56, 1, 1);
} catch (e) {
if (e.message.includes("[2606:4700:4700::1111]")) {
assert.fail(`Error message contained brackets, implying they were not stripped. Got: ${e.message}`);
}
// The error message should contain the raw IP without brackets
assert.ok(
e.message.includes("2606:4700:4700::1111"),
`Error message should contain the raw IP "2606:4700:4700::1111". Got: ${e.message}`
);
}
});

test("should handle standard ASCII domains correctly", async () => {
try {
await pingAsync("google.com", false, 1, "", true, 56, 1, 1);
} catch (e) {
if (e.message.includes("Parameter string not correctly encoded")) {
assert.fail("Ping failed with encoding error for ASCII domain");
}
assert.ok(e.message.includes("google.com"), `Error message should contain "google.com". Got: ${e.message}`);
Comment thread Fixed
}
});
});
Loading