noip: Simplify response processing

This commit is contained in:
Richard Hansen 2024-07-24 21:20:33 -04:00
parent 5b433c3cd5
commit c0b28f344f

View file

@ -4123,19 +4123,12 @@ sub nic_noip_update {
password => $groupcfg{'password'},
);
next if !header_ok($hosts, $reply);
my @reply = split /\n/, $reply;
my $state = 'header';
(my $body = $reply) =~ s/^.*?\n\n//s or do {
failed("updating %s: Could not connect to %s.", $hosts, $groupcfg{'server'});
next;
};
my @reply = split(/\n/, $body);
for my $line (@reply) {
if ($state eq 'header') {
$state = 'body';
} elsif ($state eq 'body') {
$state = 'results' if $line eq '';
} elsif ($state =~ /^results/) {
$state = 'results2';
my ($status, $returnedips) = split / /, lc $line;
my $h = shift @hosts;
@ -4185,9 +4178,6 @@ sub nic_noip_update {
}
}
}
failed("updating %s: Could not connect to %s.", $hosts, $groupcfg{'server'})
if $state ne 'results2';
}
}
######################################################################