X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fnet_setup.c;h=118d719c439d4420e023915c0406686973c9c45f;hp=70291bffe97111f5f4a30691e63c56172a669351;hb=9f53ab209d8a6a7622a49ed03cef735b6e3f3eeb;hpb=8ae54dc7c782bcc4b771ec0766fcf9eee115756e diff --git a/src/net_setup.c b/src/net_setup.c index 70291bff..118d719c 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -204,14 +204,14 @@ bool read_rsa_private_key(void) { /* Read Subnets from all host config files */ -static void load_all_subnets(void) { +void load_all_subnets(void) { DIR *dir; struct dirent *ent; char *dname; char *fname; avl_tree_t *config_tree; config_t *cfg; - subnet_t *s; + subnet_t *s, *s2; node_t *n; bool result; @@ -251,7 +251,11 @@ static void load_all_subnets(void) { if(!get_config_subnet(cfg, &s)) continue; - subnet_add(n, s); + if((s2 = lookup_subnet(n, s))) { + s2->expires = -1; + } else { + subnet_add(n, s); + } } exit_configuration(&config_tree); @@ -309,6 +313,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");