Added simple support for Duckdns www.duckdns.org
Patch provided by gkranis on github. Merge branch 'gkranis' git-svn-id: svn+ssh://svn.code.sf.net/p/ddclient/code/trunk@178 3873ddee-7413-0410-b6c4-c2c57c1ab35a
This commit is contained in:
parent
3ec5dd56c6
commit
ddf25d3ab1
1 changed files with 91 additions and 0 deletions
91
ddclient
91
ddclient
|
@ -450,6 +450,9 @@ my %variables = (
|
||||||
},
|
},
|
||||||
'googledomains-common-defaults' => {
|
'googledomains-common-defaults' => {
|
||||||
'server' => setv(T_FQDNP, 1, 0, 1, 'domains.google.com', undef),
|
'server' => setv(T_FQDNP, 1, 0, 1, 'domains.google.com', undef),
|
||||||
|
'duckdns-common-defaults' => {
|
||||||
|
'server' => setv(T_FQDNP, 1, 0, 1, 'www.duckdns.org', undef),
|
||||||
|
'login' => setv(T_LOGIN, 0, 0, 0, 'unused', undef),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
my %services = (
|
my %services = (
|
||||||
|
@ -626,6 +629,15 @@ my %services = (
|
||||||
$variables{'service-common-defaults'},
|
$variables{'service-common-defaults'},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
'duckdns' => {
|
||||||
|
'updateable' => undef,
|
||||||
|
'update' => \&nic_duckdns_update,
|
||||||
|
'examples' => \&nic_duckdns_examples,
|
||||||
|
'variables' => merge(
|
||||||
|
$variables{'duckdns-common-defaults'},
|
||||||
|
$variables{'service-common-defaults'},
|
||||||
|
),
|
||||||
|
},
|
||||||
);
|
);
|
||||||
$variables{'merged'} = merge($variables{'global-defaults'},
|
$variables{'merged'} = merge($variables{'global-defaults'},
|
||||||
$variables{'service-common-defaults'},
|
$variables{'service-common-defaults'},
|
||||||
|
@ -4119,6 +4131,85 @@ sub nic_cloudflare_update {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
## nic_duckdns_examples
|
||||||
|
######################################################################
|
||||||
|
sub nic_duckdns_examples {
|
||||||
|
return <<EoEXAMPLE;
|
||||||
|
o 'duckdns'
|
||||||
|
|
||||||
|
The 'duckdns' protocol is used by the free
|
||||||
|
dynamic DNS service offered by www.duckdns.org.
|
||||||
|
Check http://www.duckdns.org/install.jsp?tab=linux-cron for API
|
||||||
|
|
||||||
|
Configuration variables applicable to the 'duckdns' protocol are:
|
||||||
|
protocol=duckdns ##
|
||||||
|
server=www.fqdn.of.service ## defaults to www.duckdns.org
|
||||||
|
password=service-password ## password (token) registered with the service
|
||||||
|
non-fully.qualified.host ## the host registered with the service.
|
||||||
|
|
||||||
|
Example ${program}.conf file entries:
|
||||||
|
## single host update
|
||||||
|
protocol=duckdns, \\
|
||||||
|
password=z0mgs3cjur3p4ss \\
|
||||||
|
myhost
|
||||||
|
|
||||||
|
EoEXAMPLE
|
||||||
|
}
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
## nic_duckdns_update
|
||||||
|
## by George Kranis (copypasta from nic_dtdns_update)
|
||||||
|
## http://www.duckdns.org/update?domains=mydomain1,mydomain2&token=xxxx-xxx-xx-x&ip=x.x.x.x
|
||||||
|
## response contains OK or KO
|
||||||
|
######################################################################
|
||||||
|
sub nic_duckdns_update {
|
||||||
|
debug("\nnic_duckdns_update -------------------");
|
||||||
|
|
||||||
|
## update each configured host
|
||||||
|
## should improve to update in one pass
|
||||||
|
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 to update
|
||||||
|
my $url;
|
||||||
|
$url = "http://$config{$h}{'server'}/update";
|
||||||
|
$url .= "?domains=";
|
||||||
|
$url .= $h;
|
||||||
|
$url .= "&token=";
|
||||||
|
$url .= $config{$h}{'password'};
|
||||||
|
$url .= "&ip=";
|
||||||
|
$url .= $ip;
|
||||||
|
|
||||||
|
|
||||||
|
# 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);
|
||||||
|
|
||||||
|
my @reply = split /\n/, $reply;
|
||||||
|
my $returned = pop(@reply);
|
||||||
|
if ($returned =~ /OK/)
|
||||||
|
{
|
||||||
|
$config{$h}{'ip'} = $ip;
|
||||||
|
$config{$h}{'mtime'} = $now;
|
||||||
|
$config{$h}{'status'} = 'good';
|
||||||
|
success("updating %s: good: IP address set to %s", $h, $ip);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$config{$h}{'status'} = 'failed';
|
||||||
|
failed("updating %s: Server said: '$returned'", $h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# vim: ai ts=4 sw=4 tw=78 :
|
# vim: ai ts=4 sw=4 tw=78 :
|
||||||
|
|
Loading…
Reference in a new issue