Don't log errors when autoconnecting fails and debuglevel is 0.
authorGuus Sliepen <guus@tinc-vpn.org>
Mon, 6 Nov 2017 20:46:17 +0000 (21:46 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Mon, 6 Nov 2017 20:46:17 +0000 (21:46 +0100)
src/autoconnect.c
src/conf.c
src/conf.h
src/net.c
src/net.h
src/net_setup.c
src/net_socket.c
src/protocol_auth.c

index 8adb74f..132467e 100644 (file)
@@ -65,7 +65,7 @@ static void make_new_connection() {
                        outgoing_t *outgoing = xzalloc(sizeof(*outgoing));
                        outgoing->name = xstrdup(n->name);
                        list_insert_tail(outgoing_list, outgoing);
-                       setup_outgoing_connection(outgoing);
+                       setup_outgoing_connection(outgoing, false);
                }
 
                break;
@@ -102,7 +102,7 @@ static void connect_to_unreachable() {
                outgoing_t *outgoing = xzalloc(sizeof(*outgoing));
                outgoing->name = xstrdup(n->name);
                list_insert_tail(outgoing_list, outgoing);
-               setup_outgoing_connection(outgoing);
+               setup_outgoing_connection(outgoing, false);
 
                return;
        }
index e789f72..5304ab5 100644 (file)
@@ -313,7 +313,7 @@ config_t *parse_config_line(char *line, const char *fname, int lineno) {
   Parse a configuration file and put the results in the configuration tree
   starting at *base.
 */
-bool read_config_file(splay_tree_t *config_tree, const char *fname) {
+bool read_config_file(splay_tree_t *config_tree, const char *fname, bool verbose) {
        FILE *fp;
        char buffer[MAX_STRING_SIZE];
        char *line;
@@ -325,7 +325,7 @@ bool read_config_file(splay_tree_t *config_tree, const char *fname) {
        fp = fopen(fname, "r");
 
        if(!fp) {
-               logger(DEBUG_ALWAYS, LOG_DEBUG, "Cannot open config file %s: %s", fname, strerror(errno));
+               logger(verbose ? DEBUG_ALWAYS : DEBUG_CONNECTIONS, LOG_ERR, "Cannot open config file %s: %s", fname, strerror(errno));
                return false;
        }
 
@@ -415,7 +415,7 @@ bool read_server_config(void) {
 
        snprintf(fname, sizeof(fname), "%s" SLASH "tinc.conf", confbase);
        errno = 0;
-       x = read_config_file(config_tree, fname);
+       x = read_config_file(config_tree, fname, true);
 
        // We will try to read the conf files in the "conf.d" dir
        if(x) {
@@ -434,7 +434,7 @@ bool read_server_config(void) {
                                // And we try to read the ones that end with ".conf"
                                if(l > 5 && !strcmp(".conf", & ep->d_name[ l - 5 ])) {
                                        snprintf(fname, sizeof(fname), "%s" SLASH "%s", dname, ep->d_name);
-                                       x = read_config_file(config_tree, fname);
+                                       x = read_config_file(config_tree, fname, true);
                                }
                        }
 
@@ -449,16 +449,12 @@ bool read_server_config(void) {
        return x;
 }
 
-bool read_host_config(splay_tree_t *config_tree, const char *name) {
-       char fname[PATH_MAX];
-       bool x;
-
+bool read_host_config(splay_tree_t *config_tree, const char *name, bool verbose) {
        read_config_options(config_tree, name);
 
+       char fname[PATH_MAX];
        snprintf(fname, sizeof(fname), "%s" SLASH "hosts" SLASH "%s", confbase, name);
-       x = read_config_file(config_tree, fname);
-
-       return x;
+       return read_config_file(config_tree, fname, verbose);
 }
 
 bool append_config_file(const char *name, const char *key, const char *value) {
index 817c2cb..6220479 100644 (file)
@@ -55,10 +55,10 @@ extern bool get_config_address(const config_t *, struct addrinfo **);
 extern bool get_config_subnet(const config_t *, struct subnet_t **);
 
 extern config_t *parse_config_line(char *, const char *, int);
-extern bool read_config_file(splay_tree_t *, const char *);
+extern bool read_config_file(splay_tree_t *, const char *, bool verbose);
 extern void read_config_options(splay_tree_t *, const char *);
 extern bool read_server_config(void);
-extern bool read_host_config(splay_tree_t *, const char *);
+extern bool read_host_config(splay_tree_t *, const char *, bool verbose);
 extern bool append_config_file(const char *, const char *, const char *);
 
 #endif
index 097a79c..5d84741 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -327,7 +327,7 @@ int reload_configuration(void) {
        read_config_options(config_tree, NULL);
 
        snprintf(fname, sizeof(fname), "%s" SLASH "hosts" SLASH "%s", confbase, myself->name);
-       read_config_file(config_tree, fname);
+       read_config_file(config_tree, fname, true);
 
        /* Parse some options that are allowed to be changed while tinc is running */
 
index 6d4dfc8..73e82e0 100644 (file)
--- a/src/net.h
+++ b/src/net.h
@@ -204,7 +204,7 @@ extern void device_enable(void);
 extern void device_disable(void);
 extern bool setup_myself_reloadable(void);
 extern bool setup_network(void);
-extern void setup_outgoing_connection(struct outgoing_t *);
+extern void setup_outgoing_connection(struct outgoing_t *, bool verbose);
 extern void try_outgoing_connections(void);
 extern void close_network_connections(void);
 extern int main_loop(void);
index 49ea31b..ad9398d 100644 (file)
@@ -75,7 +75,7 @@ bool node_read_ecdsa_public_key(node_t *n) {
 
        init_configuration(&config_tree);
 
-       if(!read_host_config(config_tree, n->name)) {
+       if(!read_host_config(config_tree, n->name, true)) {
                goto exit;
        }
 
@@ -120,7 +120,7 @@ bool read_ecdsa_public_key(connection_t *c) {
        if(!c->config_tree) {
                init_configuration(&c->config_tree);
 
-               if(!read_host_config(c->config_tree, c->name)) {
+               if(!read_host_config(c->config_tree, c->name, true)) {
                        return false;
                }
        }
@@ -382,7 +382,7 @@ void load_all_nodes(void) {
                splay_tree_t *config_tree;
                init_configuration(&config_tree);
                read_config_options(config_tree, ent->d_name);
-               read_host_config(config_tree, ent->d_name);
+               read_host_config(config_tree, ent->d_name, true);
 
                if(!n) {
                        n = new_node();
@@ -843,7 +843,7 @@ static bool setup_myself(void) {
        myself->connection = new_connection();
        myself->name = name;
        myself->connection->name = xstrdup(name);
-       read_host_config(config_tree, name);
+       read_host_config(config_tree, name, true);
 
        if(!get_config_string(lookup_config(config_tree, "Port"), &myport)) {
                myport = xstrdup("655");
index c020e8f..43ea4f8 100644 (file)
@@ -332,7 +332,7 @@ int setup_vpn_in_socket(const sockaddr_t *sa) {
 } /* int setup_vpn_in_socket */
 
 static void retry_outgoing_handler(void *data) {
-       setup_outgoing_connection(data);
+       setup_outgoing_connection(data, true);
 }
 
 void retry_outgoing(outgoing_t *outgoing) {
@@ -678,7 +678,7 @@ static struct addrinfo *get_known_addresses(node_t *n) {
        return ai;
 }
 
-void setup_outgoing_connection(outgoing_t *outgoing) {
+void setup_outgoing_connection(outgoing_t *outgoing, bool verbose) {
        timeout_del(&outgoing->ev);
 
        node_t *n = lookup_node(outgoing->name);
@@ -695,7 +695,7 @@ void setup_outgoing_connection(outgoing_t *outgoing) {
        }
 
        init_configuration(&outgoing->config_tree);
-       read_host_config(outgoing->config_tree, outgoing->name);
+       read_host_config(outgoing->config_tree, outgoing->name, verbose);
        outgoing->cfg = lookup_config(outgoing->config_tree, "Address");
 
        if(!outgoing->cfg) {
@@ -704,7 +704,7 @@ void setup_outgoing_connection(outgoing_t *outgoing) {
                }
 
                if(!outgoing->kai) {
-                       logger(DEBUG_ALWAYS, LOG_DEBUG, "No address known for %s", outgoing->name);
+                       logger(verbose ? DEBUG_ALWAYS : DEBUG_CONNECTIONS, LOG_DEBUG, "No address known for %s", outgoing->name);
                        goto remove;
                }
        }
@@ -920,7 +920,7 @@ void try_outgoing_connections(void) {
                        outgoing_t *outgoing = xzalloc(sizeof(*outgoing));
                        outgoing->name = name;
                        list_insert_tail(outgoing_list, outgoing);
-                       setup_outgoing_connection(outgoing);
+                       setup_outgoing_connection(outgoing, true);
                }
        }
 
index 56ff3b1..c0a2aea 100644 (file)
@@ -428,7 +428,7 @@ bool id_h(connection_t *c, const char *request) {
        if(!c->config_tree) {
                init_configuration(&c->config_tree);
 
-               if(!read_host_config(c->config_tree, c->name)) {
+               if(!read_host_config(c->config_tree, c->name, false)) {
                        logger(DEBUG_ALWAYS, LOG_ERR, "Peer %s had unknown identity (%s)", c->hostname, c->name);
                        return false;
                }