X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fnet_setup.c;h=38fed521a64dae1ece4831c27c28285e268d17f0;hp=0033c008cbf28a25c9cb968e4ef25a4356da237a;hb=9fdf4278f8c8c1563d45205c9e9f1bc351bd814f;hpb=1140ca6d3004b228947bad8736f0b49d6b169267 diff --git a/src/net_setup.c b/src/net_setup.c index 0033c008..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; @@ -962,9 +966,8 @@ static bool setup_myself(void) { else if(!strcasecmp(type, "vde")) devops = vde_devops; #endif - } - if (type) free(type); + } get_config_bool(lookup_config(config_tree, "DeviceStandby"), &device_standby); @@ -1060,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;