easydns: Simplify response processing

This commit is contained in:
Richard Hansen 2024-07-20 00:07:20 -04:00
parent 7a2625b7a7
commit 6992a34028

View file

@ -4827,16 +4827,11 @@ sub nic_easydns_update {
next;
}
next if !header_ok($h, $reply);
my @reply = split /\n/, $reply;
my $state = 'header';
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) = $line =~ /^(\S*)\b.*/;
(my $body = $reply) =~ s/^.*?\n\n//s or do {
failed("$h: Could not connect to $config{$h}{'server'}");
next;
};
my ($status) = $body =~ qr/^(\S*)\b/;
$config{$h}{'status-ipv4'} = $status if $ipv4;
$config{$h}{'status-ipv6'} = $status if $ipv6;
if ($status eq 'NOERROR') {
@ -4857,12 +4852,8 @@ sub nic_easydns_update {
} elsif (exists $errors{$status}) {
failed("$h: $status: $errors{$status}");
} else {
failed("$h: unexpected result: $line");
failed("$h: unexpected result: $body");
}
last;
}
}
failed("$h: Could not connect to $config{$h}{'server'}") if $state ne 'results2';
}
}