-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
fix: idn ping errors #6662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
fix: idn ping errors #6662
Changes from all 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 2923f6a
Added punicode translation to pingAsync
iotux febca21
Merge branch 'louislam:master' into fix/idn-ping-errors
iotux 70400d6
Added comment to pingAsync
iotux 69b40ea
Added comment to pingAsync
iotux 0664642
Trigger re-check
iotux 69d763a
Added IDN ping test
iotux 1f9e922
test-idn-ping.js -> test/backend-test/test-util-server
iotux b2845b0
Solidified tests
iotux 76747aa
[autofix.ci] apply automated fixes
autofix-ci[bot] 9d50f3d
Merge branch 'louislam:master' into fix/idn-ping-errors
iotux d660507
Reworked tests
iotux 261d772
Changed test IPv6 address because of the test "Network is unreachable…
iotux b67f9df
[autofix.ci] apply automated fixes
autofix-ci[bot] 8b0325b
Added bracket stripping
iotux 9c4db57
Corrected test to account for "Network unreachable" message
iotux 92eb8c8
[autofix.ci] apply automated fixes
autofix-ci[bot] b2470ea
Refactor IPv6 error message assertions in tests
iotux 4b56b25
[autofix.ci] apply automated fixes
autofix-ci[bot] d561f58
Fix regex for stripping brackets from destAddr
iotux 9e66be2
Added MacOS specific workaround fur unusual error message
iotux bdfeee9
[autofix.ci] apply automated fixes
autofix-ci[bot] 746f074
Removed redundant bracket stripping from destAddr
iotux 18f57b4
Merge branch 'louislam:master' into fix/idn-ping-errors
iotux c78c492
Merge branch 'louislam:master' into fix/idn-ping-errors
iotux af19d21
Reverted defaultFriendlyName to previous behaviour
iotux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iotux marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| 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 () => { | ||
| const idnDomain = "münchen.de"; | ||
| const punycodeDomain = "xn--mnchen-3ya.de"; | ||
|
|
||
| await assert.rejects(pingAsync(idnDomain, false, 1, "", true, 56, 1, 1), (err) => { | ||
| if (err.message.includes("Parameter string not correctly encoded")) { | ||
| assert.fail("Ping failed with encoding error: IDN was not converted"); | ||
| } | ||
| assert.ok( | ||
| err.message.includes(punycodeDomain), | ||
| `Error message should contain the Punycode domain "${punycodeDomain}". Got: ${err.message}` | ||
| ); | ||
| return true; | ||
| }); | ||
| }); | ||
|
|
||
| test("should strip brackets from IPv6 addresses before pinging", async () => { | ||
| const ipv6WithBrackets = "[2606:4700:4700::1111]"; | ||
| const ipv6Raw = "2606:4700:4700::1111"; | ||
|
|
||
| await assert.rejects(pingAsync(ipv6WithBrackets, true, 1, "", true, 56, 1, 1), (err) => { | ||
| assert.strictEqual( | ||
| err.message.includes(ipv6WithBrackets), | ||
| false, | ||
| "Error message should not contain brackets" | ||
| ); | ||
| // Allow either the IP in the message (local) OR "Network is unreachable" | ||
| const containsIP = err.message.includes(ipv6Raw); | ||
| const isUnreachable = | ||
| err.message.includes("Network is unreachable") || err.message.includes("Network unreachable"); | ||
| // macOS error when IPv6 stack is missing | ||
| const isMacOSError = err.message.includes("nodename nor servname provided"); | ||
| assert.ok( | ||
| containsIP || isUnreachable || isMacOSError, | ||
| `Ping failed correctly, but error message format was unexpected.\nGot: "${err.message}"\nExpected to contain IP "${ipv6Raw}" OR be a standard network error.` | ||
| ); | ||
| return true; | ||
| }); | ||
| }); | ||
|
|
||
| test("should handle standard ASCII domains correctly", async () => { | ||
| const domain = "invalid-domain.test"; | ||
| await assert.rejects(pingAsync(domain, false, 1, "", true, 56, 1, 1), (err) => { | ||
| assert.strictEqual(err.message.includes("Parameter string not correctly encoded"), false); | ||
| assert.ok( | ||
| err.message.includes(domain), | ||
| `Error message should contain the domain "${domain}". Got: ${err.message}` | ||
| ); | ||
| return true; | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.