summarylogtreecommitdiffstats
path: root/upnp.patch
blob: 9f058c7e395a57f8a1b0883a90e41dc27ab75795 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
From 6d5c1ab995ce854b56aea87770783a680b76fe72 Mon Sep 17 00:00:00 2001
From: James Le Cuirot <chewi@gentoo.org>
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/libs/network/src/UPnP_Other.cpp b/libs/network/src/UPnP_Other.cpp
index d684b9c..8fc9418 100644
--- a/libs/network/src/UPnP_Other.cpp
+++ b/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,