Add support for njal.la (#459)
Co-authored-by: Dimitris Paraskevopoulos <dpparaskevopoulos@gmail.com>
This commit is contained in:
parent
ca3be487f9
commit
c9754a125c
3 changed files with 126 additions and 10 deletions
|
@ -34,6 +34,7 @@ Dynamic DNS services currently supported include:
|
||||||
Gandi - See https://gandi.net
|
Gandi - See https://gandi.net
|
||||||
dnsexit - See https://dnsexit.com/ for details
|
dnsexit - See https://dnsexit.com/ for details
|
||||||
1984.is - See https://www.1984.is/product/freedns/ for details
|
1984.is - See https://www.1984.is/product/freedns/ for details
|
||||||
|
Njal.la - See https://njal.la/docs/ddns/
|
||||||
|
|
||||||
`ddclient` now supports many cable and DSL broadband routers.
|
`ddclient` now supports many cable and DSL broadband routers.
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,12 @@
|
||||||
daemon=300 # check every 300 seconds
|
daemon=300 # check every 300 seconds
|
||||||
syslog=yes # log update msgs to syslog
|
syslog=yes # log update msgs to syslog
|
||||||
mail=root # mail all msgs to root
|
mail=root # mail all msgs to root
|
||||||
mail-failure=root # mail failed update msgs to root
|
mail-failure=root # mail failed update msgs to root
|
||||||
pid=@runstatedir@/ddclient.pid # record PID in file.
|
pid=@runstatedir@/ddclient.pid # record PID in file.
|
||||||
ssl=yes # use ssl-support. Works with
|
ssl=yes # use ssl-support. Works with
|
||||||
# ssl-library
|
# ssl-library
|
||||||
# postscript=script # run script after updating. The
|
# postscript=script # run script after updating. The
|
||||||
# new IP is added as argument.
|
# new IP is added as argument.
|
||||||
#
|
#
|
||||||
#use=watchguard-soho, fw=192.168.111.1:80 # via Watchguard's SOHO FW
|
#use=watchguard-soho, fw=192.168.111.1:80 # via Watchguard's SOHO FW
|
||||||
#use=netopia-r910, fw=192.168.111.1:80 # via Netopia R910 FW
|
#use=netopia-r910, fw=192.168.111.1:80 # via Netopia R910 FW
|
||||||
|
@ -88,7 +88,6 @@ ssl=yes # use ssl-support. Works with
|
||||||
# protocol=dyndns2 \
|
# protocol=dyndns2 \
|
||||||
# your-static-host.dyndns.org
|
# your-static-host.dyndns.org
|
||||||
|
|
||||||
##
|
|
||||||
##
|
##
|
||||||
## dyndns.org custom addresses
|
## dyndns.org custom addresses
|
||||||
##
|
##
|
||||||
|
@ -154,7 +153,6 @@ ssl=yes # use ssl-support. Works with
|
||||||
# zone=example.com \
|
# zone=example.com \
|
||||||
# example.com,subdomain.example.com
|
# example.com,subdomain.example.com
|
||||||
|
|
||||||
##
|
|
||||||
##
|
##
|
||||||
## Loopia (loopia.se)
|
## Loopia (loopia.se)
|
||||||
##
|
##
|
||||||
|
@ -302,9 +300,18 @@ ssl=yes # use ssl-support. Works with
|
||||||
# password=mypassword \
|
# password=mypassword \
|
||||||
# myhost.mydomain.com
|
# myhost.mydomain.com
|
||||||
|
|
||||||
|
##
|
||||||
## dnsexit (www.dnsexit.com)
|
## dnsexit (www.dnsexit.com)
|
||||||
##
|
##
|
||||||
#protocol=dnsexit, \
|
#protocol=dnsexit, \
|
||||||
#login=myusername, \
|
#login=myusername, \
|
||||||
#password=mypassword, \
|
#password=mypassword, \
|
||||||
#subdomain-1.domain.com,subdomain-2.domain.com
|
#subdomain-1.domain.com,subdomain-2.domain.com
|
||||||
|
|
||||||
|
##
|
||||||
|
## Njal.la (http://njal.la/)
|
||||||
|
##
|
||||||
|
# protocol=njalla,
|
||||||
|
# password=mypassword
|
||||||
|
# quietreply=no|yes
|
||||||
|
# my-domain.com
|
||||||
|
|
110
ddclient.in
110
ddclient.in
|
@ -762,6 +762,17 @@ my %services = (
|
||||||
'zone' => setv(T_FQDN, 1, 0, undef, undef),
|
'zone' => setv(T_FQDN, 1, 0, undef, undef),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
'njalla' => {
|
||||||
|
'updateable' => undef,
|
||||||
|
'update' => \&nic_njalla_update,
|
||||||
|
'examples' => \&nic_njalla_examples,
|
||||||
|
'variables' => {
|
||||||
|
%{$variables{'service-common-defaults'}},
|
||||||
|
'login' => setv(T_STRING, 0, 0, 'unused', undef),
|
||||||
|
'server' => setv(T_FQDNP, 1, 0, 'njal.la', undef),
|
||||||
|
'quietreply' => setv(T_BOOL, 0, 1, 0, undef)
|
||||||
|
},
|
||||||
|
},
|
||||||
'noip' => {
|
'noip' => {
|
||||||
'updateable' => undef,
|
'updateable' => undef,
|
||||||
'update' => \&nic_noip_update,
|
'update' => \&nic_noip_update,
|
||||||
|
@ -1706,7 +1717,7 @@ sub init_config {
|
||||||
$proto = opt('protocol') if !defined($proto);
|
$proto = opt('protocol') if !defined($proto);
|
||||||
|
|
||||||
load_sha1_support($proto) if (grep (/^$proto$/, ("freedns", "nfsn")));
|
load_sha1_support($proto) if (grep (/^$proto$/, ("freedns", "nfsn")));
|
||||||
load_json_support($proto) if (grep (/^$proto$/, ("1984", "cloudflare", "gandi", "godaddy", "hetzner", "yandex", "nfsn")));
|
load_json_support($proto) if (grep (/^$proto$/, ("1984", "cloudflare", "gandi", "godaddy", "hetzner", "yandex", "nfsn", "njalla")));
|
||||||
|
|
||||||
if (!exists($services{$proto})) {
|
if (!exists($services{$proto})) {
|
||||||
warning("skipping host: %s: unrecognized protocol '%s'", $h, $proto);
|
warning("skipping host: %s: unrecognized protocol '%s'", $h, $proto);
|
||||||
|
@ -5041,6 +5052,103 @@ sub nic_nfsn_update {
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
## nic_njalla_examples
|
||||||
|
######################################################################
|
||||||
|
sub nic_njalla_examples {
|
||||||
|
return <<"EoEXAMPLE";
|
||||||
|
|
||||||
|
o 'njalla'
|
||||||
|
|
||||||
|
The 'njalla' protocol is used by DNS service offered by njal.la.
|
||||||
|
|
||||||
|
Configuration variables applicable to the 'njalla' protocol are:
|
||||||
|
protocol=njalla ##
|
||||||
|
password=service-password ## Generated password for your dynamic DNS record
|
||||||
|
quietreply=no|yes ## If yes return empty response on success with status 200 but print errors
|
||||||
|
domain ## subdomain to update, use @ for base domain name, * for catch all
|
||||||
|
|
||||||
|
Example ${program}.conf file entries:
|
||||||
|
## single host update
|
||||||
|
protocol=njalla \\
|
||||||
|
password=njal.la-key
|
||||||
|
quietreply=no
|
||||||
|
domain.com
|
||||||
|
|
||||||
|
EoEXAMPLE
|
||||||
|
}
|
||||||
|
######################################################################
|
||||||
|
## nic_njalla_update
|
||||||
|
##
|
||||||
|
## written by satrapes
|
||||||
|
##
|
||||||
|
## based on https://njal.la/docs/ddns/
|
||||||
|
## needs this url to update:
|
||||||
|
## https://njal.la/update?h=host_name&k=domain_password&a=your_ip
|
||||||
|
## response contains "code 200" on succesful completion
|
||||||
|
######################################################################
|
||||||
|
sub nic_njalla_update {
|
||||||
|
debug("\nnic_njalla_update -------------------");
|
||||||
|
|
||||||
|
foreach my $h (@_) {
|
||||||
|
# Read input params
|
||||||
|
my $ipv4 = delete $config{$h}{'wantipv4'};
|
||||||
|
my $ipv6 = delete $config{$h}{'wantipv6'};
|
||||||
|
my $quietreply = delete $config{$h}{'quietreply'};
|
||||||
|
my $ip_output = '';
|
||||||
|
|
||||||
|
# Build url
|
||||||
|
my $url = "https://$config{$h}{'server'}/update/?h=$h&k=$config{$h}{'password'}";
|
||||||
|
my $auto = 1;
|
||||||
|
foreach my $ip ($ipv4, $ipv6) {
|
||||||
|
next if (!$ip);
|
||||||
|
$auto = 0;
|
||||||
|
my $ipv = ($ip eq ($ipv6 // '')) ? '6' : '4';
|
||||||
|
my $type = ($ip eq ($ipv6 // '')) ? 'aaaa' : 'a';
|
||||||
|
$ip_output .= " IP v$ipv: $ip,";
|
||||||
|
$url .= "&$type=$ip";
|
||||||
|
}
|
||||||
|
$url .= (($auto eq 1)) ? '&auto' : '';
|
||||||
|
$url .= (($quietreply eq 1)) ? '&quiet' : '';
|
||||||
|
|
||||||
|
info("setting address to%s for %s", ($ip_output eq '') ? ' auto' : $ip_output, $h);
|
||||||
|
verbose("UPDATE:", "updating %s", $h);
|
||||||
|
debug("url: %s", $url);
|
||||||
|
|
||||||
|
# Try to get URL
|
||||||
|
my $reply = geturl(proxy => opt('proxy'), url => $url);
|
||||||
|
my $response = '';
|
||||||
|
if ($quietreply) {
|
||||||
|
$reply =~ qr/invalid host or key/mp;
|
||||||
|
$response = ${^MATCH};
|
||||||
|
if (!$response) {
|
||||||
|
success("updating %s: good: IP address set to %s", $h, $ip_output);
|
||||||
|
}
|
||||||
|
elsif ($response =~ /invalid host or key/) {
|
||||||
|
failed("Invalid host or key");
|
||||||
|
} else {
|
||||||
|
failed("Unknown response");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$reply =~ qr/{(?:[^{}]*|(?R))*}/mp;
|
||||||
|
$response = eval {decode_json(${^MATCH})};
|
||||||
|
# No response, declare as failed
|
||||||
|
if (!defined($reply) || !$reply) {
|
||||||
|
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
|
||||||
|
} else {
|
||||||
|
# Strip header
|
||||||
|
if ($response->{status} == 401 && $response->{message} =~ /invalid host or key/) {
|
||||||
|
failed("Invalid host or key");
|
||||||
|
} elsif ($response->{status} == 200 && $response->{message} =~ /record updated/) {
|
||||||
|
success("updating %s: good: IP address set to %s", $h, $response->{value}->{A});
|
||||||
|
} else {
|
||||||
|
failed("Unknown response");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
## nic_sitelutions_examples
|
## nic_sitelutions_examples
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
Loading…
Reference in a new issue