Document Weight and also allow it to be set from tinc.conf.
authorGuus Sliepen <guus@tinc-vpn.org>
Wed, 29 Jan 2014 16:32:18 +0000 (17:32 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Wed, 29 Jan 2014 16:32:18 +0000 (17:32 +0100)
doc/tinc.conf.5.in
doc/tinc.texi
src/protocol_auth.c

index 632c849..25b398d 100644 (file)
@@ -586,6 +586,12 @@ Setting this options also implicitly sets IndirectData.
 .Pp
 Since version 1.0.10, tinc will automatically detect whether communication via
 UDP is possible or not.
 .Pp
 Since version 1.0.10, tinc will automatically detect whether communication via
 UDP is possible or not.
+.It Va Weight Li = Ar weight
+If this variable is set, it overrides the weight given to connections made with
+another host. A higher
+.Ar weight
+means a lower priority is given to this connection when broadcasting or
+forwarding packets.
 .El
 .Sh SCRIPTS
 Apart from reading the server and host configuration files,
 .El
 .Sh SCRIPTS
 Apart from reading the server and host configuration files,
index 6c09a01..e5a5eb5 100644 (file)
@@ -1352,6 +1352,12 @@ TCP connection instead of a UDP connection.  This is especially useful
 for those who want to run a tinc daemon from behind a masquerading
 firewall, or if UDP packet routing is disabled somehow.
 Setting this options also implicitly sets IndirectData.
 for those who want to run a tinc daemon from behind a masquerading
 firewall, or if UDP packet routing is disabled somehow.
 Setting this options also implicitly sets IndirectData.
+
+@cindex Weight
+@item Weight = <weight>
+If this variable is set, it overrides the weight given to connections made with
+another host. A higher weight means a lower priority is given to this
+connection when broadcasting or forwarding packets.
 @end table
 
 
 @end table
 
 
index 147c3b4..04674e8 100644 (file)
@@ -672,7 +672,8 @@ bool send_ack(connection_t *c) {
        if(choice)
                c->options |= OPTION_CLAMP_MSS;
 
        if(choice)
                c->options |= OPTION_CLAMP_MSS;
 
-       get_config_int(lookup_config(c->config_tree, "Weight"), &c->estimated_weight);
+       if(!get_config_int(lookup_config(c->config_tree, "Weight"), &c->estimated_weight))
+               get_config_int(lookup_config(config_tree, "Weight"), &c->estimated_weight);
 
        return send_request(c, "%d %s %d %x", ACK, myport, c->estimated_weight, (c->options & 0xffffff) | (experimental ? (PROT_MINOR << 24) : 0));
 }
 
        return send_request(c, "%d %s %d %x", ACK, myport, c->estimated_weight, (c->options & 0xffffff) | (experimental ? (PROT_MINOR << 24) : 0));
 }