Skip to content

Commit

Permalink
Make sure all targets are reported, even if they do not resolve to
Browse files Browse the repository at this point in the history
an address at all.
  • Loading branch information
schoenw committed Jun 30, 2015
1 parent bf6f508 commit c887f0b
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions happy.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static unsigned int delay = 25; /* in ms */
static int pump_timeout = 2000; /* in ms */

static int target_valid(target_t *tp) {
return (tp && tp->host && tp->port && tp->endpoints);
return (tp && tp->host && tp->port);
}

static int endpoint_valid(endpoint_t *ep) {
Expand Down Expand Up @@ -410,7 +410,7 @@ expand(const char *host, const char *port)
}
}

/* create a string represetation of CNAME chains */
/* create a string representation of CNAME chains */
canonname = NULL;
for(int i = 0; i < dstset_num; i++){
char* dangler = canonname;
Expand All @@ -428,11 +428,15 @@ expand(const char *host, const char *port)
free(dstset); dstset = NULL;
}

tp = xcalloc(1, sizeof(target_t));
tp->host = strdup(host);
tp->port = strdup(port);

n = getaddrinfo(host, port, &hints, &ai_list);
if (n != 0) {
fprintf(stderr, "%s: %s (skipping %s port %s)\n",
fprintf(stderr, "%s: getaddrinfo: %s (skipping %s port %s)\n",
progname, gai_strerror(n), host, port);
return NULL;
return tp;
}

tp = xcalloc(1, sizeof(target_t));
Expand Down Expand Up @@ -599,10 +603,6 @@ prepare(target_t *targets)

assert(targets);

if (! targets->num_endpoints) {
return;
}

dd.tv_sec = delay / 1000;
dd.tv_usec = (delay % 1000) * 1000;

Expand Down Expand Up @@ -918,6 +918,11 @@ report_sk(target_t *targets)

for (tp = targets; target_valid(tp); tp = tp->next) {

if (! tp->endpoints) {
printf("HAPPY.0;%lu;%s;%s;%s\n",
now, "FAIL", tp->host, tp->port);
}

for (ep = tp->endpoints; endpoint_valid(ep); ep++) {

n = getnameinfo((struct sockaddr *) &ep->addr,
Expand Down Expand Up @@ -962,6 +967,11 @@ report_pump_sk(target_t *targets)

for (tp = targets; target_valid(tp); tp = tp->next) {

if (! tp->endpoints) {
printf("PUMP.0;%lu;%s;%s;%s\n",
now, "FAIL", tp->host, tp->port);
}

for (ep = tp->endpoints; endpoint_valid(ep); ep++) {

n = getnameinfo((struct sockaddr *) &ep->addr,
Expand Down Expand Up @@ -1009,6 +1019,11 @@ report_dns_sk(target_t *targets)

for (tp = targets; target_valid(tp); tp = tp->next) {

if (! tp->endpoints) {
printf("DNS.0;%lu;%s;%s;%s\n",
now, "FAIL", tp->host, tp->port);
}

for (ep = tp->endpoints; endpoint_valid(ep); ep++) {

n = getnameinfo((struct sockaddr *) &ep->addr,
Expand Down

0 comments on commit c887f0b

Please sign in to comment.