upnphttp.c: detecting MS client and forcing IGD v1

should fix #539
This commit is contained in:
Thomas Bernard 2021-08-11 13:51:10 +02:00
parent d8e5659c7b
commit 2f2685af97
No known key found for this signature in database
GPG Key ID: DB511043A31ACAAF
2 changed files with 14 additions and 2 deletions

View File

@ -308,6 +308,11 @@ ParseHttpHeaders(struct upnphttp * h)
syslog(LOG_DEBUG, "\"Expect: 100-Continue\" header detected"); syslog(LOG_DEBUG, "\"Expect: 100-Continue\" header detected");
} }
} }
else if(strncasecmp(line, "user-agent:", 11) == 0)
{
if(strcasestr(line + 11, "microsoft") != NULL)
h->respflags |= FLAG_MS_CLIENT;
}
#ifdef ENABLE_EVENTS #ifdef ENABLE_EVENTS
else if(strncasecmp(line, "Callback:", 9)==0) else if(strncasecmp(line, "Callback:", 9)==0)
{ {
@ -463,7 +468,11 @@ sendXMLdesc(struct upnphttp * h, char * (f)(int *, int))
char * desc; char * desc;
int len; int len;
#ifdef IGD_V2 #ifdef IGD_V2
desc = f(&len, GETFLAG(FORCEIGDDESCV1MASK)); #ifdef DEBUG
if(h->respflags & FLAG_MS_CLIENT)
syslog(LOG_DEBUG, "MS Client, forcing IGD v1");
#endif /* DEBUG */
desc = f(&len, GETFLAG(FORCEIGDDESCV1MASK) || (h->respflags & FLAG_MS_CLIENT));
#else #else
desc = f(&len, 0); desc = f(&len, 0);
#endif #endif

View File

@ -2,7 +2,7 @@
/* vim: tabstop=4 shiftwidth=4 noexpandtab /* vim: tabstop=4 shiftwidth=4 noexpandtab
* MiniUPnP project * MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* (c) 2006-2020 Thomas Bernard * (c) 2006-2021 Thomas Bernard
* This software is subject to the conditions detailed * This software is subject to the conditions detailed
* in the LICENCE file provided within the distribution */ * in the LICENCE file provided within the distribution */
@ -106,6 +106,9 @@ struct upnphttp {
#define FLAG_ALLOW_POST 0x100 #define FLAG_ALLOW_POST 0x100
#define FLAG_ALLOW_SUB_UNSUB 0x200 #define FLAG_ALLOW_SUB_UNSUB 0x200
/* If set, the User-Agent: contains "microsoft" */
#define FLAG_MS_CLIENT 0x400
#ifdef ENABLE_HTTPS #ifdef ENABLE_HTTPS
int init_ssl(void); int init_ssl(void);
void free_ssl(void); void free_ssl(void);