X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fnet_setup.c;h=38fed521a64dae1ece4831c27c28285e268d17f0;hp=23dd2521c74b465cdc64405ea79b3f821e3040aa;hb=513bffe1fee07bcbcb50691e221874adc1507857;hpb=2bb567c6a31e333ebdd16d6d076ba9976e6ed4fb diff --git a/src/net_setup.c b/src/net_setup.c index 23dd2521..38fed521 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -43,6 +43,10 @@ #include "utils.h" #include "xalloc.h" +#ifdef HAVE_MINIUPNPC +#include "upnp.h" +#endif + char *myport; static char *myname; static io_t device_io; @@ -1059,6 +1063,25 @@ static bool setup_myself(void) { xasprintf(&myself->hostname, "MYSELF port %s", myport); myself->connection->hostname = xstrdup(myself->hostname); + char *upnp = NULL; + get_config_string(lookup_config(config_tree, "UPnP"), &upnp); + bool upnp_tcp = false; + bool upnp_udp = false; + if (upnp) { + if (!strcasecmp(upnp, "yes")) + upnp_tcp = upnp_udp = true; + else if (!strcasecmp(upnp, "udponly")) + upnp_udp = true; + free(upnp); + } + if (upnp_tcp || upnp_udp) { +#ifdef HAVE_MINIUPNPC + upnp_init(upnp_tcp, upnp_udp); +#else + logger(DEBUG_ALWAYS, LOG_WARNING, "UPnP was requested, but tinc isn't built with miniupnpc support!"); +#endif + } + /* Done. */ last_config_check = now.tv_sec;