From c7b6e56337cbb03d9ed3aa601cb6e79e7858249a Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Sun, 16 Jun 2024 21:22:08 +0100 Subject: [PATCH] Support miniupnpc API version 18 (release 2.2.8) and adjust status check getValidIGD was treating non-zero return codes as successful, but only 1 should really be considered successful in this context. This maintains compatibility with earlier versions. --- libs/network/src/UPnP_Other.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/external/libutil/libs/network/src/UPnP_Other.cpp b/libs/network/src/UPnP_Other.cpp index d684b9c..8fc9418 100644 --- a/external/libutil/libs/network/src/UPnP_Other.cpp +++ b/external/libutil/libs/network/src/UPnP_Other.cpp @@ -91,7 +91,11 @@ inline DeviceList discover(int delay, const char* multicastIf = nullptr, const c inline bool getValidIGD(const DeviceList& deviceList, Urls& urls, IGDdatas& data, std::string& lanAddr) { lanAddr.resize(15); // Format: aaa.bbb.ccc.ddd - return UPNP_GetValidIGD(deviceList, &urls, &data, &lanAddr[0], lanAddr.size()) != 0; +#if (MINIUPNPC_API_VERSION >= 18) + return UPNP_GetValidIGD(deviceList, &urls, &data, &lanAddr[0], lanAddr.size(), NULL, 0) == 1; +#else + return UPNP_GetValidIGD(deviceList, &urls, &data, &lanAddr[0], lanAddr.size()) == 1; +#endif } inline void addPortMapping(const char* controlURL, const char* servicetype, const std::string& extPort, -- 2.45.1