mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-08-02 23:49:34 +08:00
76 lines
3.4 KiB
Diff
76 lines
3.4 KiB
Diff
From a5fa10bbe0dbb69bbfc47f5865238f352fa71675 Mon Sep 17 00:00:00 2001
|
|
From: Self-Hosting-Group
|
|
<155233284+Self-Hosting-Group@users.noreply.github.com>
|
|
Date: Thu, 27 Nov 2025 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
|
|
|
|
--- a/upnphttp.c
|
|
+++ b/upnphttp.c
|
|
@@ -303,9 +303,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
|
|
@@ -854,6 +854,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,
|
|
@@ -1124,6 +1132,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,
|