From 5070bd4296cc2ada1bc250cbce4272c56b96feef Mon Sep 17 00:00:00 2001 From: xlammertink Date: Fri, 3 Jan 2020 10:17:04 +0100 Subject: [PATCH] Added OVH DynHost support --- README.md | 1 + RELEASENOTE | 1 + ddclient | 89 ++++++++++++++++++++++++++++++++++++++++ sample-etc_ddclient.conf | 9 ++++ 4 files changed, 100 insertions(+) diff --git a/README.md b/README.md index ba8e366..ab7efd1 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ Dynamic DNS services currently supported include: DNS Made Easy - See https://dnsmadeeasy.com/ for details DonDominio - See https://www.dondominio.com for details NearlyFreeSpeech.net - See https://www.nearlyfreespeech.net/services/dns for details + OVH - See https://www.ovh.com for details DDclient now supports many of cable/dsl broadband routers. diff --git a/RELEASENOTE b/RELEASENOTE index c381dab..149ef06 100644 --- a/RELEASENOTE +++ b/RELEASENOTE @@ -11,6 +11,7 @@ A detailed overview can be found in git log but here's a quick overview: * updated fritzbox instructions * fixed multidomain support for namecheap * fixed support for Yandex + * added support for OVH DynHost A very big thank you for everyone who created a pull request on github and for everyone who helped to fix the little issues caused by the new providers. diff --git a/ddclient b/ddclient index f474735..f2943f3 100755 --- a/ddclient +++ b/ddclient @@ -490,6 +490,12 @@ my %variables = ( 'dondominio-common-defaults' => { 'server' => setv(T_FQDNP, 1, 0, 1, 'dondns.dondominio.com', undef), }, + 'ovh-common-defaults' => { + 'server' => setv(T_FQDNP, 1, 0, 1, 'www.ovh.com', undef), + 'script' => setv(T_STRING, 1, 1, 1, '/nic/update', undef), + 'login' => setv(T_LOGIN, 1, 0, 1, '', undef), + 'password' => setv(T_PASSWD, 1, 0, 1, '', undef), + }, ); my %services = ( 'dyndns1' => { @@ -720,6 +726,15 @@ my %services = ( $variables{'service-common-defaults'}, ), }, + 'ovh' => { + 'updateable' => undef, + 'update' => \&nic_ovh_update, + 'examples' => \&nic_ovh_examples, + 'variables' => merge( + $variables{'ovh-common-defaults'}, + $variables{'service-common-defaults'}, + ), + }, ); $variables{'merged'} = merge($variables{'global-defaults'}, $variables{'service-common-defaults'}, @@ -5055,6 +5070,80 @@ sub nic_dnsmadeeasy_update { } } +###################################################################### +## nic_ovh_examples +###################################################################### +sub nic_ovh_examples { + return <<"EoEXAMPLE"; + +o 'ovh' + +The 'ovh' protocol is used by DNS services offered by www.ovh.com. + +API information and user instructions available at: https://docs.ovh.com/gb/en/domains/hosting_dynhost/ + +Configuration variables applicable to the 'ovh' protocol are: + protocol=ovh ## + login=dnsdomain-userid ## The username/id registered with the service + password=userid-password ## The password related to the username/id + fully.qualified.host ## the hostiname registered with the service. + +Example ${program}.conf file entries: + ## single host update + protocol=ovh, \\ + login=example.com-dynhostuser, \\ + password=your_password, \\ + test.example.com + +EoEXAMPLE +} + +###################################################################### +## nic_ovh_update +###################################################################### +sub nic_ovh_update { + debug("\nnic_ovh_update -------------------"); + + ## update each configured host + ## should improve to update in one pass + foreach my $h (@_) { + my $ip = delete $config{$h}{'wantip'}; + info("setting IP address to %s for %s", $ip, $h); + verbose("UPDATE:","updating %s", $h); + + # Set the URL that we're going to update + my $url; + $url .= "https://$config{$h}{'server'}$config{$h}{'script'}?system=dyndns"; + $url .= "&hostname=$h"; + $url .= "&myip="; + $url .= $ip if $ip; + + my $reply = geturl(opt('proxy'), $url, "$config{$h}{'login'}", "$config{$h}{'password'}"); + + if (!defined($reply) || !$reply) { + failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'}); + next; + } + + my @reply = split /\n/, $reply; + my $returned = pop(@reply); + if ($returned =~ /good/ || $returned =~ /nochg/) { + $config{$h}{'ip'} = $ip; + $config{$h}{'mtime'} = $now; + $config{$h}{'status'} = 'good'; + if ($returned =~ /good/) { + success("updating %s: good: IP address set to %s", $h, $ip); + } else { + success("updating %s: skipped: IP address was already set to %s.", $h, $ip); + } + } else { + $config{$h}{'status'} = 'failed'; + failed("updating %s: Server said: '$returned'", $h); + } + } +} + + ###################################################################### # vim: ai et ts=4 sw=4 tw=78: diff --git a/sample-etc_ddclient.conf b/sample-etc_ddclient.conf index 3381f60..27b09c0 100644 --- a/sample-etc_ddclient.conf +++ b/sample-etc_ddclient.conf @@ -279,9 +279,18 @@ ssl=yes # use ssl-support. Works with # password=yandex-pdd-token \ # my.domain.tld,other.domain.tld \ +## ## DNS Made Easy (https://dnsmadeeasy.com) ## # protocol=dnsmadeeasy, # login=your-account-email-address # password=your-generated-password # your-numeric-record-id-1,your-numeric-record-id-2,... + +## +## OVH DynHost (https://ovh.com) +## +# protocol=ovh, +# login=example.com-dynhostuser, +# password=your_password +# test.example.com