File d4ba5edd5118987b255888ff3573f956c661b83d.patch of Package ddclient
From d4ba5edd5118987b255888ff3573f956c661b83d Mon Sep 17 00:00:00 2001
From: Jesse Schlueter <jesse@helix360.de>
Date: Tue, 1 Aug 2023 15:04:53 +0200
Subject: [PATCH] Added support for ydns.io
---
ddclient.in | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 100 insertions(+)
diff --git a/ddclient.in b/ddclient.in
index f852c5ea..04035587 100755
--- a/ddclient.in
+++ b/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
######################################################################