diff --git a/README.md b/README.md index 4dc2042..e39292f 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Dynamic DNS services currently supported include: ClouDNS - See https://www.cloudns.net dinahosting - See https://dinahosting.com Gandi - See https://gandi.net - dnsexit - See https://dnsexit.com/ for details + dnsexit - See https://dnsexit.com/ for details DDclient now supports many of cable/dsl broadband routers. diff --git a/ddclient.in b/ddclient.in index c47b199..e71efca 100755 --- a/ddclient.in +++ b/ddclient.in @@ -462,10 +462,10 @@ my %variables = ( 'wildcard' => setv(T_BOOL, 0, 1, 0, undef), }, 'dnsexit-common-defaults' => { - 'ssl' => setv(T_BOOL, 0, 0, 0, 0, undef), - 'use' => setv(T_USE, 0, 1, 1, 'web',undef), - 'server' => setv(T_FQDNP, 0, 1, 1, 'update.dnsexit.com', undef), - 'script' => setv(T_STRING, 0, 1, 1, '/RemoteUpdate.sv', undef), + 'ssl' => setv(T_BOOL, 0, 0, 0, undef), + 'server' => setv(T_FQDNP, 1, 0, 'update.dnsexit.com', undef), + 'script' => setv(T_STRING, 0, 1, '/RemoteUpdate.sv', undef), + 'min-error-interval' => setv(T_DELAY, 0, 0, interval('8m'), 0), }, ); my %services = ( @@ -3456,26 +3456,49 @@ EoEXAMPLE } ###################################################################### ## nic_dnsexit_update +## +## written by Gonzalo Pérez de Olaguer Córdoba +## +## based on https://www.dnsexit.com/Direct.sv?cmd=ipClients +## fetches this URL to update: +## https://update.dnsexit.com/RemoteUpdate.sv?login=yourlogin&password=yourpassword& +## host=yourhost.yourdomain.com&myip=xxx.xx.xx.xxx +## ###################################################################### sub nic_dnsexit_update { debug("\nnic_dnsexit_update -------------------"); + my %status = ( + '0' => [ 'good', 'Success' ], + '1' => [ 'nochg', 'IP is the same as the IP on the system' ], + '2' => [ 'badauth', 'Invalid password' ], + '3' => [ 'badauth', 'User not found' ], + '4' => [ 'nochg', 'IP not changed. To save our system resources, please don\'t post updates unless the IP got changed.' ], + '10' => [ 'error', 'Hostname is not specified' ], + '11' => [ 'nohost', 'fail to find the domain' ], + '13' => [ 'error', 'parameter validation error' ], + ); + ## update each configured host foreach my $h (@_) { - my $ip = delete $config{$h}{'wantip'}; + my $ip = delete $config{$h}{'wantip'}; info("setting IP address to %s for %s", $ip, $h); verbose("UPDATE:","updating %s", $h); # Set the URL that we're going to update my $url; - $url = "http://$config{$h}{'server'}$config{$h}{'script'}"; + $url = "https://$config{$h}{'server'}$config{$h}{'script'}"; $url .= "?login=$config{$h}{'login'}"; $url .= "&password=$config{$h}{'password'}"; $url .= "&host=$h"; - $url .= "&myip=$ip"; + $url .= "&myip="; + $url .= $ip if $ip; # Try to get URL - my $reply = geturl(opt('proxy'), $url); + my $reply = geturl( + proxy => opt('proxy'), + url => $url + ); # No response, declare as failed if (!defined($reply) || !$reply) { @@ -3485,18 +3508,30 @@ sub nic_dnsexit_update { last if !header_ok($h, $reply); # Response found - if ($reply =~ /(\d+)=(.+)/) - { - $config{$h}{'ip'} = $ip; - $config{$h}{'mtime'} = $now; - $config{$h}{'status'} = 'good'; - success("updating %s: good: IP address set to %s", $h, $ip); - } else { - my @reply = split /\n/, $reply; - my $returned = pop(@reply); + if ($reply =~ /(\d+)=(.+)/) { + my ($statuscode, $statusmsg) = ($1, $2); + if (exists $status{$statuscode}) { + my ($status, $message) = @{ $status{$statuscode} }; + if ($status =~ m'^(good|nochg)$') { + $config{$h}{'ip'} = $ip; + $config{$h}{'mtime'} = $now; + } + $config{$h}{'status'} = $status; + if ($status eq 'good') { + success("updating %s: good: IP address set to %s", $h, $ip); + } else { + warning("updating %s: %s: %s", $h, $status, $message); + } + } else { + $config{$h}{'status'} = 'failed'; + failed("updating %s: failed: unrecognized status code (%s)", $h, $statuscode); + } + } else { $config{$h}{'status'} = 'failed'; - failed("updating %s: Server said: '$returned'", $h); - } + warning("SENT: %s", $url) unless opt('verbose'); + warning("REPLIED: %s", $reply); + failed("updating %s: unrecognized reply.", $h); + } } } ######################################################################