summaryrefslogtreecommitdiffstats
path: root/src/fastd.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-12-16 20:33:53 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-12-16 20:33:53 +0100
commit794958aa7834c6703e369d15b99fe0b38a8edb05 (patch)
tree3c4aa5d740a19742be18151dafcd261bfdb26a0d /src/fastd.c
parentee300afb79e9788f98d4c98d4535018f7fdbdcdd (diff)
downloadfastd-794958aa7834c6703e369d15b99fe0b38a8edb05.tar
fastd-794958aa7834c6703e369d15b99fe0b38a8edb05.zip
resolve: consider all addresses returned for a hostname
Diffstat (limited to 'src/fastd.c')
-rw-r--r--src/fastd.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/fastd.c b/src/fastd.c
index a9cb0c4..d6bfa2f 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -412,7 +412,7 @@ static void send_handshake(fastd_context_t *ctx, fastd_peer_t *peer) {
if (!peer->next_remote)
exit_bug(ctx, "send_handshake: no remote");
- fastd_peer_claim_address(ctx, peer, NULL, NULL, &peer->next_remote->address);
+ fastd_peer_claim_address(ctx, peer, NULL, NULL, &peer->next_remote->addresses[peer->next_remote->current_address]);
fastd_peer_reset_socket(ctx, peer);
}
@@ -456,10 +456,15 @@ static void handle_handshake_queue(fastd_context_t *ctx) {
if (fastd_peer_is_established(peer))
return;
+ if (++peer->next_remote->current_address < peer->next_remote->n_addresses)
+ return;
+
peer->next_remote = peer->next_remote->next;
if (!peer->next_remote)
peer->next_remote = peer->remotes;
+ peer->next_remote->current_address = 0;
+
if (fastd_remote_is_dynamic(peer->next_remote))
fastd_resolve_peer(ctx, peer, peer->next_remote);
}
@@ -503,12 +508,17 @@ static void handle_tun(fastd_context_t *ctx) {
static void handle_resolve_returns(fastd_context_t *ctx) {
fastd_resolve_return_t resolve_return;
-
while (read(ctx->resolverfd, &resolve_return, sizeof(resolve_return)) < 0) {
if (errno != EINTR)
exit_errno(ctx, "handle_resolve_return: read");
}
+ fastd_peer_address_t addresses[resolve_return.n_addr];
+ while (read(ctx->resolverfd, &addresses, sizeof(addresses)) < 0) {
+ if (errno != EINTR)
+ exit_errno(ctx, "handle_resolve_return: read");
+ }
+
fastd_peer_t *peer;
for (peer = ctx->peers; peer; peer = peer->next) {
if (!peer->config)
@@ -523,7 +533,7 @@ static void handle_resolve_returns(fastd_context_t *ctx) {
if (!remote)
continue;
- fastd_peer_handle_resolve(ctx, peer, remote, &resolve_return.addr);
+ fastd_peer_handle_resolve(ctx, peer, remote, resolve_return.n_addr, addresses);
break;
}