Merge pull request #9709 from AdmiralCurtiss/upnp-error-log

UPnP: Improve error messages on initialization failure.
This commit is contained in:
Léo Lam 2021-07-06 15:36:38 +02:00 committed by GitHub
commit 954f27c5d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,6 +15,7 @@
#include <string>
#include <thread>
#include <upnpcommands.h>
#include <upnperrors.h>
#include <vector>
static UPNPUrls s_urls;
@ -51,7 +52,15 @@ static bool InitUPnP()
#endif
if (!devlist)
{
WARN_LOG_FMT(NETPLAY, "An error occurred trying to discover UPnP devices.");
if (upnperror == UPNPDISCOVER_SUCCESS)
{
WARN_LOG_FMT(NETPLAY, "No UPnP devices could be found.");
}
else
{
WARN_LOG_FMT(NETPLAY, "An error occurred trying to discover UPnP devices: {}",
strupnperror(upnperror));
}
s_error = true;
@ -59,6 +68,7 @@ static bool InitUPnP()
}
// Look for the IGD
bool found_valid_igd = false;
for (UPNPDev* dev = devlist.get(); dev; dev = dev->pNext)
{
if (!std::strstr(dev->st, "InternetGatewayDevice"))
@ -80,6 +90,7 @@ static bool InitUPnP()
parserootdesc(desc_xml.get(), desc_xml_size, &s_data);
GetUPNPUrls(&s_urls, &s_data, dev->descURL, 0);
found_valid_igd = true;
NOTICE_LOG_FMT(NETPLAY, "Got info from IGD at {}.", dev->descURL);
break;
}
@ -89,6 +100,9 @@ static bool InitUPnP()
}
}
if (!found_valid_igd)
WARN_LOG_FMT(NETPLAY, "Could not find a valid IGD in the discovered UPnP devices.");
s_inited = true;
return true;