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

don't include link-local addresses (169.254) in public_ips #1040

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

minrk
Copy link
Member

@minrk minrk commented Sep 21, 2024

public_ips() is meant to return addresses which might be connectable from other machines, which link-local are not.

closes #1039

public_ips is meant to return addresses that might be connectable, which link-local are not
Copy link
Member

@ivanov ivanov left a comment

Choose a reason for hiding this comment

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

Thanks, Min!

not to code-golf things, too much, but any reason not to add

or  addr.startswith("169.254.")

to the lines that already have addr.startswith("127.") logic (possibly with an appropriate group, where line 89 would become

if not (ip.startswith("127.") or ip.startswith("169.254.")):`

@minrk
Copy link
Member Author

minrk commented Sep 22, 2024

No worries! I added the conditions to avoid link-local addresses being assigned to LOCALHOST. So I could add the or, but then I'd have to move the LOCALHOST to its own condition with the same match minus 169.

There is a lot of duplication here, so maybe I'll try to consolidate the whole thing.

where dict is like `{"en0": ["1.2.3.4"]}`
@minrk
Copy link
Member Author

minrk commented Sep 22, 2024

consolidated to _populate_from_dict since netifaces and psutil were essentially the same.

@minrk minrk changed the title don't include link-local addresses in public_ips don't include link-local addresses (169.254) in public_ips Sep 22, 2024
@ivanov
Copy link
Member

ivanov commented Sep 26, 2024

thanks, Min, for the patch, the explanation, and the additional cleanup 🎉

@ivanov ivanov merged commit 8b80757 into jupyter:main Sep 26, 2024
35 checks passed
@minrk minrk deleted the link-local-not-public branch September 28, 2024 14:23
@minrk
Copy link
Member Author

minrk commented Sep 28, 2024

Thanks for the review and merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Psutil changes in public_ips() causes breaking changes
2 participants