Use UDP address from puncher to derive TCP address

This is necessary for dual stack connections where the masterserver will
only an IPv6 address and the netpuncher will only return a UDP address/port.
ipv6
Lukas Werling 2017-01-09 19:26:50 +01:00
parent 33a32cb6bd
commit 16b511b75d
1 changed files with 9 additions and 0 deletions

View File

@ -1298,8 +1298,17 @@ void C4Network2IO::OnPuncherConnect(C4NetIO::addr_t addr)
// Add for local client
C4Network2Client *pLocal = ::Network.Clients.GetLocal();
if (pLocal)
{
pLocal->AddAddr(C4Network2Address(maybe_v4, P_UDP), true);
// If the outside port matches the inside port, there is no port translation and the
// TCP address will probably work as well.
if (addr.GetPort() == Config.Network.PortUDP && Config.Network.PortTCP > 0)
{
maybe_v4.SetPort(Config.Network.PortTCP);
pLocal->AddAddr(C4Network2Address(maybe_v4, P_TCP), true);
}
// Do not ::Network.InvalidateReference(); yet, we're expecting an ID from the netpuncher
}
}
// *** C4Network2IOConnection