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