From 2017e71ea8f98eb0c6fb0f576bd80c5864389c9a Mon Sep 17 00:00:00 2001 From: Nelson Araujo Date: Sun, 8 Sep 2024 20:00:10 -0700 Subject: [PATCH] Add support to ionos.com --- Makefile.am | 1 + ddclient.in | 73 +++++++++++++++++++++++++++++++++++++++++++++ t/protocol_ionos.pl | 39 ++++++++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 t/protocol_ionos.pl diff --git a/Makefile.am b/Makefile.am index 13367ad6..4d869125 100644 --- a/Makefile.am +++ b/Makefile.am @@ -78,6 +78,7 @@ handwritten_tests = \ t/protocol_directnic.pl \ t/protocol_dnsexit2.pl \ t/protocol_dyndns2.pl \ + t/protocol_ionos.pl \ t/read_recap.pl \ t/skip.pl \ t/ssl-validate.pl \ diff --git a/ddclient.in b/ddclient.in index ba4b463b..4cdc6a63 100755 --- a/ddclient.in +++ b/ddclient.in @@ -1294,6 +1294,15 @@ our %protocols = ( 'max-interval' => setv(T_DELAY, 0, 'inf', 0), }, ), + 'ionos' => ddclient::Protocol->new( + 'update' => \&nic_ionos_update, + 'examples' => \&nic_ionos_examples, + 'cfgvars' => { + %{$cfgvars{'protocol-common-defaults'}}, + 'server' => setv(T_FQDNP, 0, 'ipv4.api.hosting.ionos.com', undef), + 'login' => undef, + }, + ), ); $cfgvars{'merged'} = { map({ %{$protocols{$_}{'cfgvars'}} } keys(%protocols)), @@ -7641,6 +7650,70 @@ Example ${program}.conf file entries: EoEXAMPLE } +###################################################################### +## nic_ionos_examples +###################################################################### +sub nic_ionos_examples { + my $self = shift; + return < $@); + ddclient::t::HTTPD->import(); +} + +httpd()->run(sub { + my ($req) = @_; + diag('=============================================================================='); + diag("Test server received request:\n" . $req->as_string()); + return undef if $req->uri()->path() eq '/control'; + return [401, [@$textplain, 'www-authenticate' => 'Basic realm="realm", charset="UTF-8"'], + ['authentication required']] if ($req->header('authorization') // '') ne $wantauthn; + return [400, $textplain, ['invalid method: ' . $req->method()]] if $req->method() ne 'GET'; + return undef; +}); + +local %ddclient::config = ( + 'host.my.example.com' => { + 'protocol' => 'ionos', + 'password' => 'mytestingpassword', + 'server' => httpd()->endpoint(), + 'wantip' => '1.2.3.4', +}); + +ddclient::nic_ionos_update(undef, 'host.my.example.com'); + +my @requests = httpd()->reset(); +is(scalar(@requests), 1, "$tc->{desc}: single update request"); + +my $req = shift(@requests); +is($req->uri()->path(), '/dns/v1/dyndns', "$tc->{desc}: request path"); +is($req->uri()->query(), 'q=mytestingpassword', "$tc->{desc}: request query"); + +done_testing();