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

getLocalIp: Keep looking if we see 127.0.0.1 #19926

Merged
merged 2 commits into from
Jan 28, 2025
Merged

getLocalIp: Keep looking if we see 127.0.0.1 #19926

merged 2 commits into from
Jan 28, 2025

Conversation

hrydgard
Copy link
Owner

@hrydgard hrydgard commented Jan 28, 2025

This path is unix-only, so it accounts for the difference against Windows seen in #19919

Fixes #19919

Turns out that it seems to often just find 127.0.0.1, but if you let it keep looking it this case, it'll find the appropriate address to use, fixing the problem.

Not sure whether it's worth using this path or if we should use the next fallback instead as used by Windows, where we connect to 8.8.8.8 and check the local IP on the connection.

@hrydgard hrydgard added this to the v1.19.0 milestone Jan 28, 2025
@hrydgard hrydgard merged commit 07ed6da into master Jan 28, 2025
19 checks passed
@hrydgard hrydgard deleted the ipdetect-fix branch January 28, 2025 13:13
@anr2me
Copy link
Collaborator

anr2me commented Jan 29, 2025

As i remembered on Linux the first LAN IP found doesn't always have internet connection if you have multiple network interfaces, and can be inconsistent.

So the best approach to find the network that have internet access is by trying to send/connect to a public IP as reference (from what i found at stackoverflow we can even connect using UDP for this), which will then have a valid IP that have internet access bound on the socket, which can be retrieved using getsockname.

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

Successfully merging this pull request may close these issues.

"Builtin proAdhoc server" has started conflicting with Infrastructure play
2 participants