From 6994b05ab61e8ce1f4c05a99368da4157288b88e Mon Sep 17 00:00:00 2001 From: PeterF Date: Thu, 11 Jan 2024 16:01:11 +0000 Subject: [PATCH] Update ddclient.in The mythicdyn module is modified so that it will update either or both V4 and/or V6 addresses depending upon which specific address parameters have been defined in the config file. The module examines the wantipv4 and wantipv6 parameters. If required, both addresses will be updated in a single invocation. --- ddclient.in | 54 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/ddclient.in b/ddclient.in index 6b70af3..0e035c7 100755 --- a/ddclient.in +++ b/ddclient.in @@ -5848,12 +5848,13 @@ www.mythic-beasts.com. Configuration variables applicable to the 'mythicdyn' protocol are: protocol=mythicdyn ## - ipv6=no|yes ## whether to set an A record (default, ipv6=no) - ## or AAAA record (ipv6=yes). login=service-login ## the user name provided by the admin interface password=service-password ## the password provided by the admin interface fully.qualified.host ## the host registered with the service +Note: this module examines the wantipv4 & wantipv6 parameters + and will set either or both V4 and/or V6 addresses as required + Note: this service automatically sets the IP address to that from which the request comes, so the IP address detected by ddclient is only used to keep track of when it needs updating. @@ -5878,33 +5879,40 @@ EoEXAMPLE sub nic_mythicdyn_update { debug("\nnic_mythicdyn_update --------------------"); - # Update each set configured host. + # Update each configured host. foreach my $h (@_) { info("%s -- Setting IP address.", $h); - my $ipversion = $config{$h}{'ipv6'} ? '6' : '4'; + foreach my $mythver ('4','6') { + my $ip = $config{$h}{"wantipv$mythver"}; - my $reply = geturl( - proxy => opt('proxy'), - url => "https://ipv$ipversion.$config{$h}{'server'}/dns/v2/dynamic/$h", - method => 'POST', - login => $config{$h}{'login'}, - password => $config{$h}{'password'}, - ipversion => $ipversion, - ); - unless ($reply) { - failed("Updating service %s failed: %s", $h, $config{$h}{'server'}); - next; - } + if (defined($ip)) { + info("Process configuration for IPV%s --------", $mythver); + my $reply = geturl( + proxy => opt('proxy'), + url => "https://ipv$mythver.$config{$h}{'server'}/dns/v2/dynamic/$h", + method => 'POST', + login => $config{$h}{'login'}, + password => $config{$h}{'password'}, + ipversion => $mythver, + ); + unless ($reply) { + failed("Updating service %s failed: %s", $h, $config{$h}{'server'}); + next; + } - my $ok = header_ok($h, $reply); - if ($ok) { - $config{$h}{'mtime'} = $now; - $config{$h}{'status'} = "good"; + my $ok = header_ok($h, $reply); + if ($ok) { + $config{$h}{'mtime'} = $now; + $config{$h}{"status-ipv$mythver"} = "good"; - success("%s -- Updated successfully.", $h); - } else { - failed("%s -- Failed to update.", $h); + success("%s -- IPV%s Updated successfully.", $h, $mythver); + } else { + failed("%s -- Failed to update.", $h); + } + } else { + info("No configuration for IPV%s -------------", $mythver); + } } } }