dnsexit: check for valid responses that mean 'failure' (from @truesalo)
This commit is contained in:
parent
92deb08d41
commit
535438f46e
2 changed files with 55 additions and 20 deletions
|
|
@ -32,7 +32,7 @@ Dynamic DNS services currently supported include:
|
||||||
ClouDNS - See https://www.cloudns.net
|
ClouDNS - See https://www.cloudns.net
|
||||||
dinahosting - See https://dinahosting.com
|
dinahosting - See https://dinahosting.com
|
||||||
Gandi - See https://gandi.net
|
Gandi - See https://gandi.net
|
||||||
dnsexit - See https://dnsexit.com/ for details
|
dnsexit - See https://dnsexit.com/ for details
|
||||||
|
|
||||||
DDclient now supports many of cable/dsl broadband routers.
|
DDclient now supports many of cable/dsl broadband routers.
|
||||||
|
|
||||||
|
|
|
||||||
73
ddclient.in
73
ddclient.in
|
|
@ -462,10 +462,10 @@ my %variables = (
|
||||||
'wildcard' => setv(T_BOOL, 0, 1, 0, undef),
|
'wildcard' => setv(T_BOOL, 0, 1, 0, undef),
|
||||||
},
|
},
|
||||||
'dnsexit-common-defaults' => {
|
'dnsexit-common-defaults' => {
|
||||||
'ssl' => setv(T_BOOL, 0, 0, 0, 0, undef),
|
'ssl' => setv(T_BOOL, 0, 0, 0, undef),
|
||||||
'use' => setv(T_USE, 0, 1, 1, 'web',undef),
|
'server' => setv(T_FQDNP, 1, 0, 'update.dnsexit.com', undef),
|
||||||
'server' => setv(T_FQDNP, 0, 1, 1, 'update.dnsexit.com', undef),
|
'script' => setv(T_STRING, 0, 1, '/RemoteUpdate.sv', undef),
|
||||||
'script' => setv(T_STRING, 0, 1, 1, '/RemoteUpdate.sv', undef),
|
'min-error-interval' => setv(T_DELAY, 0, 0, interval('8m'), 0),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
my %services = (
|
my %services = (
|
||||||
|
|
@ -3456,26 +3456,49 @@ EoEXAMPLE
|
||||||
}
|
}
|
||||||
######################################################################
|
######################################################################
|
||||||
## nic_dnsexit_update
|
## nic_dnsexit_update
|
||||||
|
##
|
||||||
|
## written by Gonzalo Pérez de Olaguer Córdoba <salo@gpoc.es>
|
||||||
|
##
|
||||||
|
## based on https://www.dnsexit.com/Direct.sv?cmd=ipClients
|
||||||
|
## fetches this URL to update:
|
||||||
|
## https://update.dnsexit.com/RemoteUpdate.sv?login=yourlogin&password=yourpassword&
|
||||||
|
## host=yourhost.yourdomain.com&myip=xxx.xx.xx.xxx
|
||||||
|
##
|
||||||
######################################################################
|
######################################################################
|
||||||
sub nic_dnsexit_update {
|
sub nic_dnsexit_update {
|
||||||
debug("\nnic_dnsexit_update -------------------");
|
debug("\nnic_dnsexit_update -------------------");
|
||||||
|
|
||||||
|
my %status = (
|
||||||
|
'0' => [ 'good', 'Success' ],
|
||||||
|
'1' => [ 'nochg', 'IP is the same as the IP on the system' ],
|
||||||
|
'2' => [ 'badauth', 'Invalid password' ],
|
||||||
|
'3' => [ 'badauth', 'User not found' ],
|
||||||
|
'4' => [ 'nochg', 'IP not changed. To save our system resources, please don\'t post updates unless the IP got changed.' ],
|
||||||
|
'10' => [ 'error', 'Hostname is not specified' ],
|
||||||
|
'11' => [ 'nohost', 'fail to find the domain' ],
|
||||||
|
'13' => [ 'error', 'parameter validation error' ],
|
||||||
|
);
|
||||||
|
|
||||||
## update each configured host
|
## update each configured host
|
||||||
foreach my $h (@_) {
|
foreach my $h (@_) {
|
||||||
my $ip = delete $config{$h}{'wantip'};
|
my $ip = delete $config{$h}{'wantip'};
|
||||||
info("setting IP address to %s for %s", $ip, $h);
|
info("setting IP address to %s for %s", $ip, $h);
|
||||||
verbose("UPDATE:","updating %s", $h);
|
verbose("UPDATE:","updating %s", $h);
|
||||||
|
|
||||||
# Set the URL that we're going to update
|
# Set the URL that we're going to update
|
||||||
my $url;
|
my $url;
|
||||||
$url = "http://$config{$h}{'server'}$config{$h}{'script'}";
|
$url = "https://$config{$h}{'server'}$config{$h}{'script'}";
|
||||||
$url .= "?login=$config{$h}{'login'}";
|
$url .= "?login=$config{$h}{'login'}";
|
||||||
$url .= "&password=$config{$h}{'password'}";
|
$url .= "&password=$config{$h}{'password'}";
|
||||||
$url .= "&host=$h";
|
$url .= "&host=$h";
|
||||||
$url .= "&myip=$ip";
|
$url .= "&myip=";
|
||||||
|
$url .= $ip if $ip;
|
||||||
|
|
||||||
# Try to get URL
|
# Try to get URL
|
||||||
my $reply = geturl(opt('proxy'), $url);
|
my $reply = geturl(
|
||||||
|
proxy => opt('proxy'),
|
||||||
|
url => $url
|
||||||
|
);
|
||||||
|
|
||||||
# No response, declare as failed
|
# No response, declare as failed
|
||||||
if (!defined($reply) || !$reply) {
|
if (!defined($reply) || !$reply) {
|
||||||
|
|
@ -3485,18 +3508,30 @@ sub nic_dnsexit_update {
|
||||||
last if !header_ok($h, $reply);
|
last if !header_ok($h, $reply);
|
||||||
|
|
||||||
# Response found
|
# Response found
|
||||||
if ($reply =~ /(\d+)=(.+)/)
|
if ($reply =~ /(\d+)=(.+)/) {
|
||||||
{
|
my ($statuscode, $statusmsg) = ($1, $2);
|
||||||
$config{$h}{'ip'} = $ip;
|
if (exists $status{$statuscode}) {
|
||||||
$config{$h}{'mtime'} = $now;
|
my ($status, $message) = @{ $status{$statuscode} };
|
||||||
$config{$h}{'status'} = 'good';
|
if ($status =~ m'^(good|nochg)$') {
|
||||||
success("updating %s: good: IP address set to %s", $h, $ip);
|
$config{$h}{'ip'} = $ip;
|
||||||
} else {
|
$config{$h}{'mtime'} = $now;
|
||||||
my @reply = split /\n/, $reply;
|
}
|
||||||
my $returned = pop(@reply);
|
$config{$h}{'status'} = $status;
|
||||||
|
if ($status eq 'good') {
|
||||||
|
success("updating %s: good: IP address set to %s", $h, $ip);
|
||||||
|
} else {
|
||||||
|
warning("updating %s: %s: %s", $h, $status, $message);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$config{$h}{'status'} = 'failed';
|
||||||
|
failed("updating %s: failed: unrecognized status code (%s)", $h, $statuscode);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$config{$h}{'status'} = 'failed';
|
$config{$h}{'status'} = 'failed';
|
||||||
failed("updating %s: Server said: '$returned'", $h);
|
warning("SENT: %s", $url) unless opt('verbose');
|
||||||
}
|
warning("REPLIED: %s", $reply);
|
||||||
|
failed("updating %s: unrecognized reply.", $h);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue