(Netplay) LAN addresses only for UPnP (#13461)

Some router devices might accept non-LAN addresses without raising an error.
This commit is contained in:
Cthulhu-throwaway 2022-01-08 06:45:41 -03:00 committed by GitHub
parent 87c5720988
commit c2df109874
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -101,17 +101,24 @@ static void task_netplay_nat_traversal_handler(retro_task_t *task)
}
/* Grab a suitable interface. */
hints.ai_family = AF_INET;
for (i = data->iface; i < natt_st->interfaces.size; i++)
{
struct net_ifinfo_entry *tmp_entry =
&natt_st->interfaces.entries[i];
/* Ignore localhost */
if (string_is_equal(tmp_entry->host, "127.0.0.1"))
if (getaddrinfo_retro(tmp_entry->host, NULL, &hints, &addr) ||
!addr)
continue;
/* Ignore IPv6 */
if (strchr(tmp_entry->host, ':'))
/* Ignore non-LAN interfaces */
if (!netplay_is_lan_address(
(struct sockaddr_in *) addr->ai_addr))
{
freeaddrinfo_retro(addr);
addr = NULL;
continue;
}
entry = tmp_entry;
data->iface = i;
@ -125,16 +132,6 @@ static void task_netplay_nat_traversal_handler(retro_task_t *task)
break;
}
if (getaddrinfo_retro(entry->host, NULL, &hints, &addr) ||
!addr)
{
if (++data->iface < natt_st->interfaces.size)
data->forward_type = NATT_FORWARD_TYPE_ANY;
else
data->status = NAT_TRAVERSAL_STATUS_SELECT_DEVICE;
break;
}
memcpy(&data->request.addr.sin_addr,
&((struct sockaddr_in *) addr->ai_addr)->sin_addr,
sizeof(data->request.addr.sin_addr));