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

handle ipv6 addresses suffixed with scope id #52

Merged
merged 1 commit into from
Jul 21, 2019
Merged

Conversation

staltz
Copy link
Member

@staltz staltz commented Jul 11, 2019

Related to #51, I get a lot of errors that Manyverse is crashing with this:

Error: listen EINVAL fe80::c376:4a3f:a128:3466:26831
    at Server.setupListenHandle [as _listen2] (net.js:1269:19)
    at listenInCluster (net.js:1334:12)
    at doListen (net.js:1460:7)
    at process._tickCallback (internal/process/next_tick.js:63:19)

And it comes from this multiserver's net plugin. After a lot of investigation, I figured out why that IPv6 address is "invalid": all of these IPv6 addresses that I got reports from were all link-local addresses, and given multiple network interfaces on the device, the IPv6 addresses needs a suffix to disambiguate which network interface is that address related to. See IETF RFC 6874.

So to fix those kind of crashes, I just need to provide the zone id %wlan0 or %en0 (or whatever) as a suffix on the IP address, so if we call server.listen(port, host) using the host shown below, then the crash is fixed!

-host = 'fe80::c376:4a3f:a128:3466'
+host = 'fe80::c376:4a3f:a128:3466%wlan0'

Read more: https://superuser.com/questions/99746/why-is-there-a-percent-sign-in-the-ipv6-address

Given the IPv6 Link-Local addressing, where every interface has the same network (fe80::/10), there must be some way to distinguish which specific network is meant when referring to a link-local address. That is what the Scope ID, also called a Zone ID so as not to be confused with the multicast scope flags, is for.

What this PR does, however, is to hide the %wlan0 for remote peers, because the RFC says:

URIs including a ZoneID are to be interpreted only in the context of the host at which they originate, since the ZoneID is of local significance only.

That's why I added some code in stringify() to remove the zone ID before sharing it with peers.

@arj03
Copy link
Member

arj03 commented Jul 16, 2019

Looks good

@staltz staltz requested a review from christianbundy July 21, 2019 07:40
@dominictarr
Copy link
Contributor

merged into 3.4.0

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.

3 participants