@@ -352,9 +352,6 @@ static int get_address_remote(ddns_t *ctx, ddns_info_t *info, char *address, siz
352
352
353
353
static int get_address_cmd (ddns_t * ctx , ddns_info_t * info , char * address , size_t len )
354
354
{
355
- if (!info -> checkip_cmd || !info -> checkip_cmd [0 ])
356
- return 1 ;
357
-
358
355
DO (shell_transaction (ctx , info , info -> checkip_cmd ));
359
356
logit (LOG_DEBUG , "Command response:" );
360
357
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
403
400
char * ptr , trailer [IFNAMSIZ + 2 ];
404
401
struct ifaddrs * ifaddr , * ifa ;
405
402
406
- if (!ifname || !ifname [0 ])
407
- return 1 ;
408
-
409
403
/* Trailer to strip, if set by getnameinfo() */
410
404
snprintf (trailer , sizeof (trailer ), "%%%s" , ifname );
411
405
@@ -467,17 +461,22 @@ static int get_address_backend(ddns_t *ctx, ddns_info_t *info, char *address, si
467
461
logit (LOG_DEBUG , "Get address for %s" , info -> system -> name );
468
462
memset (address , 0 , len );
469
463
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
+ }
480
478
479
+ /* Get address from remote service */
481
480
if (!get_address_remote (ctx , info , address , len ))
482
481
return 0 ;
483
482
0 commit comments