Convert Port to numeric form before sending it to other nodes.
[tinc] / src / net_setup.c
index 70291bf..813c58b 100644 (file)
@@ -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");