Skip to content

Commit c62d719

Browse files
authored
Merge pull request #459 from fdcastel/dont-cross-the-streams
Fix #450: Do not use an IP resolution method different than the one specified in configuration.
2 parents b670b31 + 3bcb509 commit c62d719

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

src/ddns.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,6 @@ static int get_address_remote(ddns_t *ctx, ddns_info_t *info, char *address, siz
352352

353353
static int get_address_cmd(ddns_t *ctx, ddns_info_t *info, char *address, size_t len)
354354
{
355-
if (!info->checkip_cmd || !info->checkip_cmd[0])
356-
return 1;
357-
358355
DO(shell_transaction(ctx, info, info->checkip_cmd));
359356
logit(LOG_DEBUG, "Command response:");
360357
logit(LOG_DEBUG, "%s", ctx->work_buf);
@@ -403,9 +400,6 @@ static int get_address_iface(ddns_t *ctx, const char *ifname, char *address, siz
403400
char *ptr, trailer[IFNAMSIZ + 2];
404401
struct ifaddrs *ifaddr, *ifa;
405402

406-
if (!ifname || !ifname[0])
407-
return 1;
408-
409403
/* Trailer to strip, if set by getnameinfo() */
410404
snprintf(trailer, sizeof(trailer), "%%%s", ifname);
411405

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

470-
if (!get_address_cmd (ctx, info, address, len))
471-
return 0;
472-
473-
/* Check info specific interface */
474-
if (!get_address_iface (ctx, info->ifname, address, len))
475-
return 0;
476-
477-
/* Check the global interface */
478-
if (!get_address_iface (ctx, iface, address, len))
479-
return 0;
464+
if (info->checkip_cmd && info->checkip_cmd[0]) {
465+
/* Get address from command */
466+
return get_address_cmd(ctx, info, address, len);
467+
}
468+
469+
if (info->ifname && info->ifname[0]) {
470+
/* Get address from specific interface */
471+
return get_address_iface(ctx, info->ifname, address, len);
472+
}
473+
474+
if (iface && iface[0]) {
475+
/* Get address from global interface */
476+
return get_address_iface(ctx, iface, address, len);
477+
}
480478

479+
/* Get address from remote service */
481480
if (!get_address_remote(ctx, info, address, len))
482481
return 0;
483482

0 commit comments

Comments
 (0)