MantisBT - Doomseeker
View Issue Details
0004191Doomseeker[All Projects] Bugpublic2024-01-31 16:592024-10-09 19:47
Necrodoom 
Zalewa 
normalminoralways
needs testingopen 
MicrosoftWindowsXP/Vista/7
1.4.1 
1.5.0 
0004191: Doomseeker lists incorrect IP address when attempting to connect to a LAN server
When doomseeker detects a LAN server, it sees it correctly, but when generating the commandline for it, it appends ::ffff: to the ipaddress, causing zandronum to parse it as a localhost server. For example, a server hosted on 192.168.0.107:10666 will make doomseeker generate the address of ::ffff:192.168.0.107:10666. This prevents joining LAN servers on doomseeker without pinning the server or via direct commandline.
No tags attached.
Issue History
2024-01-31 16:59NecrodoomNew Issue
2024-07-27 15:10ZalewaAssigned To => Zalewa
2024-07-27 15:10ZalewaStatusnew => acknowledged
2024-07-27 15:10ZalewaTarget Version => 1.5.0
2024-10-07 16:05ZalewaStatusacknowledged => assigned
2024-10-07 18:00ZalewaNote Added: 0024054
2024-10-07 18:00ZalewaStatusassigned => feedback
2024-10-09 19:47ZalewaNote Added: 0024057
2024-10-09 19:47ZalewaStatusfeedback => needs testing

Notes
(0024054)
Zalewa   
2024-10-07 18:00   
OK, so this happens because we bind the UDP socket that is listening to the LAN broadcasts to an "Any" address. This "Any" is both IPv4 and IPv6. Here.

When a broadcast packet arrives, we need to know where it came from. We obtain the address of the host who sent it here.

Now, it appears that if the system Doomseeker runs in has an IPv6 address (regardless if there's actual connectivity) and the socket is bound to this encompassing "Any", Qt will map IPv4 addresses to IPv6. Converting such address to a string, for command line purposes, will produce the IPv6 address string as stated in the report.

To fix this, I can try mapping such IPv6 address back to an explicit IPv4 address.

I actually tried that, the code is rather short:

// Qt may provide us with an IPv4-mapped IPv6 address, so
// convert it to an explicit IPv4 if it's a mapped IPv4.
if (sender.protocol() == QAbstractSocket::IPv6Protocol)
{
    bool isMapped = false;
    quint32 ipv4 = sender.toIPv4Address(&isMapped);
    if (isMapped)
    {
        sender = QHostAddress(ipv4);
    }
}

If fixes the issue: you can connect to the server. The question is: will this blow anything up in an environment with real IPv6? I suspect no, because the LAN broadcasts, as Zandronum uses them, don't even function in IPv6. So, this feature is a pure IPv4 thing anyway.

Just in any case, I haven't pushed this fix yet, but it seems a valid one. I asked the tin can about it and it also says it should be ok, but the tin can can never be fully trusted.

An alternative fix would be not to bind the socket to "Any", but to "AnyIPv4". Qt should then cease to produce IPv4-mapped IPv6 addresses, but this may cause some error messages in environments where there is no IPv4 at all, and handling this properly may be more complicated than just remapping the IP.
(0024057)
Zalewa   
2024-10-09 19:47   
Fix applied, let's hope it's gonna be ok:
'https://bitbucket.org/Doomseeker/doomseeker/commits/0e8c84ab773ba175414f63b698bb865209e98702 [^]'