X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fnet_setup.c;h=813c58baca29fbf782a88d2133d9f01e00d72e4d;hp=cad84ccb26d2865157d0289e1de359eda5284ecc;hb=f75e71bc693847af71f61fb72cd788e3e47f9bd3;hpb=9fed0ec34b9208611a7e96a595f23fa04e60a5c0 diff --git a/src/net_setup.c b/src/net_setup.c index cad84ccb..813c58ba 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -309,6 +309,16 @@ bool setup_myself(void) { && !get_config_string(lookup_config(myself->connection->config_tree, "Port"), &myport)) myport = xstrdup("655"); + if(!atoi(myport)) { + struct addrinfo *ai = str2addrinfo("localhost", myport, SOCK_DGRAM); + sockaddr_t sa; + if(!ai || !ai->ai_addr) + return false; + free(myport); + memcpy(&sa, ai->ai_addr, ai->ai_addrlen); + sockaddr2str(&sa, NULL, &myport); + } + /* Read in all the subnets specified in the host configuration file */ cfg = lookup_config(myself->connection->config_tree, "Subnet"); @@ -339,7 +349,10 @@ bool setup_myself(void) { if(myself->options & OPTION_TCPONLY) myself->options |= OPTION_INDIRECT; + get_config_bool(lookup_config(config_tree, "DirectOnly"), &directonly); + get_config_bool(lookup_config(config_tree, "StrictSubnets"), &strictsubnets); get_config_bool(lookup_config(config_tree, "TunnelServer"), &tunnelserver); + strictsubnets |= tunnelserver; if(get_config_string(lookup_config(config_tree, "Mode"), &mode)) { if(!strcasecmp(mode, "router")) @@ -353,8 +366,21 @@ bool setup_myself(void) { return false; } free(mode); - } else - routing_mode = RMODE_ROUTER; + } + + if(get_config_string(lookup_config(config_tree, "Forwarding"), &mode)) { + if(!strcasecmp(mode, "off")) + forwarding_mode = FMODE_OFF; + else if(!strcasecmp(mode, "internal")) + forwarding_mode = FMODE_INTERNAL; + else if(!strcasecmp(mode, "kernel")) + forwarding_mode = FMODE_KERNEL; + else { + logger(LOG_ERR, "Invalid forwarding mode!"); + return false; + } + free(mode); + } choice = true; get_config_bool(lookup_config(myself->connection->config_tree, "PMTUDiscovery"), &choice); @@ -485,7 +511,7 @@ bool setup_myself(void) { graph(); - if(tunnelserver) + if(strictsubnets) load_all_subnets(); /* Open device */