Skip to content

Commit

Permalink
Merge pull request #459 from fdcastel/dont-cross-the-streams
Browse files Browse the repository at this point in the history
Fix #450: Do not use an IP resolution method different than the one specified in configuration.
  • Loading branch information
troglobit authored Sep 29, 2023
2 parents b670b31 + 3bcb509 commit c62d719
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/ddns.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,6 @@ static int get_address_remote(ddns_t *ctx, ddns_info_t *info, char *address, siz

static int get_address_cmd(ddns_t *ctx, ddns_info_t *info, char *address, size_t len)
{
if (!info->checkip_cmd || !info->checkip_cmd[0])
return 1;

DO(shell_transaction(ctx, info, info->checkip_cmd));
logit(LOG_DEBUG, "Command response:");
logit(LOG_DEBUG, "%s", ctx->work_buf);
Expand Down Expand Up @@ -403,9 +400,6 @@ static int get_address_iface(ddns_t *ctx, const char *ifname, char *address, siz
char *ptr, trailer[IFNAMSIZ + 2];
struct ifaddrs *ifaddr, *ifa;

if (!ifname || !ifname[0])
return 1;

/* Trailer to strip, if set by getnameinfo() */
snprintf(trailer, sizeof(trailer), "%%%s", ifname);

Expand Down Expand Up @@ -467,17 +461,22 @@ static int get_address_backend(ddns_t *ctx, ddns_info_t *info, char *address, si
logit(LOG_DEBUG, "Get address for %s", info->system->name);
memset(address, 0, len);

if (!get_address_cmd (ctx, info, address, len))
return 0;

/* Check info specific interface */
if (!get_address_iface (ctx, info->ifname, address, len))
return 0;

/* Check the global interface */
if (!get_address_iface (ctx, iface, address, len))
return 0;
if (info->checkip_cmd && info->checkip_cmd[0]) {
/* Get address from command */
return get_address_cmd(ctx, info, address, len);
}

if (info->ifname && info->ifname[0]) {
/* Get address from specific interface */
return get_address_iface(ctx, info->ifname, address, len);
}

if (iface && iface[0]) {
/* Get address from global interface */
return get_address_iface(ctx, iface, address, len);
}

/* Get address from remote service */
if (!get_address_remote(ctx, info, address, len))
return 0;

Expand Down

0 comments on commit c62d719

Please sign in to comment.