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

Allow IPv6 loopback address #907

Closed
wants to merge 8 commits into from

Conversation

Timer
Copy link

@Timer Timer commented May 15, 2017

What kind of change does this PR introduce?

bugfix

Did you add or update the examples/?
N/A

Summary

localhost resolves to ::1 for IPv6, 127.0.0.1 for IPv4. We shouldn't forget about IPv6 users.

Does this PR introduce a breaking change?

No

Other information

@Timer
Copy link
Author

Timer commented May 15, 2017

Hi! I made these changes on github so I hope they work. 😅
In a nutshell, there was no support for IPv6... this remedies that!

lib/Server.js Outdated

// always allow localhost host, for convience
if(hostname === "127.0.0.1" || hostname === "localhost") return true;
if(hostname === "127.0.0.1" || hostname === "localhost" || hostname === "::1") return true;

// allow hostname of listening adress
if(hostname === this.listenHostname) return true;

// also allow public hostname if provided
if(typeof this.publicHost === "string") {
Copy link
Author

Choose a reason for hiding this comment

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

It would be great if publicHost could be an array so we could provide an IPv6 and IPv4 address.

@shellscape
Copy link
Contributor

@Timer looks like there are some issues with the tests to resolve before we can merge this. Please have a look

@Timer Timer force-pushed the patch-1 branch 2 times, most recently from e3a42e0 to f2cbd25 Compare June 16, 2017 17:43
@codecov
Copy link

codecov bot commented Jun 16, 2017

Codecov Report

Merging #907 into master will decrease coverage by 0.12%.
The diff coverage is 91.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #907      +/-   ##
==========================================
- Coverage   72.23%   72.11%   -0.13%     
==========================================
  Files           4        4              
  Lines         461      459       -2     
  Branches      138      136       -2     
==========================================
- Hits          333      331       -2     
  Misses        128      128
Impacted Files Coverage Δ
lib/Server.js 79.56% <91.66%> (-0.13%) ⬇️

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 8d5f252...3e12a11. Read the comment docs.

@@ -489,7 +485,7 @@ Server.prototype.listen = function(port, hostname) {
});
sockServer.on("connection", (conn) => {
if(!conn) return;
if(!this.checkHost(conn.headers)) {
if(!this.checkHost(conn.hostname)) {
Copy link
Author

Choose a reason for hiding this comment

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

We just have to make sure this works.

Copy link
Contributor

Choose a reason for hiding this comment

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

it looks obvious as to why this was changed to hostname but what I'm wondering is if there was reason it was using headers. I think we may need tests around this to be certain.

@shellscape
Copy link
Contributor

ping @Timer re: tests for headers/hostname change

@shellscape
Copy link
Contributor

@Timer last ping before we close this one as abandoned. please do have a look at the conflicts and adding a test around the hostname change!

@shellscape shellscape changed the base branch from master to abandoned-pull-requests August 30, 2017 01:12
@shellscape shellscape closed this Aug 30, 2017
@Timer Timer deleted the patch-1 branch January 22, 2018 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants