Allow port to be specified in Address statements.
authorGuus Sliepen <guus@tinc-vpn.org>
Wed, 23 Dec 2009 18:49:38 +0000 (19:49 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Wed, 23 Dec 2009 18:49:38 +0000 (19:49 +0100)
This allows one to connect to use more than one port number to connect to
another node. The syntax is now:

Address = <hostname> [<port>]

doc/tinc.conf.5.in
doc/tinc.texi
src/net_socket.c

index 1cb2f0c..8e64445 100644 (file)
@@ -330,9 +330,10 @@ Since host configuration files only contain public keys,
 no secrets are revealed by sending out this information.
 .Bl -tag -width indent
 
 no secrets are revealed by sending out this information.
 .Bl -tag -width indent
 
-.It Va Address Li = Ar address Bq recommended
+.It Va Address Li = Ar address Oo port Oc Bq recommended
 The IP address or hostname of this tinc daemon on the real network.
 This will only be used when trying to make an outgoing connection to this tinc daemon.
 The IP address or hostname of this tinc daemon on the real network.
 This will only be used when trying to make an outgoing connection to this tinc daemon.
+Optionally, a port can be specified to use for this address.
 Multiple
 .Va Address
 variables can be specified, in which case each address will be tried until a working
 Multiple
 .Va Address
 variables can be specified, in which case each address will be tried until a working
@@ -380,7 +381,10 @@ When this option is enabled, tinc will try to discover the path MTU to this node
 After the path MTU has been discovered, it will be enforced on the VPN.
 
 .It Va Port Li = Ar port Pq 655
 After the path MTU has been discovered, it will be enforced on the VPN.
 
 .It Va Port Li = Ar port Pq 655
-The port number on which this tinc daemon is listening for incoming connections.
+The port number on which this tinc daemon is listening for incoming connections,
+which is used if no port number is specified in an
+.Va Address
+statement.
 
 .It Va PublicKey Li = Ar key Bq obsolete
 The public RSA key of this tinc daemon.
 
 .It Va PublicKey Li = Ar key Bq obsolete
 The public RSA key of this tinc daemon.
index e6e6a42..3565818 100644 (file)
@@ -943,10 +943,11 @@ and will only allow nodes and subnets on the VPN which are present in the
 
 @table @asis
 @cindex Address
 
 @table @asis
 @cindex Address
-@item Address = <@var{IP address}|@var{hostname}> [recommended]
+@item Address = <@var{IP address}|@var{hostname}> [<port>] [recommended]
 This variable is only required if you want to connect to this host.  It
 must resolve to the external IP address where the host can be reached,
 not the one that is internal to the VPN.
 This variable is only required if you want to connect to this host.  It
 must resolve to the external IP address where the host can be reached,
 not the one that is internal to the VPN.
+If no port is specified, the default Port is used.
 
 @cindex Cipher
 @item Cipher = <@var{cipher}> (blowfish)
 
 @cindex Cipher
 @item Cipher = <@var{cipher}> (blowfish)
index 46e0532..cd41e37 100644 (file)
@@ -331,7 +331,7 @@ void finish_connecting(connection_t *c) {
 }
 
 void do_outgoing_connection(connection_t *c) {
 }
 
 void do_outgoing_connection(connection_t *c) {
-       char *address, *port;
+       char *address, *port, *space;
        int result;
 
        if(!c->outgoing) {
        int result;
 
        if(!c->outgoing) {
@@ -352,8 +352,14 @@ begin:
 
                get_config_string(c->outgoing->cfg, &address);
 
 
                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);
 
                c->outgoing->ai = str2addrinfo(address, port, SOCK_STREAM);
                free(address);