Add regfish (#471)

This commit is contained in:
gertfriend 2022-11-18 08:43:47 +01:00 committed by GitHub
parent 3dffe5372a
commit f01110aedb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 82 additions and 0 deletions

View file

@ -35,6 +35,7 @@ Dynamic DNS services currently supported include:
dnsexit - See https://dnsexit.com/ for details
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
`ddclient` now supports many cable and DSL broadband routers.

View file

@ -315,3 +315,10 @@ ssl=yes # use ssl-support. Works with
# password=mypassword
# quietreply=no|yes
# my-domain.com
##
## regfish.de (www.regfish.de/)
##
# protocol=regfishde,
# password=mypassword
# my-domain.com

View file

@ -533,6 +533,10 @@ my %variables = (
'script' => setv(T_STRING, 0, 1, '/RemoteUpdate.sv', undef),
'min-error-interval' => setv(T_DELAY, 0, 0, interval('8m'), 0),
},
'regfishde-common-defaults' => {
'server' => setv(T_FQDNP, 1, 0, 'dyndns.regfish.de', undef),
'login' => setv(T_LOGIN, 0, 0, 0, 'unused', undef),
},
);
my %services = (
'1984' => {
@ -895,6 +899,15 @@ my %services = (
$variables{'service-common-defaults'},
),
},
'regfishde' => {
'updateable' => undef,
'update' => \&nic_regfishde_update,
'examples' => \&nic_regfishde_examples,
'variables' => merge(
$variables{'regfishde-common-defaults'},
$variables{'service-common-defaults'},
),
},
);
$variables{'merged'} = {
map({ %{$services{$_}{'variables'}} } keys(%services)),
@ -7159,6 +7172,67 @@ sub nic_keysystems_update {
}
}
######################################################################
## nic_regfishde_examples
######################################################################
sub nic_regfishde_examples {
return <<EoEXAMPLE;
o 'regfishde'
The 'regfishde' protocol is used by the non-free dynamic DNS service offered by www.regfish.de.
Check https://www.regfish.de for configuration variables applicable to the 'regfishde' protocol:
protocol=regfishde
server=dyndns.regfish.de
password=service-password ## password (token) registered with the service
myhost.mydomain.com ## the host registered with the service.
Example ${program}.conf file entries:
## single host update
protocol=regfishde
password=service-password
myhost.mydomain.com
EoEXAMPLE
}
######################################################################
## nic_regfishde_update
## response contains "success" on succesfull completion
######################################################################
sub nic_regfishde_update {
debug("\nnic_regfishde_update -------------------");
## update configured host
for my $h (@_) {
my $ip = delete $config{$h}{'wantip'};
my $ipv6 = delete $config{$h}{'wantip'};
info("regfish.de setting IP address to %s for %s", $ip, $h);
my $ipv = ($ip eq ($ipv6 // '')) ? '6' : '4';
my $url = "https://$config{$h}{'server'}/?fqdn=$h&ipv$ipv=$ip&forcehost=1&token=$config{$h}{'password'}";
# Try to get URL
my $reply = geturl(proxy => opt('proxy'), url => $url);
# No response, give error
if (!defined($reply) || !$reply) {
failed("regfish.de updating %s: failed: %s.", $h, $config{$h}{'server'});
last;
}
last if !header_ok($h, $reply);
if ($reply =~ /success/)
{
$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: '$reply'", $h);
}
}
}
# Execute main() if this file is run as a script or run via PAR (https://metacpan.org/pod/PAR),
# otherwise do nothing. This "modulino" pattern makes it possible to import this file as a module