Add DDNS API domeneshop.no (#478)
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
This commit is contained in:
parent
1a6e4431ab
commit
3149171aa7
3 changed files with 98 additions and 0 deletions
|
@ -36,6 +36,7 @@ Dynamic DNS services currently supported include:
|
|||
1984.is - See https://www.1984.is/product/freedns/ for details
|
||||
Njal.la - See https://njal.la/docs/ddns/
|
||||
regfish.de - See https://www.regfish.de/domains/dyndns/ for details
|
||||
domenehsop - See https://api.domeneshop.no/docs/#tag/ddns/paths/~1dyndns~1update/get
|
||||
|
||||
`ddclient` now supports many cable and DSL broadband routers.
|
||||
|
||||
|
|
|
@ -308,6 +308,14 @@ ssl=yes # use ssl-support. Works with
|
|||
#password=mypassword, \
|
||||
#subdomain-1.domain.com,subdomain-2.domain.com
|
||||
|
||||
##
|
||||
## domeneshop (www.domeneshop.no)
|
||||
##
|
||||
# protocol=domeneshop
|
||||
# login=<token>
|
||||
# password=<secret>
|
||||
# subdomain-1.domain.com,subdomain-2.domain.com
|
||||
|
||||
##
|
||||
## Njal.la (http://njal.la/)
|
||||
##
|
||||
|
|
89
ddclient.in
89
ddclient.in
|
@ -630,6 +630,15 @@ my %services = (
|
|||
'host' => setv(T_NUMBER, 1, 1, 0, undef),
|
||||
},
|
||||
},
|
||||
'domeneshop' => {
|
||||
'updateable' => undef,
|
||||
'update' => \&nic_domeneshop_update,
|
||||
'examples' => \&nic_domeneshop_examples,
|
||||
'variables' => {
|
||||
%{$variables{'service-common-defaults'}},
|
||||
'server' => setv(T_FQDNP, 1, 0, 'api.domeneshop.no', undef),
|
||||
},
|
||||
},
|
||||
'duckdns' => {
|
||||
'updateable' => undef,
|
||||
'update' => \&nic_duckdns_update,
|
||||
|
@ -4467,6 +4476,86 @@ sub nic_dslreports1_update {
|
|||
}
|
||||
}
|
||||
|
||||
######################################################################
|
||||
## nic_domeneshop_examples
|
||||
######################################################################
|
||||
sub nic_domeneshop_examples {
|
||||
return <<"EoEXAMPLE";
|
||||
o 'domeneshop'
|
||||
|
||||
API is documented here: https://api.domeneshop.no/docs/
|
||||
|
||||
To generate credentials, visit https://www.domeneshop.no/admin?view=api after logging in to the control panel at
|
||||
https://www.domeneshop.no/admin?view=api
|
||||
|
||||
Configuration variables applicable to the 'domeneshop' api are:
|
||||
protocol=domeneshop ##
|
||||
login=token ## api-token
|
||||
password=secret ## api-secret
|
||||
domain.example.com ## the host registered with the service. ## the host registered with the service.
|
||||
|
||||
Example ${program}.conf file entries:
|
||||
## single host update
|
||||
protocol=domeneshop
|
||||
login=username
|
||||
password=your-password
|
||||
my.example.com
|
||||
|
||||
EoEXAMPLE
|
||||
}
|
||||
|
||||
######################################################################
|
||||
## nic_domeneshop_update
|
||||
######################################################################
|
||||
sub nic_domeneshop_update {
|
||||
debug("\nnic_domeneshop_update -------------------");
|
||||
|
||||
my $endpointPath = "/v0/dyndns/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 to update
|
||||
my $url;
|
||||
$url = $globals{'ssl'} ? "https://" : "http://";
|
||||
$url .= "$config{$h}{'server'}$endpointPath?hostname=$h&myip=$ip";
|
||||
|
||||
# Try to get URL
|
||||
my $reply = geturl(
|
||||
proxy => opt('proxy'),
|
||||
url => $url,
|
||||
login => $config{$h}{'login'},
|
||||
password => $config{$h}{'password'},
|
||||
);
|
||||
|
||||
# No response, declare as failed
|
||||
if (!defined($reply) || !$reply) {
|
||||
failed("Updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
|
||||
next;
|
||||
}
|
||||
next if !header_ok($h, $reply);
|
||||
|
||||
# evaluate response
|
||||
my @reply = split /\n/, $reply;
|
||||
my $status = shift(@reply);
|
||||
my $message = pop(@reply);
|
||||
if ($status =~ /204/) {
|
||||
$config{$h}{'ip'} = $ip;
|
||||
$config{$h}{'mtime'} = $now;
|
||||
$config{$h}{'status'} = 'good';
|
||||
success("updating %s: good: IP address set to %s", $h, $ip);
|
||||
} else {
|
||||
$config{$h}{'status'} = 'failed';
|
||||
failed("updating %s: Server said: '%s' '%s'", $h, $status, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
######################################################################
|
||||
## nic_zoneedit1_examples
|
||||
######################################################################
|
||||
|
|
Loading…
Reference in a new issue