Change AutoConnect from int to bool.
authorGuus Sliepen <guus@tinc-vpn.org>
Tue, 6 May 2014 12:11:55 +0000 (14:11 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Tue, 6 May 2014 12:11:55 +0000 (14:11 +0200)
The proper value is 3, not 2 or 4, and 5 is right out. So just hardcode this value,
and only have the option to turn AutoConnect on or off.

doc/tinc.conf.5.in
doc/tinc.texi
src/net.c
src/net.h
src/net_setup.c

index 28296fb..072bf07 100644 (file)
@@ -114,15 +114,13 @@ If
 .Qq any
 is selected, then depending on the operating system both IPv4 and IPv6 or just
 IPv6 listening sockets will be created.
 .Qq any
 is selected, then depending on the operating system both IPv4 and IPv6 or just
 IPv6 listening sockets will be created.
-.It Va AutoConnect Li = Ar count Po 0 Pc Bq experimental
-If set to a non-zero value,
+.It Va AutoConnect Li = yes | no Po no Pc Bq experimental
+If set to yes,
 .Nm
 .Nm
-will try to only have
-.Ar count
-meta connections to other nodes,
-by automatically making or breaking connections to known nodes.
-Higher values increase redundancy but also increase meta data overhead.
-When using this option, a good value is 3.
+will automatically set up meta connections to other nodes,
+without requiring
+.Va ConnectTo
+variables.
 .It Va BindToAddress Li = Ar address Op Ar port
 This is the same as
 .Va ListenAddress ,
 .It Va BindToAddress Li = Ar address Op Ar port
 This is the same as
 .Va ListenAddress ,
@@ -169,7 +167,9 @@ The names should be known to this tinc daemon
 line).
 .Pp
 If you don't specify a host with
 line).
 .Pp
 If you don't specify a host with
-.Va ConnectTo ,
+.Va ConnectTo
+and don't enable
+.Va AutoConnect ,
 .Nm tinc
 won't try to connect to other daemons at all,
 and will instead just listen for incoming connections.
 .Nm tinc
 won't try to connect to other daemons at all,
 and will instead just listen for incoming connections.
index 555b816..3082397 100644 (file)
@@ -843,12 +843,9 @@ If any is selected, then depending on the operating system
 both IPv4 and IPv6 or just IPv6 listening sockets will be created.
 
 @cindex AutoConnect
 both IPv4 and IPv6 or just IPv6 listening sockets will be created.
 
 @cindex AutoConnect
-@item AutoConnect = <count> (0) [experimental]
-If set to a non-zero value,
-tinc will try to only have count meta connections to other nodes,
-by automatically making or breaking connections to known nodes.
-Higher values increase redundancy but also increase meta data overhead.
-When using this option, a good value is 3.
+@item AutoConnect = <yes|no> (no) [experimental]
+If set to yes, tinc will automatically set up meta connections to other nodes,
+without requiring @var{ConnectTo} variables.
 
 @cindex BindToAddress
 @item BindToAddress = <@var{address}> [<@var{port}>]
 
 @cindex BindToAddress
 @item BindToAddress = <@var{address}> [<@var{port}>]
@@ -895,7 +892,7 @@ in which case outgoing connections to each specified tinc daemon are made.
 The names should be known to this tinc daemon
 (i.e., there should be a host configuration file for the name on the ConnectTo line).
 
 The names should be known to this tinc daemon
 (i.e., there should be a host configuration file for the name on the ConnectTo line).
 
-If you don't specify a host with ConnectTo,
+If you don't specify a host with ConnectTo and don't enable AutoConnect,
 tinc won't try to connect to other daemons at all,
 and will instead just listen for incoming connections.
 
 tinc won't try to connect to other daemons at all,
 and will instead just listen for incoming connections.
 
index baf576d..92f6be8 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -204,7 +204,7 @@ static void periodic_handler(void *data) {
                                nc++;
                }
 
                                nc++;
                }
 
-               if(nc < autoconnect) {
+               if(nc < 3) {
                        /* Not enough active connections, try to add one.
                           Choose a random node, if we don't have a connection to it,
                           and we are not already trying to make one, create an
                        /* Not enough active connections, try to add one.
                           Choose a random node, if we don't have a connection to it,
                           and we are not already trying to make one, create an
@@ -238,7 +238,7 @@ static void periodic_handler(void *data) {
                                }
                                break;
                        }
                                }
                                break;
                        }
-               } else if(nc > autoconnect) {
+               } else if(nc > 3) {
                        /* Too many active connections, try to remove one.
                           Choose a random outgoing connection to a node
                           that has at least one other connection.
                        /* Too many active connections, try to remove one.
                           Choose a random outgoing connection to a node
                           that has at least one other connection.
@@ -264,7 +264,7 @@ static void periodic_handler(void *data) {
                        }
                }
 
                        }
                }
 
-               if(nc >= autoconnect) {
+               if(nc >= 3) {
                        /* If we have enough active connections,
                           remove any pending outgoing connections.
                        */
                        /* If we have enough active connections,
                           remove any pending outgoing connections.
                        */
index 845fd75..6c7064b 100644 (file)
--- a/src/net.h
+++ b/src/net.h
@@ -137,7 +137,7 @@ extern int udp_sndbuf;
 extern int max_connection_burst;
 extern bool do_prune;
 extern char *myport;
 extern int max_connection_burst;
 extern bool do_prune;
 extern char *myport;
-extern int autoconnect;
+extern bool autoconnect;
 extern bool disablebuggypeers;
 extern int contradicting_add_edge;
 extern int contradicting_del_edge;
 extern bool disablebuggypeers;
 extern int contradicting_add_edge;
 extern int contradicting_del_edge;
index fdd4834..839d7a9 100644 (file)
@@ -52,7 +52,7 @@ char *proxyport;
 char *proxyuser;
 char *proxypass;
 proxytype_t proxytype;
 char *proxyuser;
 char *proxypass;
 proxytype_t proxytype;
-int autoconnect;
+bool autoconnect;
 bool disablebuggypeers;
 
 char *scriptinterpreter;
 bool disablebuggypeers;
 
 char *scriptinterpreter;
@@ -630,9 +630,15 @@ bool setup_myself_reloadable(void) {
        if(!get_config_int(lookup_config(config_tree, "KeyExpire"), &keylifetime))
                keylifetime = 3600;
 
        if(!get_config_int(lookup_config(config_tree, "KeyExpire"), &keylifetime))
                keylifetime = 3600;
 
-       get_config_int(lookup_config(config_tree, "AutoConnect"), &autoconnect);
-       if(autoconnect < 0)
-               autoconnect = 0;
+       config_t *cfg = lookup_config(config_tree, "AutoConnect");
+       if(cfg) {
+               if(!get_config_bool(cfg, &autoconnect)) {
+                       // Some backwards compatibility with when this option was an int
+                       int val = 0;
+                       get_config_int(cfg, &val);
+                       autoconnect = val;
+               }
+       }
 
        get_config_bool(lookup_config(config_tree, "DisableBuggyPeers"), &disablebuggypeers);
 
 
        get_config_bool(lookup_config(config_tree, "DisableBuggyPeers"), &disablebuggypeers);