App-resolvetable
view release on metacpan or search on metacpan
lib/App/resolvetable.pm view on Meta::CPAN
}
} elsif ($action eq 'show-timings') {
$row = {
name => $name,
map {
my $server = $_;
my $starttime = $starttime{$name}{$_};
my $endtime = $endtime{$name}{$_};
my $val;
if (defined $endtime) {
my $ms = ($endtime - $starttime)*1000;
if ($ms > 4000) {
$val = ">4000ms";
} elsif ($ms <= 0.5) {
$val = "<=0.5ms";
} else {
$val = sprintf("%3.0fms", $ms);
}
} else {
$val = undef;
}
($server => $val);
} @$servers,
};
} else {
die "Unknown action '$action'";
}
if ($args{colorize}) {
_colorize_shortest_time($row);
_mark_undef_with_x($row);
}
push @rows, $row;
}
[200, "OK", \@rows, {'table.fields'=>['name', @$servers]}];
}
1;
# ABSTRACT: Produce a colored table containing DNS resolve results of several names from several servers/resolvers
__END__
=pod
=encoding UTF-8
=head1 NAME
App::resolvetable - Produce a colored table containing DNS resolve results of several names from several servers/resolvers
=head1 VERSION
This document describes version 0.008 of App::resolvetable (from Perl distribution App-resolvetable), released on 2021-07-08.
=head1 DESCRIPTION
Sample screenshot 1:
=begin html
<img src="https://st.aticpan.org/source/PERLANCAR/App-resolvetable-0.008/share/images/Screenshot_20190530_111051.png" />
=end html
Sample screenshot 2 (with C<--timings>):
=begin html
<img src="https://st.aticpan.org/source/PERLANCAR/App-resolvetable-0.008/share/images/Screenshot_20190530_112052.png" />
=end html
Sample screenshot 3 (with C<--compare>):
=begin html
<img src="https://st.aticpan.org/source/PERLANCAR/App-resolvetable-0.008/share/images/Screenshot_20190820_235000-redacted.png" />
=end html
=head1 FUNCTIONS
=head2 resolvetable
Usage:
resolvetable(%args) -> [$status_code, $reason, $payload, \%result_meta]
Produce a colored table containing DNS resolve results of several names from several serversE<sol>resolvers.
This function is not exported.
Arguments ('*' denotes required arguments):
=over 4
=item * B<action> => I<str> (default: "show-addresses")
The default action is to show resolve result (C<show-addresses>). Will highlight
the majority result with green, and minority result with red. Failed resolve
(undef) will also be highlighted with a red "X".
The C<compare-addresses> action is similar to C<show-addresses>, but will assume
the first server/resolver as the reference and compare the results of the other
servers with the first. When the result is different, it will be highlighted
with red; when the result is the same, it will be highlighted with green. Failed
resolve (undef) are highlighted with a grey X (if result is the same as
reference server) or a red X (if result is different than reference server). So
basically whenever you see a red, the results of the other servers are not
identical with the first (reference) server.
The C<show-timings> action will show resolve times instead of addresses, to
compare speed among DNS servers/resolvers. Will highlight the fastest server
with green.
=item * B<colorize> => I<bool> (default: 1)
=item * B<names>* => I<array[str]>
=item * B<servers>* => I<array[str]>
=item * B<type> => I<str> (default: "A")
Type of DNS record to query.
=back
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status code
(200 means OK, 4xx caller error, 5xx function error). Second element
($reason) is a string containing error message, or something like "OK" if status is
200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth
element (%result_meta) is called result metadata and is optional, a hash
( run in 1.607 second using v1.01-cache-2.11-cpan-df04353d9ac )