- if(space) {
- port = xstrdup(space + 1);
- *space = 0;
- } else {
- // TODO: Only allow Address statements?
- if(!get_config_string(lookup_config(outgoing->config_tree, "Port"), &port)) {
- logger(mesh, MESHLINK_ERROR, "No Port known for %s", outgoing->name);
- retry_outgoing(mesh, outgoing);
- return false;
+static bool get_next_cfg(meshlink_handle_t *mesh, outgoing_t *outgoing, char *variable) {
+ (void)mesh;
+
+ if(!outgoing->cfg) {
+ outgoing->cfg = lookup_config(outgoing->config_tree, variable);
+ } else {
+ outgoing->cfg = lookup_config_next(outgoing->config_tree, outgoing->cfg);
+ }
+
+ return outgoing->cfg;
+}
+
+static bool get_next_outgoing_address(meshlink_handle_t *mesh, outgoing_t *outgoing) {
+ bool start = false;
+
+ if(outgoing->state == OUTGOING_START) {
+ start = true;
+ outgoing->state = OUTGOING_CANONICAL;
+ }
+
+ if(outgoing->state == OUTGOING_CANONICAL) {
+ while(outgoing->aip || get_next_cfg(mesh, outgoing, "CanonicalAddress")) {
+ if(get_next_ai(mesh, outgoing)) {
+ return true;
+ } else {
+ freeaddrinfo(outgoing->ai);
+ outgoing->ai = NULL;
+ outgoing->aip = NULL;