Skip to content
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

fix: listening on IPv6 address not possible #5133

Merged
merged 1 commit into from
Apr 26, 2022

Conversation

awfulcooking
Copy link
Contributor

Wrap IPv6 addresses in square brackets for URL in ensureAddress.

Fixes #1582 (regression)

Thanks ;-)

@awfulcooking awfulcooking requested a review from a team April 26, 2022 18:47
Wrap IPv6 addresses in square brackets when making URL in ensureAddress,
fixing regression (coder#1582)
@jsjoeio jsjoeio added the bug Something isn't working label Apr 26, 2022
@@ -94,7 +94,8 @@ export const ensureAddress = (server: http.Server, protocol: string): URL | stri
}

if (typeof addr !== "string") {
return new URL(`${protocol}://${addr.address}:${addr.port}`)
const host = addr.family === "IPv6" ? `[${addr.address}]` : addr.address
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love how simple this is 👏🏼

Comment on lines +160 to +168
it("should construct URL with an IPv4 address", async () => {
mockServer.address = () => ({ address: "1.2.3.4", port: 5678, family: "IPv4" })
const address = ensureAddress(mockServer, "http")
expect(address.toString()).toBe(`http://1.2.3.4:5678/`)
})
it("should construct URL with an IPv6 address", async () => {
mockServer.address = () => ({ address: "a:b:c:d::1234", port: 5678, family: "IPv6" })
const address = ensureAddress(mockServer, "http")
expect(address.toString()).toBe(`http://[a:b:c:d::1234]:5678/`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appreciate you adding more tests as well 👏🏼

Copy link
Contributor

@jsjoeio jsjoeio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great to me! Thank you so much 👏🏼

I'll let @code-asher give the final ✅

@jsjoeio jsjoeio enabled auto-merge (squash) April 26, 2022 19:17
@codecov
Copy link

codecov bot commented Apr 26, 2022

Codecov Report

Merging #5133 (55bc52b) into main (683412c) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5133      +/-   ##
==========================================
+ Coverage   71.73%   71.75%   +0.01%     
==========================================
  Files          30       30              
  Lines        1684     1685       +1     
  Branches      374      375       +1     
==========================================
+ Hits         1208     1209       +1     
  Misses        407      407              
  Partials       69       69              
Impacted Files Coverage Δ
src/node/app.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 683412c...55bc52b. Read the comment docs.

@jsjoeio jsjoeio merged commit a0b3614 into coder:main Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Listening on INADDR6_ANY not possible
3 participants