Files
op-packages/miniupnpd/patches/10-upnp-igdv2-compat.patch
T
github-actions[bot] 846b79eedc
Merge-upstream / merge (push) Canceled after 0s
🎄 Sync 2026-08-17 19:39:03
2026-08-17 19:39:03 +08:00

81 lines
3.6 KiB
Diff

From f94e5bf7a60a41911af8d7e23cdb4ebe166257e2 Mon Sep 17 00:00:00 2001
From: Self-Hosting-Group
<155233284+Self-Hosting-Group@users.noreply.github.com>
Date: Fri, 14 Aug 2026 00:00:00 +0000
Subject: [PATCH] miniupnpd: UPnP IGDv2 Microsoft/Apple compatibility
* Add workaround to list port maps with the Windows IGDv2-incompatible
client by returning an infinite (0) lease duration. To fix listing and
editing via GUI (Explorer/Network), if daemon was compiled with IGDv2
* Extend detection to older versions of Windows and add Xbox
* Detect Apple IGDv2-incompatible clients and apply existing workaround,
that only caused problems if PCP/NAT-PMP (prioritised) was disabled
Link: https://github.com/Self-Hosting-Group/miniupnp/tree/upnp-igdv2-compat
Link: https://github.com/Self-Hosting-Group/wiki/wiki/Port-Mapping-Protocols-Overview#compatibility-issues
---
upnphttp.c | 19 ++++++++++++++++---
upnpsoap.c | 16 ++++++++++++++++
2 files changed, 32 insertions(+), 3 deletions(-)
--- a/upnphttp.c
+++ b/upnphttp.c
@@ -307,9 +307,22 @@ ParseHttpHeaders(struct upnphttp * h)
}
else if(strncasecmp(line, "user-agent:", 11) == 0)
{
- /* - User-Agent: Microsoft-Windows/10.0 UPnP/1.0
- * - User-Agent: FDSSDP */
- if(strcasestr(line + 11, "microsoft") != NULL || strstr(line + 11, "FDSSDP") != NULL) {
+ /* Detect Microsoft UPnP IGDv2-incompatible clients that only support IGDv1 routers,
+ * and Windows requires extra UDA 1.x (Win XP 1.0), via User-Agent SOAP/HTTP header:
+ * - Microsoft-Windows/10.0 UPnP/1.0 (Win >=10)
+ * - Microsoft-Windows/6.1 UPnP/1.0 (Win 7)
+ * - FDSSDP (Win >=Vista for GET)
+ * - Mozilla/4.0 (compatible; UPnP/1.0; Windows NT/5.1) (Win XP/Vista for GET)
+ * - Mozilla/4.0 (compatible; UPnP/1.0; Windows 9x) (Win XP/Vista for POST)
+ * - Xbox/2.0.17559.0 UPnP/1.0 Xbox/2.0.17559.0
+ * Detect Apple UPnP IGDv2-incompatible clients that only support IGDv1 routers:
+ * - Mozilla/4.0 (compatible; UPnP/1.0; Windows NT/5.1) (for GET)
+ * - Mozilla/4.0 (compatible; UPnP/1.0; Windows 9x) (for POST) */
+ if (((strstr(line + 11, "Microsoft-Windows/") != NULL ||
+ strstr(line + 11, "Xbox/") != NULL) &&
+ strstr(line + 11, " UPnP/1.0") != NULL) ||
+ strstr(line + 11, "FDSSDP") != NULL ||
+ strstr(line + 11, "Mozilla/4.0 (compatible; UPnP/1.0; Windows") != NULL) {
h->respflags |= FLAG_MS_CLIENT;
}
}
--- a/upnpsoap.c
+++ b/upnpsoap.c
@@ -920,6 +920,14 @@ GetSpecificPortMappingEntry(struct upnph
#ifdef ENABLE_PCP
hide_pcp_nonce(desc);
#endif
+#ifdef IGD_V2
+ /* Workaround to list port maps with the Windows IGDv2-incompatible client
+ * by returning an infinite (0) lease duration. To fix listing and editing
+ * via GUI (Explorer/Network), if daemon was compiled with IGDv2 */
+ if (h->respflags & FLAG_MS_CLIENT) {
+ leaseduration = 0;
+ }
+#endif
bodylen = snprintf(body, sizeof(body), resp,
action, ns/*SERVICE_TYPE_WANIPC*/,
(unsigned int)iport, int_ip, desc, leaseduration,
@@ -1208,6 +1216,14 @@ GetGenericPortMappingEntry(struct upnpht
#ifdef ENABLE_PCP
hide_pcp_nonce(desc);
#endif
+#ifdef IGD_V2
+ /* Workaround to list port maps with the Windows IGDv2-incompatible client
+ * by returning an infinite (0) lease duration. To fix listing and editing
+ * via GUI (Explorer/Network), if daemon was compiled with IGDv2 */
+ if (h->respflags & FLAG_MS_CLIENT) {
+ leaseduration = 0;
+ }
+#endif
bodylen = snprintf(body, sizeof(body), resp,
action, ns, /*SERVICE_TYPE_WANIPC,*/ rhost,
(unsigned int)eport, protocol, (unsigned int)iport, iaddr, desc,