Added support for ydns.io
This commit is contained in:
parent
ef496d108f
commit
d4ba5edd51
1 changed files with 100 additions and 0 deletions
100
ddclient.in
100
ddclient.in
|
|
@ -921,6 +921,16 @@ my %services = (
|
|||
'server' => setv(T_FQDNP, 1, 0, 'pddimp.yandex.ru', undef),
|
||||
},
|
||||
},
|
||||
'ydns' => {
|
||||
'updateable' => undef,
|
||||
'update' => \&nic_ydns_update,
|
||||
'examples' => \&nic_ydns_examples,
|
||||
'variables' => {
|
||||
%{$variables{'service-common-defaults'}},
|
||||
'min-interval' => setv(T_DELAY, 0, 0, interval('5m'), 0),
|
||||
'server' => setv(T_FQDNP, 1, 0, 'ydns.io/api/v1', undef),
|
||||
},
|
||||
},
|
||||
'zoneedit1' => {
|
||||
'updateable' => undef,
|
||||
'update' => \&nic_zoneedit1_update,
|
||||
|
|
@ -6420,6 +6430,96 @@ sub nic_yandex_update {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
######################################################################
|
||||
## nic_ydns_examples
|
||||
######################################################################
|
||||
sub nic_ydns_examples {
|
||||
return <<"EoEXAMPLE";
|
||||
o YDNS
|
||||
|
||||
The 'ydns' protocol is used to by DNS services offered by https://ydns.io.
|
||||
|
||||
Configuration variables applicable to the 'ydns' protocol are:
|
||||
protocol=ydns ##
|
||||
server=fqdn.of.service ## can be omitted, defaults to ydns.io/api/v1
|
||||
login=username ## your API username
|
||||
password=secret ## your API secret
|
||||
fully.qualified.host ## the host registered with the service.
|
||||
|
||||
Example ${program}.conf file entries:
|
||||
## single host update
|
||||
protocol=ydns, \\
|
||||
login=eXample9V9ddVxyjpqN2, \\
|
||||
password=DONOTUSEQ7THYJYVPFZT5R7CYXZQCH \\
|
||||
record.myhost.com
|
||||
|
||||
## multiple host update
|
||||
protocol=ydns, \\
|
||||
login=eXample9V9ddVxyjpqN2, \\
|
||||
password=DONOTUSEQ7THYJYVPFZT5R7CYXZQCH \\
|
||||
record.myhost.com,other.myhost.com
|
||||
EoEXAMPLE
|
||||
}
|
||||
######################################################################
|
||||
## nic_ydns_update
|
||||
##
|
||||
## written by Jesse Schlueter
|
||||
##
|
||||
######################################################################
|
||||
sub nic_ydns_update {
|
||||
debug("\nnic_ydns_update ---------------------");
|
||||
|
||||
# group hosts with identical credentials together
|
||||
my %groups = group_hosts_by([ @_ ], [ qw(server login password) ]);
|
||||
|
||||
# update each set of hosts that had the same credentials
|
||||
foreach my $sig (keys %groups) {
|
||||
my @hosts = @{$groups{$sig}};
|
||||
my $key = $hosts[0];
|
||||
|
||||
# FQDNs
|
||||
for my $domain (@hosts) {
|
||||
my $ipv4 = delete $config{$domain}{'wantipv4'};
|
||||
my $ipv6 = delete $config{$domain}{'wantipv6'};
|
||||
|
||||
# Update IPv4 and IPv6 record using the same call
|
||||
foreach my $ip ($ipv4, $ipv6) {
|
||||
next if (!$ip);
|
||||
my $ipv = ($ip eq ($ipv6 // '')) ? '6' : '4';
|
||||
my $type = ($ip eq ($ipv6 // '')) ? 'AAAA' : 'A';
|
||||
|
||||
info("updating %s: setting IPv$ipv address to %s", $domain, $ip);
|
||||
$config{$domain}{"status-ipv$ipv"} = 'failed';
|
||||
|
||||
my $url = "https://$config{$key}{'server'}/update/?host=$domain&ip=$ip";
|
||||
|
||||
my $reply = geturl(
|
||||
proxy => opt('proxy'),
|
||||
url => $url,
|
||||
method => 'GET',
|
||||
login => $config{$key}{'login'},
|
||||
password => $config{$key}{'password'}
|
||||
);
|
||||
unless ($reply) {
|
||||
failed("updating %s: Could not connect to %s.", $domain, $config{$key}{'server'});
|
||||
next;
|
||||
}
|
||||
|
||||
my $ok = header_ok($domain, $reply);
|
||||
if ($ok) {
|
||||
success("updating %s: IPv$ipv address set to %s", $domain, $ip);
|
||||
$config{$domain}{"ipv$ipv"} = $ip;
|
||||
$config{$domain}{'mtime'} = $now;
|
||||
$config{$domain}{"status-ipv$ipv"} = 'good';
|
||||
} else {
|
||||
failed("updating %s: invalid reply.", $domain);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
######################################################################
|
||||
## nic_duckdns_examples
|
||||
######################################################################
|
||||
|
|
|
|||
Loading…
Reference in a new issue