dyndns2: Simplify response parsing
This commit is contained in:
parent
60f931e7da
commit
45e3603918
1 changed files with 49 additions and 54 deletions
21
ddclient.in
21
ddclient.in
|
@ -4073,15 +4073,14 @@ sub nic_dyndns2_update {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
next if !header_ok($hosts, $reply);
|
next if !header_ok($hosts, $reply);
|
||||||
my @reply = split /\n/, $reply;
|
# Some services can return 200 OK even if there is an error (e.g., bad authentication,
|
||||||
my $state = 'header';
|
# updates too frequent) so the body of the response must also be checked.
|
||||||
for my $line (@reply) {
|
(my $body = $reply) =~ s/^.*?\n\n//s;
|
||||||
if ($state eq 'header') {
|
my ($line) = grep(qr/^results/, split(qr/\n/, $body));
|
||||||
$state = 'body';
|
if (!$line) {
|
||||||
} elsif ($state eq 'body') {
|
failed("updating %s: Could not connect to %s.", $hosts, $groupcfg{'server'});
|
||||||
$state = 'results' if $line eq '';
|
next;
|
||||||
} elsif ($state =~ /^results/) {
|
}
|
||||||
$state = 'results2';
|
|
||||||
# bug #10: some dyndns providers does not return the IP so
|
# bug #10: some dyndns providers does not return the IP so
|
||||||
# we can't use the returned IP
|
# we can't use the returned IP
|
||||||
my ($status, $returnedips) = split / /, lc $line;
|
my ($status, $returnedips) = split / /, lc $line;
|
||||||
|
@ -4125,10 +4124,6 @@ sub nic_dyndns2_update {
|
||||||
failed("updating %s: unexpected status (%s)", $hosts, $line);
|
failed("updating %s: unexpected status (%s)", $hosts, $line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
failed("updating %s: Could not connect to %s.", $hosts, $groupcfg{'server'})
|
|
||||||
if $state ne 'results2';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
Loading…
Reference in a new issue