X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fnet_setup.c;h=30e6f848a68c4ea4828fc02828267fade412386d;hp=bf5ba04c1e7e1005b22f48ffd164b32584a34510;hb=f934417aa658367587dadc81bd5c466baef407ef;hpb=3ccdf50beb6b2d3f2730bdc66006b43190537cde diff --git a/src/net_setup.c b/src/net_setup.c index bf5ba04c..30e6f848 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -1,7 +1,7 @@ /* net_setup.c -- Setup. Copyright (C) 1998-2005 Ivo Timmermans, - 2000-2015 Guus Sliepen + 2000-2016 Guus Sliepen 2006 Scott Lamb 2010 Brandon Black @@ -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; @@ -364,6 +368,7 @@ void load_all_subnets(void) { if((s2 = lookup_subnet(n, s))) { s2->expires = -1; + free(s); } else { subnet_add(n, s); } @@ -586,9 +591,14 @@ bool setup_myself_reloadable(void) { subnet_add(NULL, s); } -#if !defined(SOL_IP) || !defined(IP_TOS) +#if !defined(IPPROTO_IP) || !defined(IP_TOS) + if(priorityinheritance) + logger(DEBUG_ALWAYS, LOG_WARNING, "%s not supported on this platform for IPv4 connections", "PriorityInheritance"); +#endif + +#if !defined(IPPROTO_IPV6) || !defined(IPV6_TCLASS) if(priorityinheritance) - logger(DEBUG_ALWAYS, LOG_WARNING, "%s not supported on this platform", "PriorityInheritance"); + logger(DEBUG_ALWAYS, LOG_WARNING, "%s not supported on this platform for IPv6 connections", "PriorityInheritance"); #endif if(!get_config_int(lookup_config(config_tree, "MACExpire"), &macexpire)) @@ -961,6 +971,7 @@ static bool setup_myself(void) { else if(!strcasecmp(type, "vde")) devops = vde_devops; #endif + free(type); } get_config_bool(lookup_config(config_tree, "DeviceStandby"), &device_standby); @@ -1057,6 +1068,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; @@ -1124,8 +1154,7 @@ void close_network_connections(void) { if(myself && myself->connection) { subnet_update(myself, NULL, false); - terminate_connection(myself->connection, false); - free_connection(myself->connection); + connection_del(myself->connection); } for(int i = 0; i < listen_sockets; i++) {