diff --git a/ChangeLog.md b/ChangeLog.md index 579f686..bcec842 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -16,6 +16,11 @@ repository history](https://github.com/ddclient/ddclient/commits/main). special characters are preserved literally. [#766](https://github.com/ddclient/ddclient/pull/766) +### New features + + * `myaddr`: New `protocol` option for updating [myaddr](https://myaddr.tools/) + records. [#785](https://github.com/ddclient/ddclient/pull/785) + ## 2025-01-07 v4.0.0-rc.2 ### Breaking changes diff --git a/README.md b/README.md index 7eef76e..40e0303 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ Dynamic DNS services currently supported include: * [Infomaniak](https://faq.infomaniak.com/2376) * [INWX](https://www.inwx.com/) * [Loopia](https://www.loopia.se) + * [Myaddr](https://myaddr.tools) * [Mythic Beasts](https://www.mythic-beasts.com/support/api/dnsv2/dynamic-dns) * [NameCheap](https://www.namecheap.com) * [NearlyFreeSpeech.net](https://www.nearlyfreespeech.net/services/dns) diff --git a/ddclient.conf.in b/ddclient.conf.in index 878cab3..8d61313 100644 --- a/ddclient.conf.in +++ b/ddclient.conf.in @@ -231,6 +231,13 @@ pid=@runstatedir@/ddclient.pid # record PID in file. # password=my-token # myhost.example.com +## +## Myaddr (myaddr.tools) +## +# protocol=myaddr +# password=private-key +# myname.myaddr.tools + ## ## MyOnlinePortal (http://myonlineportal.net) ## diff --git a/ddclient.in b/ddclient.in index c91d100..fc55a21 100755 --- a/ddclient.in +++ b/ddclient.in @@ -1143,6 +1143,15 @@ our %protocols = ( 'script' => setv(T_STRING, 0, '/nic/update', undef), }, ), + 'myaddr' => ddclient::Protocol->new( + 'update' => \&nic_myaddr_update, + 'examples' => \&nic_myaddr_examples, + 'cfgvars' => { + %{$cfgvars{'protocol-common-defaults'}}, + 'login' => undef, + 'server' => setv(T_FQDNP, 0, 'myaddr.tools', undef), + }, + ), 'mythicdyn' => ddclient::Protocol->new( 'update' => \&nic_mythicdyn_update, 'examples' => \&nic_mythicdyn_examples, @@ -5626,6 +5635,61 @@ sub nic_henet_update { } } +###################################################################### +## nic_myaddr_examples +###################################################################### +sub nic_myaddr_examples { + my $self = shift; + return <<"EoEXAMPLE"; +o 'myaddr' + +The 'myaddr' protocol is used by the DNS service offered by myaddr.tools. + +Configuration variables applicable to the 'myaddr' protocol are: + protocol=myaddr + password=private-key ## the private key corresponding to the domain to + ## update + myname.myaddr.tools ## a name (not used by the service; the above key + ## uniquely identifies the domain to update) + +Example ${program}.conf file entries: + protocol=myaddr, \\ + password=6bcf18a592bbc85bcee439e1e42def483ff3ef632a84df7ece5ff072f72887c1, \\ + example.myaddr.tools + +EoEXAMPLE +} + +###################################################################### +## nic_myaddr_update +###################################################################### +sub nic_myaddr_update { + my $self = shift; + for my $group (group_hosts_by(\@_, qw(password server wantipv4 wantipv6))) { + local $_l = pushlogctx(join(',', @{$group->{hosts}})); + my $key = $group->{cfg}{password}; + my $server = $group->{cfg}{server}; + for my $v (4, 6) { + delete $config{$_}{"wantipv$v"} for @{$group->{hosts}}; + my $ip = $group->{cfg}{"wantipv$v"}; + next if !$ip; + info("setting IPv$v address to $ip"); + my $reply = geturl( + proxy => opt('proxy'), + url => "https://$server/update?key=$key&ip=$ip", + ); + next if !header_ok($reply); + # a 200 response indicates success + for my $h (@{$group->{hosts}}) { + $recap{$h}{mtime} = $now; + $recap{$h}{"ipv$v"} = $ip; + $recap{$h}{"status-ipv$v"} = 'good'; + } + success("IPv$v address set to $ip"); + } + } +} + ###################################################################### ## nic_mythicdyn_examples ##