he.net: Add support for Hurricane Electric provider

The implementation is based on the existing
dyndns2 protocol with a few differences:
- The IPv4 and IPv6 addresses must be updated in
  separate calls. This is different from most of
  the other providers where both IPv4 and IPv6
  addresses can be updated in a single call. Thus
  the existing dyndns2 protocol implementation
  cannot be reused for dns.he.net.
- Multiple hosts are not supported by the provider.

See: https://dns.he.net/docs.html
This commit is contained in:
Indrajit Raychaudhuri 2024-06-03 02:07:50 -05:00 committed by Richard Hansen
parent 9eff7404e3
commit ecf935a4e2
4 changed files with 100 additions and 1 deletions

View file

@ -47,6 +47,8 @@ repository history](https://github.com/ddclient/ddclient/commits/master).
[#676](https://github.com/ddclient/ddclient/pull/676) [#676](https://github.com/ddclient/ddclient/pull/676)
* `emailonly`: New `protocol` option that simply emails you when your IP * `emailonly`: New `protocol` option that simply emails you when your IP
address changes. [#654](https://github.com/ddclient/ddclient/pull/654) address changes. [#654](https://github.com/ddclient/ddclient/pull/654)
* `he.net`: Added support for updating Hurricane Electric records.
[#682](https://github.com/ddclient/ddclient/pull/682)
### Bug fixes ### Bug fixes
@ -150,7 +152,7 @@ Refer to [v3.11 release plan discussions](https://github.com/ddclient/ddclient/i
* Added support for domaindiscount24.com * Added support for domaindiscount24.com
* Added support for njal.la * Added support for njal.la
## 2022-05-15 v3.10.0_2 ## 2022-05-15 v3.10.0_2
### Bug fixes ### Bug fixes

View file

@ -33,6 +33,7 @@ Dynamic DNS services currently supported include:
* [Gandi](https://gandi.net) * [Gandi](https://gandi.net)
* [GoDaddy](https://www.godaddy.com) * [GoDaddy](https://www.godaddy.com)
* [Google](https://domains.google) * [Google](https://domains.google)
* [Hurricane Electric](https://dns.he.net)
* [Infomaniak](https://faq.infomaniak.com/2376) * [Infomaniak](https://faq.infomaniak.com/2376)
* [Loopia](https://www.loopia.se) * [Loopia](https://www.loopia.se)
* [Mythic Beasts](https://www.mythic-beasts.com/support/api/dnsv2/dynamic-dns) * [Mythic Beasts](https://www.mythic-beasts.com/support/api/dnsv2/dynamic-dns)

View file

@ -222,6 +222,13 @@ ssl=yes # use ssl-support. Works with
# password=my-auto-generated-password # password=my-auto-generated-password
# my.domain.tld, otherhost.domain.tld # my.domain.tld, otherhost.domain.tld
##
## Hurricane Electric (dns.he.net)
##
# protocol=he.net, \
# password=my-genereated-password \
# myhost.example.com
## ##
## Duckdns (http://www.duckdns.org/) ## Duckdns (http://www.duckdns.org/)
## ##

View file

@ -915,6 +915,17 @@ our %protocols = (
'server' => setv(T_FQDNP, 0, 0, 'domains.google.com', undef), 'server' => setv(T_FQDNP, 0, 0, 'domains.google.com', undef),
}, },
}, },
'he.net' => {
'updateable' => undef,
'update' => \&nic_henet_update,
'examples' => \&nic_henet_examples,
'variables' => {
%{$variables{'protocol-common-defaults'}},
'login' => undef,
'min-interval' => setv(T_DELAY, 0, 0, interval('5m'), 0),
'server' => setv(T_FQDNP, 0, 0, 'dyn.dns.he.net', undef),
},
},
'hetzner' => { 'hetzner' => {
'force_update' => undef, 'force_update' => undef,
'update' => \&nic_hetzner_update, 'update' => \&nic_hetzner_update,
@ -5862,6 +5873,84 @@ sub nic_googledomains_update {
} }
} }
######################################################################
## nic_henet_examples
##
## written by Indrajit Raychaudhuri
##
######################################################################
sub nic_henet_examples {
return <<"EoEXAMPLE";
o 'he.net'
The 'he.net' protocol is used by DNS service offered by dns.he.net.
Configuration variables applicable to the 'he.net' protocol are:
protocol=he.net ##
password=service-password ## the password provided by the admin interface
fully.qualified.host ## the host registered with the service.
Example ${program}.conf file entries:
## single host update
protocol=he.net, \\
password=my-genereated-password \\
myhost.example.com
EoEXAMPLE
}
######################################################################
## nic_henet_update
######################################################################
sub nic_henet_update {
debug("\nnic_henet_update -------------------");
my %errors = (
'badauth' => 'Bad authorization (username or password)',
'badsys' => 'The system parameter given was not valid',
'nohost' => 'The hostname specified does not exist in the database',
'abuse' => 'The hostname specified is blocked for abuse',
'nochg' => 'No update required; unnecessary attempts to change to the current address are considered abusive',
);
for my $h (@_) {
# The IPv4 and IPv6 addresses must be updated in separate API call.
for my $ipv ('4', '6') {
my $ip = delete($config{$h}{"wantipv$ipv"}) or next;
info("Setting IPv%s address to %s for %s", $ipv, $ip, $h);
verbose("UPDATE:", "updating %s", $h);
my $reply = geturl(
proxy => opt('proxy'),
url => "https://$config{$h}{'server'}/nic/update?hostname=$h&myip=$ip",
login => $h,
password => $config{$h}{'password'},
) // '';
if ($reply eq '') {
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
next;
}
next if !header_ok($h, $reply);
# dyn.dns.he.net can return 200 OK even if there is an error (e.g., bad authentication,
# updates too frequent) so the body of the response must also be checked.
(my $body = $reply) =~ s/^.*?\n\n//s;
my ($line) = split(/\n/, $body, 2);
my ($status, $returnedip) = split(/ /, lc($line));
$status = 'good' if $status eq 'nochg';
$config{$h}{"status-ipv$ipv"} = $status;
if ($status ne 'good') {
if (exists($errors{$status})) {
failed("updating %s: %s: %s", $h, $status, $errors{$status});
} else {
failed("updating %s: unexpected status: %s", $h, $line);
}
next;
}
success("updating %s: %s: IPv%s address set to %s", $h, $status, $ipv, $returnedip);
$config{$h}{"ipv$ipv"} = $returnedip;
$config{$h}{'mtime'} = $now;
}
}
}
###################################################################### ######################################################################
## nic_mythicdyn_examples ## nic_mythicdyn_examples
## ##