Skip to content

nn_ac: Add local IP getter implementation for Linux#1839

Open
ashquarky wants to merge 2 commits into
cemu-project:mainfrom
ashquarky:patch/linux-ifaddrs
Open

nn_ac: Add local IP getter implementation for Linux#1839
ashquarky wants to merge 2 commits into
cemu-project:mainfrom
ashquarky:patch/linux-ifaddrs

Conversation

@ashquarky
Copy link
Copy Markdown

Adds implementation of _GetLocalIPAndSubnetMask for Linux. This allows LAN play in NEX games to work correctly. Previously, the fallback address was always used, which caused connection instability.

@goeiecool9999
Copy link
Copy Markdown
Collaborator

This is good.
I have one note. What if there are multiple IP addresses associated with the host? For example if the user is running virtual machines with libvirt it creates a bridge interface with a valid IP address. And when a VPN is running it also creates a virtual interface with an IP address associated with it. Often these interfaces will have a RFC 1918 address so we can't filter by that either.
It's possible that these virtual interfaces will appear later in the linked list because they're usually created later than the interfaces for the physical hardware, but I don't think the API explicitly guarantees that order and if so we probably shouldn't rely on it(?)
At least virtual VPN connections can be filtered by checking if the interface has the IFF_POINTOPOINT flag set though.

POINTTOPOINT is for VPN connections, and also filter some common bridge interfaces by name.

There really isn't a good answer for doing this on Linux, short of the default route - which might just give a VPN - so do what we can.
@ashquarky
Copy link
Copy Markdown
Author

There isn't a great way to detect unusual/bridge interfaces like those made by virtual machines. One could look at the default route, but then it gets caught up by VPNs when we want specifically the outside LAN. It might be possible to eliminate bridges entirely, but some folks (including me!) deliberately have their LAN on a bridge interface so it can be easily attached to virtual things.

I've added a filter for point to point, as well as some common bridge names (br- for libvirt, docker) as a rough heuristic.

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.

2 participants