- if(!outgoing->ai && !outgoing->nai) {
- if(!outgoing->cfg) {
- logger(mesh, MESHLINK_ERROR, "Could not set up a meta connection to %s", outgoing->name);
- retry_outgoing(mesh, outgoing);
- return false;
+ outgoing->ai = get_known_addresses(n);
+ outgoing->aip = outgoing->ai;
+ return outgoing->aip;
+}
+
+static bool get_next_ai(meshlink_handle_t *mesh, outgoing_t *outgoing) {
+ if(!outgoing->ai) {
+ char *address = NULL;
+
+ if(get_config_string(outgoing->cfg, &address)) {
+ char *port;
+ char *space = strchr(address, ' ');
+
+ if(space) {
+ port = xstrdup(space + 1);
+ *space = 0;
+ } else {
+ if(!get_config_string(lookup_config(outgoing->config_tree, "Port"), &port)) {
+ logger(mesh, MESHLINK_ERROR, "No Port known for %s", outgoing->name);
+ return false;
+ }
+ }
+
+ outgoing->ai = str2addrinfo(address, port, SOCK_STREAM);
+ free(port);
+ free(address);