now resolves PTR records
This commit is contained in:
parent
50e5ead7b6
commit
69fc6df937
|
@ -1,4 +1,9 @@
|
|||
Revision history for Parse-Netstat-Colorizer
|
||||
|
||||
0.1.0 2019-02-28/?
|
||||
-Add inversion support to cnetstat.
|
||||
-Add PTR and regexp PTR support to cnetstat.
|
||||
-Add PTR resolving options.
|
||||
|
||||
0.0.0 2019-02-28/04:30
|
||||
-Initial release.
|
||||
|
|
|
@ -26,6 +26,7 @@ WriteMakefile(
|
|||
'Term::ANSIColor'=>'0.0.0',
|
||||
'Text::Table'=>'0.0.0',
|
||||
'Getopt::Long'=>'0.0.0',
|
||||
'Net::IP'=>'0.0.0',
|
||||
},
|
||||
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
|
||||
clean => { FILES => 'Parse-Netstat-Colorizer-*' },
|
||||
|
|
|
@ -9,6 +9,7 @@ use Parse::Netstat::Search;
|
|||
use Parse::Netstat::Search::Sort;
|
||||
use Term::ANSIColor;
|
||||
use Text::Table;
|
||||
use Net::IP;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
@ -16,11 +17,11 @@ Parse::Netstat::Colorizer - Searches and colorizes the output from Parse::Netsta
|
|||
|
||||
=head1 VERSION
|
||||
|
||||
Version 0.0.0
|
||||
Version 0.1.0
|
||||
|
||||
=cut
|
||||
|
||||
our $VERSION = '0.0.0';
|
||||
our $VERSION = '0.1.0';
|
||||
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
@ -75,6 +76,8 @@ sub new {
|
|||
port_resolve=>1,
|
||||
search=>Parse::Netstat::Search->new,
|
||||
sort=>Parse::Netstat::Search::Sort->new,
|
||||
resolver=>Net::DNS::Resolver->new,
|
||||
use_ptr=>1,
|
||||
};
|
||||
bless $self;
|
||||
|
||||
|
@ -167,6 +170,23 @@ sub colorize{
|
|||
}
|
||||
}
|
||||
|
||||
if ( $self->{use_ptr} ){
|
||||
my $answer_f=$self->{resolver}->search( $conn->{foreign_host} );
|
||||
my $answer_l=$self->{resolver}->search( $conn->{local_host} );
|
||||
|
||||
if ( defined( $answer_f->{answer}[0] ) &&
|
||||
( ref( $answer_f->{answer}[0] ) eq 'Net::DNS::RR::PTR' )
|
||||
){
|
||||
$conn->{foreign_host}=lc($answer_f->{answer}[0]->ptrdname);
|
||||
}
|
||||
|
||||
if ( defined( $answer_l->{answer}[0] ) &&
|
||||
( ref( $answer_l->{answer}[0] ) eq 'Net::DNS::RR::PTR' )
|
||||
){
|
||||
$conn->{local_host}=lc($answer_l->{answer}[0]->ptrdname);
|
||||
}
|
||||
}
|
||||
|
||||
my @new_line=(
|
||||
color('BRIGHT_YELLOW').$conn->{proto}.color('reset'),
|
||||
color('BRIGHT_CYAN').$conn->{sendq}.color('reset'),
|
||||
|
|
Loading…
Reference in New Issue