From ecf935a4e2f022f3175b9329b165f4cd39631852 Mon Sep 17 00:00:00 2001 From: Indrajit Raychaudhuri Date: Mon, 3 Jun 2024 02:07:50 -0500 Subject: [PATCH] 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 --- ChangeLog.md | 4 ++- README.md | 1 + ddclient.conf.in | 7 ++++ ddclient.in | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 100 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index b6e7622..37cf416 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -47,6 +47,8 @@ repository history](https://github.com/ddclient/ddclient/commits/master). [#676](https://github.com/ddclient/ddclient/pull/676) * `emailonly`: New `protocol` option that simply emails you when your IP 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 @@ -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 njal.la - + ## 2022-05-15 v3.10.0_2 ### Bug fixes diff --git a/README.md b/README.md index c55db17..9309fce 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ Dynamic DNS services currently supported include: * [Gandi](https://gandi.net) * [GoDaddy](https://www.godaddy.com) * [Google](https://domains.google) +* [Hurricane Electric](https://dns.he.net) * [Infomaniak](https://faq.infomaniak.com/2376) * [Loopia](https://www.loopia.se) * [Mythic Beasts](https://www.mythic-beasts.com/support/api/dnsv2/dynamic-dns) diff --git a/ddclient.conf.in b/ddclient.conf.in index e916958..12d8dcb 100644 --- a/ddclient.conf.in +++ b/ddclient.conf.in @@ -222,6 +222,13 @@ ssl=yes # use ssl-support. Works with # password=my-auto-generated-password # 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/) ## diff --git a/ddclient.in b/ddclient.in index b8428e1..8de28e4 100755 --- a/ddclient.in +++ b/ddclient.in @@ -915,6 +915,17 @@ our %protocols = ( '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' => { 'force_update' => undef, '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 ##