-void try_outgoing_connections(void) {
- /* If there is no outgoing list yet, create one. Otherwise, mark all outgoings as deleted. */
-
- if(!outgoing_list) {
- outgoing_list = list_alloc((list_action_t)free_outgoing);
- } else {
- for list_each(outgoing_t, outgoing, outgoing_list)
- outgoing->timeout = -1;
- }
-
- /* Make sure there is one outgoing_t in the list for each ConnectTo. */
-
- for(config_t *cfg = lookup_config(config_tree, "ConnectTo"); cfg; cfg = lookup_config_next(config_tree, cfg)) {
- char *name;
- get_config_string(cfg, &name);
-
- if(!check_id(name)) {
- logger(DEBUG_ALWAYS, LOG_ERR,
- "Invalid name for outgoing connection in %s line %d",
- cfg->file, cfg->line);
- free(name);
- continue;
- }
-
- bool found = false;
-
- for list_each(outgoing_t, outgoing, outgoing_list) {
- if(!strcmp(outgoing->name, name)) {
- found = true;
- outgoing->timeout = 0;
- break;
- }
- }
-
- if(!found) {
- outgoing_t *outgoing = xmalloc_and_zero(sizeof *outgoing);
- outgoing->name = name;
- list_insert_tail(outgoing_list, outgoing);
- setup_outgoing_connection(outgoing);
- }
- }
-
- /* Terminate any connections whose outgoing_t is to be deleted. */