Opened 20 months ago

Last modified 6 days ago

#14371 new defect

CLOUD: Server's IP interface is sometimes from a virtual adapter

Reported by: antoniou79 Owned by:
Priority: normal Component: --Other--
Version: Keywords: LAN, IP interface
Cc: Game:

Description

This is was noted on ScummVM 2.8git compiled from master HEAD) on Windows 10 x64.

When activating the LAN feature from Global Options...-> LAN -> Run server, ScummVM would choose an IP interface which corresponds to a virtual ethernet adapter named vEthernet (WSL) Hyper-V Virtual Ethernet Adapter. The resulting url for the server was: http://172.20.224.1:12345/
As far as I can tell this is something set up by WSL2 (Windows Subsystem for Linux).

The preferrable IP interface in my case would be the one of my home LAN using the IP range: 192.168.1.0/24, which is also the main network that the OS is using (to access the router/Internet and other devices in the LAN).

Yet, there is no way to customise this. Ideally, ScummVM would be able to autodetect the preferrable LAN interface.

From a short discussion on Discord, similar issue can happen on Linux and iOS.

A relevant excerpt from the discussion that might be helpful in the resolution of the issue:

(criezy) The IP comes from SDL_Net (look for SDLNet_ResolveHost in backends/networking/. Hopefully the code could be improved for all platforms there, without requiring platform-specific code to get a usable IP.
(rootfather) Looks like SDLnet simply picks the first IP configured on the system, regardless of the interfaces

Change History (3)

comment:1 by sev-, 20 months ago

I did a small investigation.

We are using SDLNet_ResolveHost() to get the IP address. The implementation in SDL_net (https://github.com/libsdl-org/SDL_net/blob/main/SDLnet.c#L186) returns this:

  SDL_memcpy(&address->host,hp->h_addr,hp->h_length);

And there is this define:

#define h_addr  h_addr_list[0]  /* address, for backward compatibility */

E.g. we return only the first address which could be incorrect in case there are several interfaces.

Instead, we would need to iterate over the returned addresses like this:

    for (int i = 0; hp->h_addr_list[i] != 0; ++i) {
        struct in_addr addr;
        memcpy(&addr, hp->h_addr_list[i], sizeof(struct in_addr));
        ...

And then return the list of addresses. The complication is that our current code keeps not the IP address but generates a URL with port and protocol: https://github.com/scummvm/scummvm/blob/master/backends/networking/sdl_net/localwebserver.cpp#L288

So, that part has to be refactored.

My idea is that we show all of these addresses in GUI when we launch the local server.

comment:2 by sev-, 10 months ago

SDL_Net 2.0 implements SDLNet_GetLocalAddresses() method

comment:3 by sev-, 6 days ago

Summary: LAN: Server's IP interface is sometimes from a virtual adapterCLOUD: Server's IP interface is sometimes from a virtual adapter
Note: See TracTickets for help on using tickets.