Allow port to be specified in Address statements.
[oweals/tinc.git] / src / net_socket.c
index 46e0532eaf59d5f8e5f0f36887fe5a0f9d560ffe..cd41e37b0628859a27f7f5d7071fba2fc60cb214 100644 (file)
@@ -331,7 +331,7 @@ void finish_connecting(connection_t *c) {
 }
 
 void do_outgoing_connection(connection_t *c) {
-       char *address, *port;
+       char *address, *port, *space;
        int result;
 
        if(!c->outgoing) {
@@ -352,8 +352,14 @@ begin:
 
                get_config_string(c->outgoing->cfg, &address);
 
-               if(!get_config_string(lookup_config(c->config_tree, "Port"), &port))
-                       xasprintf(&port, "655");
+               space = strchr(address, ' ');
+               if(space) {
+                       port = xstrdup(space + 1);
+                       *space = 0;
+               } else {
+                       if(!get_config_string(lookup_config(c->config_tree, "Port"), &port))
+                               port = xstrdup("655");
+               }
 
                c->outgoing->ai = str2addrinfo(address, port, SOCK_STREAM);
                free(address);