-
Notifications
You must be signed in to change notification settings - Fork 228
Sort interfaces by priority when searching an IP address #82
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -376,7 +376,25 @@ ip.address = function(name, family) { | |
| return res[0].address; | ||
| } | ||
|
|
||
| var all = Object.keys(interfaces).map(function (nic) { | ||
| function priority (name) { | ||
| if (name.startsWith('en') || name.startsWith('eth')) { | ||
| return 0; | ||
| } | ||
| if (name.startsWith('wlan')) { | ||
| return 1; | ||
| } | ||
|
|
||
| return 2; | ||
| } | ||
|
|
||
| var sortedInterfaces = Object.keys(interfaces).sort(function(a, b) { | ||
| a = priority(a); | ||
| b = priority(b); | ||
|
|
||
| return a - b; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not just
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @brentvatne you're right :-) I did that to debug my code. |
||
| }); | ||
|
|
||
| var all = sortedInterfaces.map(function (nic) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should remove space between |
||
| // | ||
| // Note: name will only be `public` or `private` | ||
| // when this is called. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should remove space before
(namefor consistency with the rest of the codebase