From c7fe00eb9747d5f76433c31f27d4c4bb1000fcfc Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Fri, 5 Feb 2021 07:28:25 +0000 Subject: [PATCH] Add dnsexit support --- ddclient.in | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/ddclient.in b/ddclient.in index 4ddd505..bc8291c 100755 --- a/ddclient.in +++ b/ddclient.in @@ -461,6 +461,12 @@ my %variables = ( 'static' => setv(T_BOOL, 0, 1, 0, undef), 'wildcard' => setv(T_BOOL, 0, 1, 0, undef), }, + 'dnsexit-common-defaults' => { + 'ssl' => setv(T_BOOL, 0, 1, 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), + }, ); my %services = ( 'changeip' => { @@ -758,6 +764,15 @@ my %services = ( 'zone' => setv(T_OFQDN, 0, 0, undef, undef), }, }, + 'dnsexit' => { + 'updateable' => undef, + 'update' => \&nic_dnsexit_update, + 'examples' => \&nic_dnsexit_examples, + 'variables' => merge( + $variables{'dnsexit-common-defaults'}, + $variables{'service-common-defaults'}, + ), + }, ); $variables{'merged'} = { map({ %{$services{$_}{'variables'}} } keys(%services)), @@ -4427,6 +4442,60 @@ sub nic_freedns_update { } } + + +###################################################################### +## nic_dnsexit_update +## modified copy of nic_dtns_update above +## by Dan Campbell +###################################################################### +sub nic_dnsexit_update { + debug("\nnic_dnsexit_update -------------------"); + + ## update each configured host + foreach my $h (@_) { + 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 .= "?login="; + $url .= $config{$h}{'login'}; + $url .= "&password="; + $url .= $config{$h}{'password'}; + $url .= "&host="; + $url .= $h; + + # Try to get URL + my $reply = geturl(opt('proxy'), $url); + + # No response, declare as failed + if (!defined($reply) || !$reply) { + failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'}); + last; + } + last if !header_ok($h, $reply); + + # Response found, just declare as success (this is ugly, we need more error checking) + if ($reply =~ /success/i) + { + $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); + $config{$h}{'status'} = 'failed'; + failed("updating %s: Server said: '$returned'", $h); + } + } +} + ###################################################################### ## nic_changeip_examples ###################################################################### @@ -4506,6 +4575,39 @@ sub nic_changeip_update { } } +###################################################################### +## nic_dnsexit_examples +###################################################################### +sub nic_dnsexit_examples { + return <