+ if(!c->outgoing->ai) {
+ if(!c->outgoing->cfg) {
+ ifdebug(CONNECTIONS) logger(LOG_ERR, "Could not set up a meta connection to %s",
+ c->name);
+ c->status.remove = true;
+ retry_outgoing(c->outgoing);
+ c->outgoing = NULL;
+ return;
+ }
+
+ char *address, *port, *space;
+
+ get_config_string(c->outgoing->cfg, &address);
+
+ space = strchr(address, ' ');
+
+ if(space) {
+ port = xstrdup(space + 1);
+ *space = 0;
+ } else {
+ if(!get_config_string(lookup_config(c->config_tree, "Port"), &port)) {
+ port = xstrdup("655");
+ }
+ }
+
+ c->outgoing->ai = str2addrinfo(address, port, SOCK_STREAM);
+
+ // If we cannot resolve the address, maybe we are using a proxy that can?
+ if(!c->outgoing->ai && proxytype != PROXY_NONE && is_valid_host_port(address, port)) {
+ memset(&c->address, 0, sizeof(c->address));
+ c->address.sa.sa_family = AF_UNKNOWN;
+ c->address.unknown.address = address;
+ c->address.unknown.port = port;
+ } else {
+ free(address);
+ free(port);
+ }
+
+ c->outgoing->aip = c->outgoing->ai;
+ c->outgoing->cfg = lookup_config_next(c->config_tree, c->outgoing->cfg);
+
+ if(!c->outgoing->ai && proxytype != PROXY_NONE) {
+ goto connect;
+ }
+ }
+
+ if(!c->outgoing->aip) {
+ if(c->outgoing->ai) {
+ freeaddrinfo(c->outgoing->ai);
+ }
+
+ c->outgoing->ai = NULL;
+ goto begin;
+ }
+
+ memcpy(&c->address, c->outgoing->aip->ai_addr, c->outgoing->aip->ai_addrlen);
+ c->outgoing->aip = c->outgoing->aip->ai_next;