miniupnpd: Option to disable IPv6 at runtime : -4 / ipv6_disable=yes

This commit is contained in:
Thomas Bernard 2020-04-09 20:41:14 +02:00
parent f34241339e
commit a774830fe0
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
5 changed files with 32 additions and 12 deletions

View File

@ -1,4 +1,7 @@
$Id: Changelog.txt,v 1.458 2020/03/29 09:07:37 nanard Exp $ $Id: Changelog.txt,v 1.459 2020/04/09 18:06:17 nanard Exp $
2020/04/09:
Option to disable IPv6 at runtime : -4 / ipv6_disable=yes
2020/03/29: 2020/03/29:
Fix FreeBSD build Fix FreeBSD build

View File

@ -1,8 +1,8 @@
/* $Id: miniupnpd.c,v 1.239 2019/10/05 20:21:47 nanard Exp $ */ /* $Id: miniupnpd.c,v 1.242 2020/04/09 18:38:14 nanard Exp $ */
/* 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-2019 Thomas Bernard * (c) 2006-2020 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 */
@ -1225,6 +1225,10 @@ init(int argc, char * * argv, struct runtime_vars * v)
fprintf(stderr, "can't parse \"%s\" as valid IPv6 listening address", ary_options[i].value); fprintf(stderr, "can't parse \"%s\" as valid IPv6 listening address", ary_options[i].value);
} }
break; break;
case UPNPIPV6_DISABLE:
if(strcmp(ary_options[i].value, "yes") == 0)
SETFLAG(IPV6DISABLEDMASK);
break;
#endif /* ENABLE_IPV6 */ #endif /* ENABLE_IPV6 */
case UPNPPORT: case UPNPPORT:
v->port = atoi(ary_options[i].value); v->port = atoi(ary_options[i].value);
@ -1423,6 +1427,11 @@ init(int argc, char * * argv, struct runtime_vars * v)
} }
else switch(argv[i][1]) else switch(argv[i][1])
{ {
#ifdef ENABLE_IPV6
case '4':
SETFLAG(IPV6DISABLEDMASK);
break;
#endif
#ifdef IGD_V2 #ifdef IGD_V2
case '1': case '1':
SETFLAG(FORCEIGDDESCV1MASK); SETFLAG(FORCEIGDDESCV1MASK);
@ -1861,7 +1870,7 @@ print_usage:
#endif #endif
"[-i ext_ifname] " "[-i ext_ifname] "
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
"[-I ext_ifname6] " "[-I ext_ifname6] [-4] "
#endif #endif
"[-o ext_ip]\n" "[-o ext_ip]\n"
#ifndef MULTIPLE_EXTERNAL_IP #ifndef MULTIPLE_EXTERNAL_IP
@ -1905,6 +1914,9 @@ print_usage:
"\tDefault config file is '%s'.\n" "\tDefault config file is '%s'.\n"
"\tWith -d miniupnpd will run as a standard program.\n" "\tWith -d miniupnpd will run as a standard program.\n"
"\t-o argument is either an IPv4 address or \"STUN:host[:port]\".\n" "\t-o argument is either an IPv4 address or \"STUN:host[:port]\".\n"
#ifdef ENABLE_IPV6
"\t-4 disable IPv6\n"
#endif
#if defined(USE_PF) || defined(USE_IPF) #if defined(USE_PF) || defined(USE_IPF)
"\t-L sets packet log in pf and ipf on.\n" "\t-L sets packet log in pf and ipf on.\n"
#endif #endif
@ -2113,7 +2125,7 @@ main(int argc, char * * argv)
listen_port = (v.port > 0) ? v.port : 0; listen_port = (v.port > 0) ? v.port : 0;
/* open socket for HTTP connections. Listen on the 1st LAN address */ /* open socket for HTTP connections. Listen on the 1st LAN address */
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
shttpl = OpenAndConfHTTPSocket(&listen_port, 1); shttpl = OpenAndConfHTTPSocket(&listen_port, !GETFLAG(IPV6DISABLEDMASK));
#else /* ENABLE_IPV6 */ #else /* ENABLE_IPV6 */
shttpl = OpenAndConfHTTPSocket(&listen_port); shttpl = OpenAndConfHTTPSocket(&listen_port);
#endif /* ENABLE_IPV6 */ #endif /* ENABLE_IPV6 */
@ -2139,7 +2151,7 @@ main(int argc, char * * argv)
/* https */ /* https */
listen_port = (v.https_port > 0) ? v.https_port : 0; listen_port = (v.https_port > 0) ? v.https_port : 0;
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
shttpsl = OpenAndConfHTTPSocket(&listen_port, 1); shttpsl = OpenAndConfHTTPSocket(&listen_port, !GETFLAG(IPV6DISABLEDMASK));
#else /* ENABLE_IPV6 */ #else /* ENABLE_IPV6 */
shttpsl = OpenAndConfHTTPSocket(&listen_port); shttpsl = OpenAndConfHTTPSocket(&listen_port);
#endif /* ENABLE_IPV6 */ #endif /* ENABLE_IPV6 */

View File

@ -53,6 +53,9 @@
# default is /var/run/minissdpd.sock # default is /var/run/minissdpd.sock
#minissdpdsocket=/var/run/minissdpd.sock #minissdpdsocket=/var/run/minissdpd.sock
# Disable IPv6 (default is no : IPv6 enabled if enabled at build time)
#ipv6_disable=yes
# Enable NAT-PMP support (default is no) # Enable NAT-PMP support (default is no)
#enable_natpmp=yes #enable_natpmp=yes

View File

@ -1,9 +1,9 @@
/* $Id: options.c,v 1.37 2019/05/21 08:39:44 nanard Exp $ */ /* $Id: options.c,v 1.39 2020/04/09 18:40:42 nanard Exp $ */
/* 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 https://miniupnp.tuxfamily.org/
* author: Ryan Wagoner * author: Ryan Wagoner
* (c) 2006-2019 Thomas Bernard * (c) 2006-2020 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 */
@ -40,6 +40,7 @@ static const struct {
{ UPNPLISTENING_IP, "listening_ip" }, { UPNPLISTENING_IP, "listening_ip" },
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
{ UPNPIPV6_LISTENING_IP, "ipv6_listening_ip" }, { UPNPIPV6_LISTENING_IP, "ipv6_listening_ip" },
{ UPNPIPV6_DISABLE, "ipv6_disable" },
#endif /* ENABLE_IPV6 */ #endif /* ENABLE_IPV6 */
{ UPNPPORT, "port" }, { UPNPPORT, "port" },
{ UPNPPORT, "http_port" }, /* "port" and "http_port" are synonims */ { UPNPPORT, "http_port" }, /* "port" and "http_port" are synonims */

View File

@ -1,9 +1,9 @@
/* $Id: options.h,v 1.30 2019/05/21 08:39:44 nanard Exp $ */ /* $Id: options.h,v 1.32 2020/04/09 18:40:42 nanard Exp $ */
/* 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 https://miniupnp.tuxfamily.org/
* author: Ryan Wagoner * author: Ryan Wagoner
* (c) 2006-2019 Thomas Bernard * (c) 2006-2020 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 */
@ -27,6 +27,7 @@ enum upnpconfigoptions {
UPNPLISTENING_IP, /* listening_ip */ UPNPLISTENING_IP, /* listening_ip */
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
UPNPIPV6_LISTENING_IP, /* listening address for IPv6 */ UPNPIPV6_LISTENING_IP, /* listening address for IPv6 */
UPNPIPV6_DISABLE, /* ipv6_disable */
#endif /* ENABLE_IPV6 */ #endif /* ENABLE_IPV6 */
UPNPPORT, /* "port" / "http_port" */ UPNPPORT, /* "port" / "http_port" */
#ifdef ENABLE_HTTPS #ifdef ENABLE_HTTPS