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

use IPv6 scopeid if it's available #8

Merged
merged 3 commits into from
Jan 26, 2022
Merged

use IPv6 scopeid if it's available #8

merged 3 commits into from
Jan 26, 2022

Conversation

staltz
Copy link
Member

@staltz staltz commented Jan 26, 2022

Context

IPv6 addresses can have a scope % suffix for example fe80::6d6:aaff:fe87:179c%wlan0 but there are two ways to use that: (1) with the interface name e.g. %wlan0 or (2) a number ID given by the operating system e.g. %4.

The second method is sometimes given by the interface details object, like:

{
  address: 'fe80::f927:7648:edf4:bc96',
  netmask: 'ffff:ffff:ffff:ffff::',
  family: 'IPv6',
  mac: '68:ec:c5:08:d2:ac',
  internal: false,
  cidr: 'fe80::f927:7648:edf4:bc96/64',
  scopeid: 4  // <----------------------------------
}

Problem

The implementation was always adding the scope as the interface name. This could be problematic on Windows where the interface name is something like Local Area Connection so the scope %Local Area Connection wouldn't work.

Solution

Prioritize using details.scopeid if it exists, otherwise fall back to interface name.

Also updates test toolkit and enables tests in CI.

@staltz staltz requested a review from arj03 January 26, 2022 09:30
Copy link
Member

@arj03 arj03 left a comment

Choose a reason for hiding this comment

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

Looks simple enough

@staltz
Copy link
Member Author

staltz commented Jan 26, 2022

Thanks, I also added a test just now.

@staltz staltz merged commit 818d5e4 into master Jan 26, 2022
@staltz staltz deleted the scopeid branch January 26, 2022 09:34
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.

None yet

2 participants