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;
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;
}
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;
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;
}
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) {
// 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);
}
}
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) {
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
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 */
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);
init_configuration(&config_tree);
- if(!read_host_config(config_tree, n->name)) {
+ if(!read_host_config(config_tree, n->name, true)) {
goto exit;
}
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;
}
}
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();
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");
} /* 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) {
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);
}
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) {
}
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;
}
}
outgoing_t *outgoing = xzalloc(sizeof(*outgoing));
outgoing->name = name;
list_insert_tail(outgoing_list, outgoing);
- setup_outgoing_connection(outgoing);
+ setup_outgoing_connection(outgoing, true);
}
}
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;
}