From 2f4b0859bd7a30ad9905fe67a92c3f23ffa995a8 Mon Sep 17 00:00:00 2001 From: woolflare <167610549+woolflare@users.noreply.github.com> Date: Sat, 6 Jul 2024 04:19:23 +0800 Subject: [PATCH] Add DDNS.FM support --- ChangeLog.md | 2 ++ README.md | 1 + ddclient.conf.in | 8 ++++++ ddclient.in | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index ec8bc1a..19633f3 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -68,6 +68,8 @@ repository history](https://github.com/ddclient/ddclient/commits/master). option can now include `http://` or `https://` to control the use of TLS. If omitted, the value of the `ssl` option is used to determine the scheme. [#703](https://github.com/ddclient/ddclient/pull/703) + * `ddns.fm`: New `protocol` option for updating [DDNS.FM](https://ddns.fm/) + records. [#695](https://github.com/ddclient/ddclient/pull/695) ### Bug fixes diff --git a/README.md b/README.md index 2c989aa..5b3275a 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Dynamic DNS services currently supported include: * [ChangeIP](https://www.changeip.com) * [CloudFlare](https://www.cloudflare.com) * [ClouDNS](https://www.cloudns.net) +* [DDNS.fm](https://www.ddns.fm/) * [DigitalOcean](https://www.digitalocean.com/) * [dinahosting](https://dinahosting.com) * [DonDominio](https://www.dondominio.com) diff --git a/ddclient.conf.in b/ddclient.conf.in index 19df639..8a336ac 100644 --- a/ddclient.conf.in +++ b/ddclient.conf.in @@ -248,6 +248,14 @@ pid=@runstatedir@/ddclient.pid # record PID in file. # password=my-token # myhost +## +## DDNS.FM (https://ddns.fm/) +## +# +# protocol=ddns.fm, +# password=my-token +# myhost.example.com + ## ## MyOnlinePortal (http://myonlineportal.net) ## diff --git a/ddclient.in b/ddclient.in index 2080379..409bd3b 100755 --- a/ddclient.in +++ b/ddclient.in @@ -762,6 +762,16 @@ our %protocols = ( 'dynurl' => setv(T_STRING, 1, 0, undef, undef), }, }, + 'ddns.fm' => { + 'force_update' => undef, + 'update' => \&nic_ddnsfm_update, + 'examples' => \&nic_ddnsfm_examples, + 'variables' => { + %{$variables{'protocol-common-defaults'}}, + 'login' => undef, + 'server' => setv(T_FQDNP, 0, 0, 'https://api.ddns.fm', undef), + }, + }, 'digitalocean' => { 'force_update' => undef, 'update' => \&nic_digitalocean_update, @@ -6730,6 +6740,62 @@ sub nic_freemyip_update { } } +###################################################################### +## nic_ddnsfm_examples +###################################################################### +sub nic_ddnsfm_examples { + return <<"EoEXAMPLE"; +o 'ddns.fm' + +The 'ddns.fm' protocol is used by the free +dynamic DNS service available at ddns.fm. +API is documented here: https://ddns.fm/docs + +Configuration variables applicable to the 'ddns.fm' protocol are: + protocol=ddns.fm ## + password=service-key ## key for your domain + non-fully.qualified.host ## the host registered with the service. + +Example ${program}.conf file entries: + ## single host update + protocol=ddns.fm, \\ + password=your_ddns_key, \\ + myhost.example.com + +EoEXAMPLE +} + +###################################################################### +## nic_ddnsfm_update +###################################################################### +sub nic_ddnsfm_update { + debug("\nnic_ddnsfm_update -------------------"); + for my $h (@_) { + # ddns.fm behavior as of 2024-07-14: + # - IPv4 and IPv6 addresses cannot be updated simultaneously. + # - IPv4 updates do not affect the IPv6 AAAA record (if present). + # - IPv6 updates do not affect the IPv4 A record (if present). + for my $ipv ('4', '6') { + my $ip = delete $config{$h}{"wantipv$ipv"} or next; + info("setting IPv$ipv address to $ip for $h"); + verbose("UPDATE:", "updating %s", $h); + my $reply = geturl( + proxy => opt('proxy'), + url => "$config{$h}{server}/update?key=$config{$h}{password}&domain=$h&myip=$ip", + ); + if (!$reply) { + failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'}); + next; + } + next if !header_ok($h, $reply); + $config{$h}{"ipv$ipv"} = $ip; + $config{$h}{'mtime'} = $now; + $config{$h}{"status-ipv$ipv"} = 'good'; + success("updating $h: good: IPv$ipv address set to $ip"); + } + } +} + ###################################################################### ## nic_woima_examples ######################################################################