Skip to content

Commit

Permalink
upnphttp.c: detecting MS client and forcing IGD v1
Browse files Browse the repository at this point in the history
should fix #539
  • Loading branch information
miniupnp committed Aug 11, 2021
1 parent 629f7be commit 61059fc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 10 additions & 1 deletion miniupnpd/upnphttp.c
Expand Up @@ -308,6 +308,11 @@ ParseHttpHeaders(struct upnphttp * h)
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
else if(strncasecmp(line, "Callback:", 9)==0)
{
Expand Down Expand Up @@ -463,7 +468,11 @@ sendXMLdesc(struct upnphttp * h, char * (f)(int *, int))
char * desc;
int len;
#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
desc = f(&len, 0);
#endif
Expand Down
5 changes: 4 additions & 1 deletion miniupnpd/upnphttp.h
Expand Up @@ -2,7 +2,7 @@
/* vim: tabstop=4 shiftwidth=4 noexpandtab
* MiniUPnP project
* 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
* in the LICENCE file provided within the distribution */

Expand Down Expand Up @@ -106,6 +106,9 @@ struct upnphttp {
#define FLAG_ALLOW_POST 0x100
#define FLAG_ALLOW_SUB_UNSUB 0x200

/* If set, the User-Agent: contains "microsoft" */
#define FLAG_MS_CLIENT 0x400

#ifdef ENABLE_HTTPS
int init_ssl(void);
void free_ssl(void);
Expand Down

0 comments on commit 61059fc

Please sign in to comment.