Parse-Netstat-0.14/0000755000175000017500000000000013047245267011572 5ustar s1s1Parse-Netstat-0.14/README0000644000175000017500000000042713047245267012455 0ustar s1s1SYNOPSIS use Parse::Netstat qw(parse_netstat); my $res = parse_netstat(output => join("", `netstat -anp`), flavor=>'linux'); SEE ALSO Parse::Netstat::* for per-flavor notes and sample outputs. parse-netstat from App::ParseNetstat is a CLI for this module. Parse-Netstat-0.14/lib/0000755000175000017500000000000013047245267012340 5ustar s1s1Parse-Netstat-0.14/lib/Parse/0000755000175000017500000000000013047245267013412 5ustar s1s1Parse-Netstat-0.14/lib/Parse/Netstat.pm0000644000175000017500000001423713047245267015401 0ustar s1s1package Parse::Netstat; our $DATE = '2017-02-10'; # DATE our $VERSION = '0.14'; # VERSION use 5.010001; use strict; use warnings; require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(parse_netstat); our %SPEC; $SPEC{parse_netstat} = { v => 1.1, summary => 'Parse the output of "netstat" command', description => <<'_', This program support several flavors of netstat. The default flavor is `linux`. Use `--flavor` to select which flavor you want. Since different flavors provide different fields and same-named fields might contain data in different format, and also not all kinds of possible output from a single flavor are supported, please see the sample parse output for each flavor (in corresponding `Parse::Netstat::*` per-flavor module) you want to use and adjust accordingly. _ args => { output => { summary => 'Output of netstat command', description => <<'_', This function only parses program's output. You need to invoke "netstat" on your own. _ schema => 'str*', pos => 0, req => 1, cmdline_src => 'stdin_or_files', }, flavor => { summary => 'Flavor of netstat', schema => ['str*', in => ['linux', 'solaris', 'freebsd', 'darwin', 'win32']], default => 'linux', }, tcp => { summary => 'Parse TCP connections', 'summary.alt.bool.not' => 'Do not parse TCP connections', schema => [bool => default => 1], }, udp => { summary => 'Parse UDP connections', 'summary.alt.bool.not' => 'Do not parse UDP connections', schema => [bool => default => 1], }, unix => { summary => 'Parse Unix socket connections', 'summary.alt.bool.not' => 'Do not parse Unix socket connections', schema => [bool => default => 1], }, }, examples => [ { src => 'netstat -anp | parse-netstat', src_plang => 'bash', }, ], }; sub parse_netstat { my %args = @_; my $output = $args{output} or return [400, "Please specify output"]; my $tcp = $args{tcp} // 1; my $udp = $args{udp} // 1; my $unix = $args{unix} // 1; my $flavor = $args{flavor} // 'linux'; if ($flavor eq 'linux') { require Parse::Netstat::linux; Parse::Netstat::linux::parse_netstat( output=>$output, tcp=>$tcp, udp=>$udp, unix=>$unix); } elsif ($flavor eq 'freebsd') { require Parse::Netstat::freebsd; Parse::Netstat::freebsd::parse_netstat( output=>$output, tcp=>$tcp, udp=>$udp, unix=>$unix); } elsif ($flavor eq 'darwin') { require Parse::Netstat::darwin; Parse::Netstat::darwin::parse_netstat( output=>$output, tcp=>$tcp, udp=>$udp, unix=>$unix); } elsif ($flavor eq 'solaris') { require Parse::Netstat::solaris; Parse::Netstat::solaris::parse_netstat( output=>$output, tcp=>$tcp, udp=>$udp, unix=>$unix); } elsif ($flavor eq 'win32') { require Parse::Netstat::win32; Parse::Netstat::win32::parse_netstat( output=>$output, tcp=>$tcp, udp=>$udp); } else { return [400, "Unknown flavor '$flavor', please see --help"]; } } 1; # ABSTRACT: Parse the output of "netstat" command __END__ =pod =encoding UTF-8 =head1 NAME Parse::Netstat - Parse the output of "netstat" command =head1 VERSION This document describes version 0.14 of Parse::Netstat (from Perl distribution Parse-Netstat), released on 2017-02-10. =head1 SYNOPSIS use Parse::Netstat qw(parse_netstat); my $res = parse_netstat(output => join("", `netstat -anp`), flavor=>'linux'); =head1 FUNCTIONS =head2 parse_netstat Usage: parse_netstat(%args) -> [status, msg, result, meta] Parse the output of "netstat" command. This program support several flavors of netstat. The default flavor is C. Use C<--flavor> to select which flavor you want. Since different flavors provide different fields and same-named fields might contain data in different format, and also not all kinds of possible output from a single flavor are supported, please see the sample parse output for each flavor (in corresponding C per-flavor module) you want to use and adjust accordingly. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): =over 4 =item * B => I (default: "linux") Flavor of netstat. =item * B* => I Output of netstat command. This function only parses program's output. You need to invoke "netstat" on your own. =item * B => I (default: 1) Parse TCP connections. =item * B => I (default: 1) Parse UDP connections. =item * B => I (default: 1) Parse Unix socket connections. =back Returns an enveloped result (an array). First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information. Return value: (any) =head1 HOMEPAGE Please visit the project's homepage at L. =head1 SOURCE Source repository is at L. =head1 BUGS Please report any bugs or feature requests on the bugtracker website L When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. =head1 SEE ALSO Parse::Netstat::* for per-flavor notes and sample outputs. L from L is a CLI for this module. =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2017, 2015, 2014, 2012, 2011 by perlancar@cpan.org. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Parse-Netstat-0.14/lib/Parse/Netstat/0000755000175000017500000000000013047245267015034 5ustar s1s1Parse-Netstat-0.14/lib/Parse/Netstat/linux.pm0000644000175000017500000003110013047245267016524 0ustar s1s1package Parse::Netstat::linux; our $DATE = '2017-02-10'; # DATE our $VERSION = '0.14'; # VERSION use 5.010001; use strict; use warnings; use Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(parse_netstat); our %SPEC; $SPEC{parse_netstat} = { v => 1.1, summary => 'Parse the output of Linux "netstat" command', description => <<'_', Netstat can be called with `-n` (show raw IP addresses and port numbers instead of hostnames or port names) or without. It can be called with `-a` (show all listening and non-listening socket) option or without. And can be called with `-p` (show PID/program names) or without. _ args => { output => { summary => 'Output of netstat command', schema => 'str*', req => 1, }, tcp => { summary => 'Whether to parse TCP (and TCP6) connections', schema => [bool => default => 1], }, udp => { summary => 'Whether to parse UDP (and UDP6) connections', schema => [bool => default => 1], }, unix => { summary => 'Whether to parse Unix socket connections', schema => [bool => default => 1], }, }, }; sub parse_netstat { my %args = @_; my $output = $args{output} or return [400, "Please specify output"]; my $tcp = $args{tcp} // 1; my $udp = $args{udp} // 1; my $unix = $args{unix} // 1; my $in_unix; my $in_unix_header; my @conns; my $i = 0; for my $line (split /^/, $output) { $i++; my %k; if ($line =~ /^tcp/ && $tcp) { #Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name #tcp 0 0 0.0.0.0:8898 0.0.0.0:* LISTEN 5566/daemon2.pl [pa $line =~ m!^(?Ptcp[46]?) \s+ (?P\d+) \s+ (?P\d+)\s+ (?P\S+?):(?P\w+)\s+ (?P\S+?):(?P\w+|\*)\s+ (?P\S+) (?: \s+ (?: (?P\d+)/(?P.+?) | - ))? \s*$!x or return [400, "Can't parse tcp line (#$i): $line"]; %k = %+; } elsif ($line =~ /^udp/ && $udp) { #udp 0 0 0.0.0.0:631 0.0.0.0:* 2769/cupsd $line =~ m!^(?Pudp[46]?) \s+ (?P\d+) \s+ (?P\d+) \s+ (?P\S+?):(?P\w+|\*)\s+ (?P\S+?):(?P\w+|\*) (?: \s+ (?P\S+)? (?: \s+ (?: (?P\d+)/(?P.+?) | - ))? )? \s*$!x or return [400, "Can't parse udp line (#$i): $line"]; %k = %+; } elsif ($line =~ /^unix/ && $unix) { #Proto RefCnt Flags Type State I-Node PID/Program name Path # unix 2 [ ACC ] STREAM LISTENING 650654 30463/gconfd-2 /tmp/orbit-t1/linc-76ff-0-3fc1dd3f2f2 $line =~ m!^(?Punix) \s+ (?P\d+) \s+ \[\s*(?P\S*)\s*\] \s+ (?P\S+) \s+ (?P\S+|\s+) \s+ (?P\d+) \s+ (?: (?: (?P\d+)/(?P.+?) | - ) \s+)? (?P.*?)\s*$!x or return [400, "Can't parse unix line (#$i): $line"]; %k = %+; } else { next; } push @conns, \%k; } [200, "OK", {active_conns => \@conns}]; } 1; # ABSTRACT: Parse the output of Linux "netstat" command __END__ =pod =encoding UTF-8 =head1 NAME Parse::Netstat::linux - Parse the output of Linux "netstat" command =head1 VERSION This document describes version 0.14 of Parse::Netstat::linux (from Perl distribution Parse-Netstat), released on 2017-02-10. =head1 SYNOPSIS use Parse::Netstat qw(parse_netstat); my $res = parse_netstat(output=>join("", `netstat -anp`), flavor=>"linux"); Sample `netstat -anp` output: Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:1027 0.0.0.0:* LISTEN - tcp 0 0 builder.localdomain:1028 *:* LISTEN tcp 0 0 127.0.0.1:58159 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:58160 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:7634 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:631 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1234/program with space tcp 0 0 192.168.0.103:44922 1.2.3.4:143 ESTABLISHED 25820/thunderbird-b tcp6 0 0 ::1:1028 :::* LISTEN - udp 0 0 0.0.0.0:631 0.0.0.0:* - udp 0 0 192.168.0.103:56668 0.0.0.0:* - udp 0 0 192.168.0.103:52753 0.0.0.0:* 8888/opera udp6 0 0 :::42069 :::* - Active UNIX domain sockets (servers and established) Proto RefCnt Flags Type State I-Node PID/Program name Path unix 2 [ ] DGRAM 6906 - /var/spool/postfix/dev/log unix 2 [ ACC ] STREAM LISTENING 650654 - /tmp/orbit-t1/linc-76ff-0-3fc1dd3f2f2 unix 2 [ ACC ] STREAM LISTENING 1121541 16933/kate 123 /tmp/orbit-s1/linc-4225-0-267d23358095e Sample result: [ 200, "OK", { active_conns => [ { foreign_host => "0.0.0.0", foreign_port => "*", local_host => "127.0.0.1", local_port => 1027, proto => "tcp", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "*", foreign_port => "*", local_host => "builder.localdomain", local_port => 1028, proto => "tcp", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "0.0.0.0", foreign_port => "*", local_host => "127.0.0.1", local_port => 58159, proto => "tcp", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "0.0.0.0", foreign_port => "*", local_host => "127.0.0.1", local_port => 58160, proto => "tcp", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "0.0.0.0", foreign_port => "*", local_host => "127.0.0.1", local_port => 7634, proto => "tcp", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "0.0.0.0", foreign_port => "*", local_host => "0.0.0.0", local_port => 22, proto => "tcp", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "0.0.0.0", foreign_port => "*", local_host => "0.0.0.0", local_port => 631, proto => "tcp", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "0.0.0.0", foreign_port => "*", local_host => "127.0.0.1", local_port => 25, pid => 1234, program => "program with space", proto => "tcp", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "1.2.3.4", foreign_port => 143, local_host => "192.168.0.103", local_port => 44922, pid => 25820, program => "thunderbird-b", proto => "tcp", recvq => 0, sendq => 0, state => "ESTABLISHED", }, { foreign_host => "::", foreign_port => "*", local_host => "::1", local_port => 1028, proto => "tcp6", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "0.0.0.0", foreign_port => "*", local_host => "0.0.0.0", local_port => 631, proto => "udp", recvq => 0, sendq => 0, state => "-", }, { foreign_host => "0.0.0.0", foreign_port => "*", local_host => "192.168.0.103", local_port => 56668, proto => "udp", recvq => 0, sendq => 0, state => "-", }, { foreign_host => "0.0.0.0", foreign_port => "*", local_host => "192.168.0.103", local_port => 52753, proto => "udp", recvq => 0, sendq => 0, state => "8888/opera", }, { foreign_host => "::", foreign_port => "*", local_host => "::", local_port => 42069, proto => "udp6", recvq => 0, sendq => 0, state => "-", }, { flags => "", inode => 6906, path => "/var/spool/postfix/dev/log", proto => "unix", refcnt => 2, state => " ", type => "DGRAM", }, { flags => "ACC", inode => 650654, path => "/tmp/orbit-t1/linc-76ff-0-3fc1dd3f2f2", proto => "unix", refcnt => 2, state => "LISTENING", type => "STREAM", }, { flags => "ACC", inode => 1121541, path => "123 /tmp/orbit-s1/linc-4225-0-267d23358095e", pid => 16933, program => "kate", proto => "unix", refcnt => 2, state => "LISTENING", type => "STREAM", }, ], }, ] =head1 FUNCTIONS =head2 parse_netstat Usage: parse_netstat(%args) -> [status, msg, result, meta] Parse the output of Linux "netstat" command. Netstat can be called with C<-n> (show raw IP addresses and port numbers instead of hostnames or port names) or without. It can be called with C<-a> (show all listening and non-listening socket) option or without. And can be called with C<-p> (show PID/program names) or without. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): =over 4 =item * B* => I Output of netstat command. =item * B => I (default: 1) Whether to parse TCP (and TCP6) connections. =item * B => I (default: 1) Whether to parse UDP (and UDP6) connections. =item * B => I (default: 1) Whether to parse Unix socket connections. =back Returns an enveloped result (an array). First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information. Return value: (any) =head1 HOMEPAGE Please visit the project's homepage at L. =head1 SOURCE Source repository is at L. =head1 BUGS Please report any bugs or feature requests on the bugtracker website L When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2017, 2015, 2014, 2012, 2011 by perlancar@cpan.org. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Parse-Netstat-0.14/lib/Parse/Netstat/win32.pm0000644000175000017500000002162313047245267016340 0ustar s1s1package Parse::Netstat::win32; our $DATE = '2017-02-10'; # DATE our $VERSION = '0.14'; # VERSION use 5.010001; use strict; use warnings; use Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(parse_netstat); our %SPEC; $SPEC{parse_netstat} = { v => 1.1, summary => 'Parse the output of Windows "netstat" command', description => <<'_', Netstat can be called with `-n` (show raw IP addresses and port numbers instead of hostnames or port names) or without. It can be called with `-a` (show all listening and non-listening socket) option or without. And can be called with `-p` (show PID/program names) or without. _ args => { output => { summary => 'Output of netstat command', schema => 'str*', req => 1, }, tcp => { summary => 'Whether to parse TCP (and TCP6) connections', schema => [bool => default => 1], }, udp => { summary => 'Whether to parse UDP (and UDP6) connections', schema => [bool => default => 1], }, }, }; sub parse_netstat { my %args = @_; my $output = $args{output} or return [400, "Please specify output"]; my $tcp = $args{tcp} // 1; my $udp = $args{udp} // 1; my @conns; my $i = 0; my $cur; # whether we're currently parsing TCP or UDP entry my $k; for my $line (split /^/, $output) { $i++; if ($line =~ /^\s*TCP\s/ && $tcp) { # Proto Local Address Foreign Address State PID # TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 988 # c:\windows\system32\WS2_32.dll # C:\WINDOWS\system32\RPCRT4.dll # c:\windows\system32\rpcss.dll # C:\WINDOWS\system32\svchost.exe # -- unknown component(s) -- # [svchost.exe] # $line =~ m!^\s*(?PTCP6?) \s+ (?P\S+?):(?P\w+)\s+ (?P\S+?):(?P\w+|\*)\s+ (?P\S+) (?: \s+ (?: (?P\d+) ))? \s*$!x or return [400, "Can't parse tcp line (#$i): $line"]; $k = { %+ }; $cur = 'tcp'; for ($k->{proto}) { $_ = lc } push @conns, $k; } elsif ($line =~ /^\s*UDP\s/ && $udp) { # UDP 0.0.0.0:500 *:* 696 # [lsass.exe] # # XXX state not yet parsed $line =~ m!^\s*(?PUDP6?) \s+ (?P\S+?):(?P\w+)\s+ (?P\S+?):(?P\w+|\*)\s+ (?: \s+ (?: (?P\d+) ))? \s*$!x or return [400, "Can't parse udp line (#$i): $line"]; $k = { %+ }; $cur = 'udp'; for ($k->{proto}) { $_ = lc } push @conns, $k; } elsif ($cur) { $k->{execs} //= []; next if $line =~ /^\s*--/; # e.g. -- unknown component(s) -- next if $line =~ /^\s*can not/i; # e.g. Can not obtain ownership information push @{ $k->{execs} }, $1 if $line =~ /^\s*(\S.*?)\s*$/; next; } else { # a blank line or headers. ignore. } } [200, "OK", {active_conns => \@conns}]; } 1; # ABSTRACT: Parse the output of Windows "netstat" command __END__ =pod =encoding UTF-8 =head1 NAME Parse::Netstat::win32 - Parse the output of Windows "netstat" command =head1 VERSION This document describes version 0.14 of Parse::Netstat::win32 (from Perl distribution Parse-Netstat), released on 2017-02-10. =head1 SYNOPSIS use Parse::Netstat qw(parse_netstat); my $res = parse_netstat(output=>join("", `netstat -anp`), flavor=>"win32"); Sample `netstat -anp` output: Active Connections Proto Local Address Foreign Address State PID TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 988 c:\windows\system32\WS2_32.dll C:\WINDOWS\system32\RPCRT4.dll c:\windows\system32\rpcss.dll C:\WINDOWS\system32\svchost.exe -- unknown component(s) -- [svchost.exe] TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4 [System] TCP 127.0.0.1:1027 0.0.0.0:0 LISTENING 1244 [alg.exe] TCP 192.168.0.104:139 0.0.0.0:0 LISTENING 4 [System] UDP 0.0.0.0:1025 *:* 1120 C:\WINDOWS\system32\mswsock.dll c:\windows\system32\WS2_32.dll c:\windows\system32\DNSAPI.dll c:\windows\system32\dnsrslvr.dll C:\WINDOWS\system32\RPCRT4.dll [svchost.exe] UDP 0.0.0.0:500 *:* 696 [lsass.exe] Sample result: [ 200, "OK", { active_conns => [ { execs => [ "c:\\windows\\system32\\WS2_32.dll", "C:\\WINDOWS\\system32\\RPCRT4.dll", "c:\\windows\\system32\\rpcss.dll", "C:\\WINDOWS\\system32\\svchost.exe", "[svchost.exe]", ], foreign_host => "0.0.0.0", foreign_port => 0, local_host => "0.0.0.0", local_port => 135, pid => 988, proto => "tcp", state => "LISTENING", }, { execs => ["[System]"], foreign_host => "0.0.0.0", foreign_port => 0, local_host => "0.0.0.0", local_port => 445, pid => 4, proto => "tcp", state => "LISTENING", }, { execs => ["[alg.exe]"], foreign_host => "0.0.0.0", foreign_port => 0, local_host => "127.0.0.1", local_port => 1027, pid => 1244, proto => "tcp", state => "LISTENING", }, { execs => ["[System]"], foreign_host => "0.0.0.0", foreign_port => 0, local_host => "192.168.0.104", local_port => 139, pid => 4, proto => "tcp", state => "LISTENING", }, { execs => [ "C:\\WINDOWS\\system32\\mswsock.dll", "c:\\windows\\system32\\WS2_32.dll", "c:\\windows\\system32\\DNSAPI.dll", "c:\\windows\\system32\\dnsrslvr.dll", "C:\\WINDOWS\\system32\\RPCRT4.dll", "[svchost.exe]", ], foreign_host => "*", foreign_port => "*", local_host => "0.0.0.0", local_port => 1025, pid => 1120, proto => "udp", }, { execs => ["[lsass.exe]"], foreign_host => "*", foreign_port => "*", local_host => "0.0.0.0", local_port => 500, pid => 696, proto => "udp", }, ], }, ] =head1 FUNCTIONS =head2 parse_netstat Usage: parse_netstat(%args) -> [status, msg, result, meta] Parse the output of Windows "netstat" command. Netstat can be called with C<-n> (show raw IP addresses and port numbers instead of hostnames or port names) or without. It can be called with C<-a> (show all listening and non-listening socket) option or without. And can be called with C<-p> (show PID/program names) or without. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): =over 4 =item * B* => I Output of netstat command. =item * B => I (default: 1) Whether to parse TCP (and TCP6) connections. =item * B => I (default: 1) Whether to parse UDP (and UDP6) connections. =back Returns an enveloped result (an array). First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information. Return value: (any) =head1 HOMEPAGE Please visit the project's homepage at L. =head1 SOURCE Source repository is at L. =head1 BUGS Please report any bugs or feature requests on the bugtracker website L When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2017, 2015, 2014, 2012, 2011 by perlancar@cpan.org. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Parse-Netstat-0.14/lib/Parse/Netstat/freebsd.pm0000644000175000017500000006663413047245267017023 0ustar s1s1package Parse::Netstat::freebsd; our $DATE = '2017-02-10'; # DATE our $VERSION = '0.14'; # VERSION use 5.010001; use strict; use warnings; use Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(parse_netstat); our %SPEC; $SPEC{parse_netstat} = { v => 1.1, summary => 'Parse the output of FreeBSD "netstat" command', description => <<'_', Netstat can be called with `-n` (show raw IP addresses and port numbers instead of hostnames or port names) or without. It can be called with `-a` (show all listening and non-listening socket) option or without. Tested with FreeBSD 10.1's netstat. _ args => { output => { summary => 'Output of netstat command', schema => 'str*', req => 1, }, tcp => { summary => 'Whether to parse TCP (and TCP6) connections', schema => [bool => default => 1], }, udp => { summary => 'Whether to parse UDP (and UDP6) connections', schema => [bool => default => 1], }, unix => { summary => 'Whether to parse Unix socket connections', schema => [bool => default => 1], }, }, }; sub parse_netstat { my %args = @_; my $output = $args{output} or return [400, "Please specify output"]; my $tcp = $args{tcp} // 1; my $udp = $args{udp} // 1; my $unix = $args{unix} // 1; my $in_unix; my $in_unix_header; my @conns; my $i = 0; for my $line (split /^/, $output) { $i++; my %k; if ($line =~ /^Registered kernel control modules/) { $in_unix = 0; } elsif ($line =~ /^tcp/ && $tcp) { #Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name #tcp4 0 0 192.168.1.33.632 192.168.1.10.2049 CLOSED $line =~ m!^(?Ptcp(?:4|6|46)?) \s+ (?P\d+) \s+ (?P\d+)\s+ (?P\S+?)[:.](?P\w+)\s+ (?P\S+?)[:.](?P\w+|\*)\s+ (?P\S+) (?: \s+ (?: (?P\d+)/(?P.+?) | - ))? \s*$!x or return [400, "Can't parse tcp line (#$i): $line"]; %k = %+; } elsif ($line =~ /^udp/ && $udp) { #Proto Recv-Q Send-Q Local Address Foreign Address (state) #udp4 0 0 *.879 *.* $line =~ m!^(?Pudp(?:4|6|46)?) \s+ (?P\d+) \s+ (?P\d+) \s+ (?P\S+?)[:.](?P\w+|\*)\s+ (?P\S+?)[:.](?P\w+|\*) (?: \s+ (?P\S+)? (?: \s+ (?: (?P\d+)/(?P.+?) | - ))? )? \s*$!x or return [400, "Can't parse udp line (#$i): $line"]; %k = %+; } elsif ($in_unix && $unix) { #Address Type Recv-Q Send-Q Inode Conn Refs Nextref Addr #fffffe00029912d0 stream 0 0 fffffe0002d8abd0 0 0 0 /tmp/ssh-zwZwlpzaip/agent.1089 $line =~ m!^(?P
\S+) \s+ (?P\S+) \s+ (?P\d+) \s+ (?P\d+) \s+ (?P[0-9a-f]+) \s+ (?P[0-9a-f]+) \s+ (?P[0-9a-f]+) \s+ (?P[0-9a-f]+) (?: \s+ (?P.+) )? \s*$!x or return [400, "Can't parse unix/freebsd line (#$i): $line"]; %k = %+; $k{proto} = 'unix'; } elsif ($in_unix_header) { $in_unix_header = 0; $in_unix++; } elsif ($line =~ /^Active (UNIX|LOCAL \(UNIX\)) domain sockets/) { $in_unix_header++; } else { next; } push @conns, \%k; } [200, "OK", {active_conns => \@conns}]; } 1; # ABSTRACT: Parse the output of FreeBSD "netstat" command __END__ =pod =encoding UTF-8 =head1 NAME Parse::Netstat::freebsd - Parse the output of FreeBSD "netstat" command =head1 VERSION This document describes version 0.14 of Parse::Netstat::freebsd (from Perl distribution Parse-Netstat), released on 2017-02-10. =head1 SYNOPSIS use Parse::Netstat qw(parse_netstat); my $res = parse_netstat(output=>join("", `netstat -an`), flavor=>"freebsd"); Sample `netstat -an` output: Active Internet connections (including servers) Proto Recv-Q Send-Q Local Address Foreign Address (state) tcp4 0 0 192.168.1.33.780 192.168.1.10.2049 CLOSE_WAIT tcp4 0 0 192.168.1.33.632 192.168.1.10.2049 CLOSED tcp4 0 0 127.0.0.1.6012 *.* LISTEN tcp6 0 0 ::1.6012 *.* LISTEN tcp4 0 52 192.168.1.33.22 192.168.1.10.41487 ESTABLISHED tcp4 0 0 127.0.0.1.6011 *.* LISTEN tcp6 0 0 ::1.6011 *.* LISTEN tcp4 0 0 192.168.1.33.22 192.168.1.10.61223 ESTABLISHED tcp4 0 0 127.0.0.1.6010 *.* LISTEN tcp6 0 0 ::1.6010 *.* LISTEN tcp4 0 0 192.168.1.33.22 192.168.1.10.18499 ESTABLISHED tcp4 0 0 192.168.1.33.22 192.168.1.10.30712 ESTABLISHED tcp4 0 0 127.0.0.1.25 *.* LISTEN tcp4 0 0 *.22 *.* LISTEN tcp6 0 0 *.22 *.* LISTEN tcp4 0 0 *.4949 *.* LISTEN tcp6 0 0 *.4949 *.* LISTEN tcp4 0 0 *.667 *.* LISTEN tcp6 0 0 *.896 *.* LISTEN tcp4 0 0 *.879 *.* LISTEN tcp6 0 0 *.879 *.* LISTEN tcp4 0 0 *.111 *.* LISTEN tcp6 0 0 *.111 *.* LISTEN udp4 0 0 *.682 *.* udp6 0 0 *.726 *.* udp6 0 0 *.948 *.* udp4 0 0 *.* *.* udp4 0 0 *.879 *.* udp6 0 0 *.879 *.* udp6 0 0 *.* *.* udp4 0 0 *.755 *.* udp4 0 0 *.111 *.* udp6 0 0 *.932 *.* udp6 0 0 *.111 *.* udp4 0 0 *.514 *.* udp6 0 0 *.514 *.* Active UNIX domain sockets Address Type Recv-Q Send-Q Inode Conn Refs Nextref Addr fffff80057aa11e0 stream 0 0 0 0 0 0 fffff80057aa12d0 stream 0 0 0 0 0 0 fffff8001b0bc5a0 stream 0 0 fffff80011150938 0 0 0 /tmp/ssh-52dQiqRzC4/agent.35116 fffff8001b0bc780 stream 0 0 0 fffff8001b0bcc30 0 0 fffff8001b0bcc30 stream 0 0 0 fffff8001b0bc780 0 0 fffff80002ad85a0 stream 0 0 fffff80030dfd760 0 0 0 /tmp/ssh-ZPrtis6Qgb/agent.21969 fffff8001b0bc2d0 stream 0 0 0 fffff80057aa10f0 0 0 fffff80057aa10f0 stream 0 0 0 fffff8001b0bc2d0 0 0 fffff80002ad82d0 stream 0 0 0 fffff80002ad84b0 0 0 fffff80002ad84b0 stream 0 0 0 fffff80002ad82d0 0 0 fffff800028b3960 stream 0 0 fffff800354e3588 0 0 0 /var/run/dbus/system_bus_socket fffff80002ad8a50 stream 0 0 0 fffff80002ad8c30 0 0 fffff80002ad8c30 stream 0 0 0 fffff80002ad8a50 0 0 fffff80002ad91e0 stream 0 0 fffff80002f5b1d8 0 0 0 /tmp/ssh-EXvnWwxbk4/agent.750 fffff80002ad93c0 stream 0 0 0 fffff80002ad90f0 0 0 fffff80002ad90f0 stream 0 0 0 fffff80002ad93c0 0 0 fffff80002ad9780 stream 0 0 fffff800029db000 0 0 0 /var/run/rpcbind.sock fffff80002ad9b40 stream 0 0 fffff800029a4000 0 0 0 /var/run/devd.pipe fffff80002ad80f0 dgram 0 0 0 fffff80002ad9960 0 fffff80002ad94b0 fffff80002ad9000 dgram 0 0 0 fffff80002ad9870 0 fffff80002ad92d0 fffff80002ad94b0 dgram 0 0 0 fffff80002ad9960 0 0 fffff80002ad92d0 dgram 0 0 0 fffff80002ad9870 0 fffff80002ad9690 fffff80002ad9690 dgram 0 0 0 fffff80002ad9870 0 fffff80002ad95a0 fffff80002ad95a0 dgram 0 0 0 fffff80002ad9870 0 0 fffff80002ad9870 dgram 0 0 fffff80002b3e938 0 fffff80002ad9000 0 /var/run/logpriv fffff80002ad9960 dgram 0 0 fffff80002b3eb10 0 fffff80002ad80f0 0 /var/run/log fffff80002ad9a50 seqpac 0 0 fffff80002947ce8 0 0 0 /var/run/devd.seqpacket.pipe Sample result: [ 200, "OK", { active_conns => [ { foreign_host => "192.168.1.10", foreign_port => 2049, local_host => "192.168.1.33", local_port => 780, proto => "tcp4", recvq => 0, sendq => 0, state => "CLOSE_WAIT", }, { foreign_host => "192.168.1.10", foreign_port => 2049, local_host => "192.168.1.33", local_port => 632, proto => "tcp4", recvq => 0, sendq => 0, state => "CLOSED", }, { foreign_host => "*", foreign_port => "*", local_host => "127.0.0.1", local_port => 6012, proto => "tcp4", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "*", foreign_port => "*", local_host => "::1", local_port => 6012, proto => "tcp6", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "192.168.1.10", foreign_port => 41487, local_host => "192.168.1.33", local_port => 22, proto => "tcp4", recvq => 0, sendq => 52, state => "ESTABLISHED", }, { foreign_host => "*", foreign_port => "*", local_host => "127.0.0.1", local_port => 6011, proto => "tcp4", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "*", foreign_port => "*", local_host => "::1", local_port => 6011, proto => "tcp6", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "192.168.1.10", foreign_port => 61223, local_host => "192.168.1.33", local_port => 22, proto => "tcp4", recvq => 0, sendq => 0, state => "ESTABLISHED", }, { foreign_host => "*", foreign_port => "*", local_host => "127.0.0.1", local_port => 6010, proto => "tcp4", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "*", foreign_port => "*", local_host => "::1", local_port => 6010, proto => "tcp6", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "192.168.1.10", foreign_port => 18499, local_host => "192.168.1.33", local_port => 22, proto => "tcp4", recvq => 0, sendq => 0, state => "ESTABLISHED", }, { foreign_host => "192.168.1.10", foreign_port => 30712, local_host => "192.168.1.33", local_port => 22, proto => "tcp4", recvq => 0, sendq => 0, state => "ESTABLISHED", }, { foreign_host => "*", foreign_port => "*", local_host => "127.0.0.1", local_port => 25, proto => "tcp4", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 22, proto => "tcp4", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 22, proto => "tcp6", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 4949, proto => "tcp4", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 4949, proto => "tcp6", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 667, proto => "tcp4", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 896, proto => "tcp6", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 879, proto => "tcp4", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 879, proto => "tcp6", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 111, proto => "tcp4", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 111, proto => "tcp6", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 682, proto => "udp4", recvq => 0, sendq => 0, }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 726, proto => "udp6", recvq => 0, sendq => 0, }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 948, proto => "udp6", recvq => 0, sendq => 0, }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => "*", proto => "udp4", recvq => 0, sendq => 0, }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 879, proto => "udp4", recvq => 0, sendq => 0, }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 879, proto => "udp6", recvq => 0, sendq => 0, }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => "*", proto => "udp6", recvq => 0, sendq => 0, }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 755, proto => "udp4", recvq => 0, sendq => 0, }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 111, proto => "udp4", recvq => 0, sendq => 0, }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 932, proto => "udp6", recvq => 0, sendq => 0, }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 111, proto => "udp6", recvq => 0, sendq => 0, }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 514, proto => "udp4", recvq => 0, sendq => 0, }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 514, proto => "udp6", recvq => 0, sendq => 0, }, {}, {}, { address => "fffff80057aa11e0", conn => 0, inode => 0, nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { address => "fffff80057aa12d0", conn => 0, inode => 0, nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { addr => "/tmp/ssh-52dQiqRzC4/agent.35116", address => "fffff8001b0bc5a0", conn => 0, inode => "fffff80011150938", nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { address => "fffff8001b0bc780", conn => "fffff8001b0bcc30", inode => 0, nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { address => "fffff8001b0bcc30", conn => "fffff8001b0bc780", inode => 0, nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { addr => "/tmp/ssh-ZPrtis6Qgb/agent.21969", address => "fffff80002ad85a0", conn => 0, inode => "fffff80030dfd760", nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { address => "fffff8001b0bc2d0", conn => "fffff80057aa10f0", inode => 0, nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { address => "fffff80057aa10f0", conn => "fffff8001b0bc2d0", inode => 0, nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { address => "fffff80002ad82d0", conn => "fffff80002ad84b0", inode => 0, nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { address => "fffff80002ad84b0", conn => "fffff80002ad82d0", inode => 0, nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { addr => "/var/run/dbus/system_bus_socket", address => "fffff800028b3960", conn => 0, inode => "fffff800354e3588", nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { address => "fffff80002ad8a50", conn => "fffff80002ad8c30", inode => 0, nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { address => "fffff80002ad8c30", conn => "fffff80002ad8a50", inode => 0, nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { addr => "/tmp/ssh-EXvnWwxbk4/agent.750", address => "fffff80002ad91e0", conn => 0, inode => "fffff80002f5b1d8", nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { address => "fffff80002ad93c0", conn => "fffff80002ad90f0", inode => 0, nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { address => "fffff80002ad90f0", conn => "fffff80002ad93c0", inode => 0, nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { addr => "/var/run/rpcbind.sock", address => "fffff80002ad9780", conn => 0, inode => "fffff800029db000", nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { addr => "/var/run/devd.pipe", address => "fffff80002ad9b40", conn => 0, inode => "fffff800029a4000", nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { address => "fffff80002ad80f0", conn => "fffff80002ad9960", inode => 0, nextref => "fffff80002ad94b0", proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "dgram", }, { address => "fffff80002ad9000", conn => "fffff80002ad9870", inode => 0, nextref => "fffff80002ad92d0", proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "dgram", }, { address => "fffff80002ad94b0", conn => "fffff80002ad9960", inode => 0, nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "dgram", }, { address => "fffff80002ad92d0", conn => "fffff80002ad9870", inode => 0, nextref => "fffff80002ad9690", proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "dgram", }, { address => "fffff80002ad9690", conn => "fffff80002ad9870", inode => 0, nextref => "fffff80002ad95a0", proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "dgram", }, { address => "fffff80002ad95a0", conn => "fffff80002ad9870", inode => 0, nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "dgram", }, { addr => "/var/run/logpriv", address => "fffff80002ad9870", conn => 0, inode => "fffff80002b3e938", nextref => 0, proto => "unix", recvq => 0, refs => "fffff80002ad9000", sendq => 0, type => "dgram", }, { addr => "/var/run/log", address => "fffff80002ad9960", conn => 0, inode => "fffff80002b3eb10", nextref => 0, proto => "unix", recvq => 0, refs => "fffff80002ad80f0", sendq => 0, type => "dgram", }, { addr => "/var/run/devd.seqpacket.pipe", address => "fffff80002ad9a50", conn => 0, inode => "fffff80002947ce8", nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "seqpac", }, ], }, ] =head1 FUNCTIONS =head2 parse_netstat Usage: parse_netstat(%args) -> [status, msg, result, meta] Parse the output of FreeBSD "netstat" command. Netstat can be called with C<-n> (show raw IP addresses and port numbers instead of hostnames or port names) or without. It can be called with C<-a> (show all listening and non-listening socket) option or without. Tested with FreeBSD 10.1's netstat. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): =over 4 =item * B* => I Output of netstat command. =item * B => I (default: 1) Whether to parse TCP (and TCP6) connections. =item * B => I (default: 1) Whether to parse UDP (and UDP6) connections. =item * B => I (default: 1) Whether to parse Unix socket connections. =back Returns an enveloped result (an array). First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information. Return value: (any) =head1 HOMEPAGE Please visit the project's homepage at L. =head1 SOURCE Source repository is at L. =head1 BUGS Please report any bugs or feature requests on the bugtracker website L When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2017, 2015, 2014, 2012, 2011 by perlancar@cpan.org. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Parse-Netstat-0.14/lib/Parse/Netstat/darwin.pm0000644000175000017500000003213713047245267016664 0ustar s1s1package Parse::Netstat::darwin; our $DATE = '2017-02-10'; # DATE our $VERSION = '0.14'; # VERSION use 5.010001; use strict; use warnings; use Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(parse_netstat); our %SPEC; require Parse::Netstat::freebsd; $SPEC{parse_netstat} = do { my $meta = { %{ $Parse::Netstat::freebsd::SPEC{parse_netstat} } }; $meta->{summary} = 'Parse the output of Mac OS X "netstat" command', $meta->{description} = <<'_'; Netstat can be called with `-n` (show raw IP addresses and port numbers instead of hostnames or port names) or without. It can be called with `-a` (show all listening and non-listening socket) option or without. _ $meta; }; sub parse_netstat { Parse::Netstat::freebsd::parse_netstat(@_); } 1; # ABSTRACT: Parse the output of Mac OS X "netstat" command __END__ =pod =encoding UTF-8 =head1 NAME Parse::Netstat::darwin - Parse the output of Mac OS X "netstat" command =head1 VERSION This document describes version 0.14 of Parse::Netstat::darwin (from Perl distribution Parse-Netstat), released on 2017-02-10. =head1 SYNOPSIS use Parse::Netstat qw(parse_netstat); my $res = parse_netstat(output=>join("", `netstat -an`), flavor=>"darwin"); Sample `netstat -an` output: Active Internet connections (including servers) Proto Recv-Q Send-Q Local Address Foreign Address (state) tcp4 0 0 10.8.0.6.54433 1.2.3.4.443 ESTABLISHED tcp46 0 0 *.80 *.* LISTEN tcp6 0 0 *.88 *.* LISTEN udp4 0 0 *.* *.* udp6 0 0 *.52919 *.* udp46 0 0 *.* *.* Active Multipath Internet connections Proto/ID Flags Local Address Foreign Address (state) Active LOCAL (UNIX) domain sockets Address Type Recv-Q Send-Q Inode Conn Refs Nextref Addr 4f1eb4c58685585f stream 0 0 0 4f1eb4c5868572ef 0 0 /var/run/mDNSResponder 4f1eb4c5868572ef stream 0 0 0 4f1eb4c58685585f 0 0 4f1eb4c578f0c92f stream 0 0 0 4f1eb4c578f0c2ef 0 0 4f1eb4c58bd4e227 stream 0 0 4f1eb4c5891011b7 0 0 0 /var/run/vmnat.40388 Registered kernel control modules id flags pcbcount rcvbuf sndbuf name 1 9 0 131072 131072 com.apple.flow-divert 2 1 1 16384 2048 com.apple.nke.sockwall 3 9 0 524288 524288 com.apple.content-filter 4 9 0 8192 2048 com.apple.packet-mangler 5 1 3 65536 65536 com.apple.net.necp_control 6 1 10 65536 65536 com.apple.net.netagent 7 9 5 524288 524288 com.apple.net.utun_control 8 1 0 65536 65536 com.apple.net.ipsec_control 9 0 39 8192 2048 com.apple.netsrc a 18 4 8192 2048 com.apple.network.statistics b 5 0 8192 2048 com.apple.network.tcp_ccdebug c 1 1 8192 2048 com.apple.network.advisory d 1 1 8192 2048 com.vmware.kext.vmci e 1 9 229376 229376 com.vmware.kext.vmnet f 1 168 8192 2048 com.vmware.kext.vmx86 Active kernel event sockets Proto Recv-Q Send-Q vendor class subcla kevt 0 0 1 1 11 kevt 0 0 1 1 7 kevt 0 0 1 1 1 kevt 0 0 1 4 0 kevt 0 0 1 6 1 kevt 0 0 1 6 1 kevt 0 0 1 1 2 kevt 0 0 1 6 1 kevt 0 0 1 6 1 kevt 0 0 1 1 10 kevt 0 0 1001 5 11 kevt 0 0 1 6 1 kevt 0 0 1 6 1 kevt 0 0 1 6 1 kevt 0 0 1 6 1 kevt 0 0 1 6 1 kevt 0 0 1 6 1 kevt 0 0 1 1 2 kevt 0 0 1 1 2 kevt 0 0 1 6 1 kevt 0 0 1 1 0 Active kernel control sockets Proto Recv-Q Send-Q unit id name kctl 0 0 1 2 com.apple.nke.sockwall kctl 0 0 1 5 com.apple.net.necp_control kctl 0 0 2 5 com.apple.net.necp_control kctl 0 0 3 5 com.apple.net.necp_control kctl 0 0 1 6 com.apple.net.netagent kctl 0 0 2 6 com.apple.net.netagent kctl 0 0 3 6 com.apple.net.netagent kctl 0 0 4 6 com.apple.net.netagent kctl 0 0 5 6 com.apple.net.netagent kctl 0 0 6 6 com.apple.net.netagent kctl 0 0 7 6 com.apple.net.netagent kctl 0 0 8 6 com.apple.net.netagent kctl 0 0 10 6 com.apple.net.netagent kctl 0 0 11 6 com.apple.net.netagent kctl 0 0 1 7 com.apple.net.utun_control kctl 0 0 2 7 com.apple.net.utun_control kctl 0 0 3 7 com.apple.net.utun_control kctl 0 0 4 7 com.apple.net.utun_control kctl 0 0 5 7 com.apple.net.utun_control kctl 0 0 1 9 com.apple.netsrc kctl 0 0 2 9 com.apple.netsrc kctl 0 0 3 9 com.apple.netsrc kctl 0 0 4 9 com.apple.netsrc kctl 0 0 5 9 com.apple.netsrc kctl 0 0 6 9 com.apple.netsrc kctl 0 0 7 9 com.apple.netsrc kctl 0 0 9 9 com.apple.netsrc kctl 0 0 10 9 com.apple.netsrc kctl 0 0 11 9 com.apple.netsrc kctl 0 0 12 9 com.apple.netsrc kctl 0 0 13 9 com.apple.netsrc kctl 0 0 14 9 com.apple.netsrc kctl 0 0 15 9 com.apple.netsrc kctl 0 0 16 9 com.apple.netsrc kctl 0 0 17 9 com.apple.netsrc kctl 0 0 18 9 com.apple.netsrc kctl 0 0 19 9 com.apple.netsrc kctl 0 0 20 9 com.apple.netsrc kctl 0 0 21 9 com.apple.netsrc kctl 0 0 22 9 com.apple.netsrc kctl 0 0 23 9 com.apple.netsrc kctl 0 0 24 9 com.apple.netsrc kctl 0 0 25 9 com.apple.netsrc kctl 0 0 26 9 com.apple.netsrc kctl 0 0 27 9 com.apple.netsrc kctl 0 0 28 9 com.apple.netsrc kctl 0 0 29 9 com.apple.netsrc kctl 0 0 30 9 com.apple.netsrc kctl 0 0 31 9 com.apple.netsrc kctl 0 0 32 9 com.apple.netsrc kctl 0 0 33 9 com.apple.netsrc kctl 0 0 34 9 com.apple.netsrc kctl 0 0 35 9 com.apple.netsrc kctl 0 0 36 9 com.apple.netsrc kctl 0 0 38 9 com.apple.netsrc kctl 0 0 41 9 com.apple.netsrc kctl 0 0 43 9 com.apple.netsrc kctl 0 0 44 9 com.apple.netsrc kctl 0 0 1 10 com.apple.network.statistics kctl 0 0 2 10 com.apple.network.statistics kctl 0 0 3 10 com.apple.network.statistics kctl 0 0 4 10 com.apple.network.statistics kctl 0 0 1 12 com.apple.network.advisory kctl 0 0 1 13 com.vmware.kext.vmci kctl 0 0 1 14 com.vmware.kext.vmnet kctl 0 0 2 14 com.vmware.kext.vmnet kctl 0 0 3 14 com.vmware.kext.vmnet kctl 0 0 4 14 com.vmware.kext.vmnet kctl 0 0 5 14 com.vmware.kext.vmnet kctl 0 0 6 14 com.vmware.kext.vmnet kctl 0 0 7 14 com.vmware.kext.vmnet kctl 0 0 8 14 com.vmware.kext.vmnet kctl 0 0 9 14 com.vmware.kext.vmnet kctl 0 0 1 15 com.vmware.kext.vmx86 Sample result: [ 200, "OK", { active_conns => [ { foreign_host => "1.2.3.4", foreign_port => 443, local_host => "10.8.0.6", local_port => 54433, proto => "tcp4", recvq => 0, sendq => 0, state => "ESTABLISHED", }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 80, proto => "tcp46", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 88, proto => "tcp6", recvq => 0, sendq => 0, state => "LISTEN", }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => "*", proto => "udp4", recvq => 0, sendq => 0, }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => 52919, proto => "udp6", recvq => 0, sendq => 0, }, { foreign_host => "*", foreign_port => "*", local_host => "*", local_port => "*", proto => "udp46", recvq => 0, sendq => 0, }, {}, {}, { addr => "/var/run/mDNSResponder", address => "4f1eb4c58685585f", conn => "4f1eb4c5868572ef", inode => 0, nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { address => "4f1eb4c5868572ef", conn => "4f1eb4c58685585f", inode => 0, nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { address => "4f1eb4c578f0c92f", conn => "4f1eb4c578f0c2ef", inode => 0, nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, { addr => "/var/run/vmnat.40388", address => "4f1eb4c58bd4e227", conn => 0, inode => "4f1eb4c5891011b7", nextref => 0, proto => "unix", recvq => 0, refs => 0, sendq => 0, type => "stream", }, {}, ], }, ] =head1 FUNCTIONS =head2 parse_netstat Usage: parse_netstat(%args) -> [status, msg, result, meta] Parse the output of Mac OS X "netstat" command. Netstat can be called with C<-n> (show raw IP addresses and port numbers instead of hostnames or port names) or without. It can be called with C<-a> (show all listening and non-listening socket) option or without. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): =over 4 =item * B* => I Output of netstat command. =item * B => I (default: 1) Whether to parse TCP (and TCP6) connections. =item * B => I (default: 1) Whether to parse UDP (and UDP6) connections. =item * B => I (default: 1) Whether to parse Unix socket connections. =back Returns an enveloped result (an array). First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information. Return value: (any) =head1 HOMEPAGE Please visit the project's homepage at L. =head1 SOURCE Source repository is at L. =head1 BUGS Please report any bugs or feature requests on the bugtracker website L When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2017, 2015, 2014, 2012, 2011 by perlancar@cpan.org. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Parse-Netstat-0.14/lib/Parse/Netstat/solaris.pm0000644000175000017500000003247713047245267017063 0ustar s1s1package Parse::Netstat::solaris; use 5.010001; use strict; use warnings; use Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(parse_netstat); our $VERSION = '0.14'; # VERSION our %SPEC; $SPEC{parse_netstat} = { v => 1.1, summary => 'Parse the output of Solaris "netstat" command', description => <<'_', Netstat can be called with `-n` (show raw IP addresses and port numbers instead of hostnames or port names) or without. It can be called with `-a` (show all listening and non-listening socket) option or without. _ args => { output => { summary => 'Output of netstat command', schema => 'str*', req => 1, }, tcp => { summary => 'Whether to parse TCP (and TCP6) connections', schema => [bool => default => 1], }, udp => { summary => 'Whether to parse UDP (and UDP6) connections', schema => [bool => default => 1], }, unix => { summary => 'Whether to parse Unix socket connections', schema => [bool => default => 1], }, }, }; sub parse_netstat { my %args = @_; my $output = $args{output} or return [400, "Please specify output"]; my $tcp = $args{tcp} // 1; my $udp = $args{udp} // 1; my $unix = $args{unix} // 1; my $proto = ''; my @conns; my $i = 0; for my $line (split /^/, $output) { $i++; my %k; if ($line =~ /^UDP: IPv([46])/) { $proto = "udp$1"; } elsif ($line =~ /^TCP: IPv([46])/) { $proto = "tcp$1"; } elsif ($line =~ /^Active UNIX domain sockets/) { $proto = "unix"; } elsif ($proto =~ /udp/ && $udp) { #UDP: IPv4 # Local Address Remote Address State #-------------------- -------------------- ---------- #8.8.17.4.15934 8.8.7.7.53 Connected $line =~ /^\s*$/ and next; # blank line $line =~ /^\s+/ and next; # header $line =~ /^[- ]+$/ and next; # separator $line =~ m!^(?P\S+?)\.(?P\w+)\s+ (?P\S+?)\.(?P\w+|\*)\s+ (?P\S+) \s*$!x or return [400, "Can't parse udp line (#$i): $line"]; %k = %+; $k{proto} = $proto; } elsif ($proto =~ /tcp/ && $tcp) { #TCP: IPv4 # Local Address Remote Address Swind Send-Q Rwind Recv-Q State #-------------------- -------------------- ----- ------ ----- ------ ----------- #8.8.17.4.1337 8.8.213.120.65472 262140 0 1049920 0 ESTABLISHED $line =~ /^\s*$/ and next; # blank line $line =~ /^\s+/ and next; # header $line =~ /^[- ]+$/ and next; # separator $line =~ m!^(?P\S+?)\.(?P\w+)\s+ (?P\S+?)\.(?P\w+|\*)\s+ (?P\d+) \s+ (?P\d+) \s+ (?P\d+) \s+ (?P\d+) \s+ (?P\S+) \s*$!x or return [400, "Can't parse tcp line (#$i): $line"]; %k = %+; $k{proto} = $proto; } elsif ($proto eq 'unix' && $unix) { #Active UNIX domain sockets #Address Type Vnode Conn Local Addr Remote Addr #30258256428 stream-ord 00000000 00000000 $line =~ /^\s*$/ and next; # blank line $line =~ /^Address\s/ and next; # header #$line =~ /^[- ]+$/ and next; # separator $line =~ m!^(?P
[0-9a-f]+)\s+ (?P\S+)\s+ (?P[0-9a-f]+)\s+ (?P[0-9a-f]+)\s+ (?: (?P\S+)\s+ (?: (?P\S+)\s+ )? )? \s*$!x or return [400, "Can't parse unix line (#$i): $line"]; %k = %+; $k{proto} = $proto; } else { # XXX error? because there are no other lines next; } push @conns, \%k; } [200, "OK", {active_conns => \@conns}]; } 1; # ABSTRACT: Parse the output of Solaris "netstat" command __END__ =pod =encoding UTF-8 =head1 NAME Parse::Netstat::solaris - Parse the output of Solaris "netstat" command =head1 VERSION This document describes version 0.14 of Parse::Netstat::solaris (from Perl distribution Parse-Netstat), released on 2017-02-10. =head1 SYNOPSIS use Parse::Netstat qw(parse_netstat); my $res = parse_netstat(output=>join("", `netstat -n`), flavor=>"solaris"); Sample `netstat -n` output: UDP: IPv4 Local Address Remote Address State -------------------- -------------------- ---------- 8.8.17.4.15934 8.8.7.7.53 Connected 127.0.0.1.32859 127.0.0.1.514 Connected 127.0.0.1.32860 127.0.0.1.514 Connected TCP: IPv4 Local Address Remote Address Swind Send-Q Rwind Recv-Q State -------------------- -------------------- ----- ------ ----- ------ ----------- 8.8.17.4.1337 8.8.213.120.65472 262140 0 1049920 0 ESTABLISHED 8.8.17.4.44306 8.8.17.4.111 57304 0 1055220 0 TIME_WAIT 8.8.17.4.44064 8.8.17.4.32774 57260 0 1055220 0 TIME_WAIT 8.8.17.4.44308 8.8.17.4.32774 57260 0 1055220 0 TIME_WAIT 8.8.17.4.44066 8.8.17.4.111 57304 0 1055220 0 TIME_WAIT 8.8.17.4.44310 8.8.17.4.111 57304 0 1055220 0 TIME_WAIT Active UNIX domain sockets Address Type Vnode Conn Local Addr Remote Addr 30258256428 stream-ord 00000000 00000000 30575aa2b38 stream-ord 00000000 00000000 305744acaf8 stream-ord 00000000 00000000 30575aa3b88 stream-ord 00000000 00000000 3013c427d68 stream-ord 00000000 00000000 303b66230f8 stream-ord 00000000 00000000 3042fbbb228 stream-ord 30b59894f40 00000000 /tmp/ssh-MyY25402/agent.25402 30186d43d70 stream-ord 00000000 00000000 303e8e332f8 stream-ord 00000000 00000000 3049e75ece0 stream-ord 302d8344500 00000000 /var/tmp/amavisd-new/abgeber/amavisd.sock 3049e75f250 stream-ord 00000000 00000000 Sample result: [ 200, "OK", { active_conns => [ {}, { foreign_host => "8.8.7.7", foreign_port => 53, local_host => "8.8.17.4", local_port => 15934, proto => "udp4", state => "Connected", }, { foreign_host => "127.0.0.1", foreign_port => 514, local_host => "127.0.0.1", local_port => 32859, proto => "udp4", state => "Connected", }, { foreign_host => "127.0.0.1", foreign_port => 514, local_host => "127.0.0.1", local_port => 32860, proto => "udp4", state => "Connected", }, {}, { foreign_host => "8.8.213.120", foreign_port => 65472, local_host => "8.8.17.4", local_port => 1337, proto => "tcp4", recvq => 0, rwind => 1049920, sendq => 0, state => "ESTABLISHED", swind => 262140, }, { foreign_host => "8.8.17.4", foreign_port => 111, local_host => "8.8.17.4", local_port => 44306, proto => "tcp4", recvq => 0, rwind => 1055220, sendq => 0, state => "TIME_WAIT", swind => 57304, }, { foreign_host => "8.8.17.4", foreign_port => 32774, local_host => "8.8.17.4", local_port => 44064, proto => "tcp4", recvq => 0, rwind => 1055220, sendq => 0, state => "TIME_WAIT", swind => 57260, }, { foreign_host => "8.8.17.4", foreign_port => 32774, local_host => "8.8.17.4", local_port => 44308, proto => "tcp4", recvq => 0, rwind => 1055220, sendq => 0, state => "TIME_WAIT", swind => 57260, }, { foreign_host => "8.8.17.4", foreign_port => 111, local_host => "8.8.17.4", local_port => 44066, proto => "tcp4", recvq => 0, rwind => 1055220, sendq => 0, state => "TIME_WAIT", swind => 57304, }, { foreign_host => "8.8.17.4", foreign_port => 111, local_host => "8.8.17.4", local_port => 44310, proto => "tcp4", recvq => 0, rwind => 1055220, sendq => 0, state => "TIME_WAIT", swind => 57304, }, {}, { address => 30258256428, conn => "00000000", proto => "unix", type => "stream-ord", vnode => "00000000", }, { address => "30575aa2b38", conn => "00000000", proto => "unix", type => "stream-ord", vnode => "00000000", }, { address => "305744acaf8", conn => "00000000", proto => "unix", type => "stream-ord", vnode => "00000000", }, { address => "30575aa3b88", conn => "00000000", proto => "unix", type => "stream-ord", vnode => "00000000", }, { address => "3013c427d68", conn => "00000000", proto => "unix", type => "stream-ord", vnode => "00000000", }, { address => "303b66230f8", conn => "00000000", proto => "unix", type => "stream-ord", vnode => "00000000", }, { address => "3042fbbb228", conn => "00000000", local_addr => "/tmp/ssh-MyY25402/agent.25402", proto => "unix", type => "stream-ord", vnode => "30b59894f40", }, { address => "30186d43d70", conn => "00000000", proto => "unix", type => "stream-ord", vnode => "00000000", }, { address => "303e8e332f8", conn => "00000000", proto => "unix", type => "stream-ord", vnode => "00000000", }, { address => "3049e75ece0", conn => "00000000", local_addr => "/var/tmp/amavisd-new/abgeber/amavisd.sock", proto => "unix", type => "stream-ord", vnode => "302d8344500", }, { address => "3049e75f250", conn => "00000000", proto => "unix", type => "stream-ord", vnode => "00000000", }, ], }, ] =head1 FUNCTIONS =head2 parse_netstat Usage: parse_netstat(%args) -> [status, msg, result, meta] Parse the output of Solaris "netstat" command. Netstat can be called with C<-n> (show raw IP addresses and port numbers instead of hostnames or port names) or without. It can be called with C<-a> (show all listening and non-listening socket) option or without. This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): =over 4 =item * B* => I Output of netstat command. =item * B => I (default: 1) Whether to parse TCP (and TCP6) connections. =item * B => I (default: 1) Whether to parse UDP (and UDP6) connections. =item * B => I (default: 1) Whether to parse Unix socket connections. =back Returns an enveloped result (an array). First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information. Return value: (any) =head1 HOMEPAGE Please visit the project's homepage at L. =head1 SOURCE Source repository is at L. =head1 BUGS Please report any bugs or feature requests on the bugtracker website L When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. =head1 AUTHOR perlancar =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2017, 2015, 2014, 2012, 2011 by perlancar@cpan.org. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Parse-Netstat-0.14/Makefile.PL0000644000175000017500000000310613047245267013544 0ustar s1s1# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.008. use strict; use warnings; use 5.010001; use ExtUtils::MakeMaker; use File::ShareDir::Install; $File::ShareDir::Install::INCLUDE_DOTFILES = 1; $File::ShareDir::Install::INCLUDE_DOTDIRS = 1; install_share dist => "share"; my %WriteMakefileArgs = ( "ABSTRACT" => "Parse the output of \"netstat\" command", "AUTHOR" => "perlancar ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0, "File::ShareDir::Install" => "0.06" }, "DISTNAME" => "Parse-Netstat", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.010001", "NAME" => "Parse::Netstat", "PREREQ_PM" => { "Exporter" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "File::Slurper" => 0, "File::Spec" => 0, "FindBin" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::More" => "0.98" }, "VERSION" => "0.14", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Exporter" => 0, "File::Slurper" => 0, "File::Spec" => 0, "FindBin" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::More" => "0.98", "strict" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); { package MY; use File::ShareDir::Install qw(postamble); } Parse-Netstat-0.14/share/0000755000175000017500000000000013047245267012674 5ustar s1s1Parse-Netstat-0.14/share/netstat-samples/0000755000175000017500000000000013047245267016020 5ustar s1s1Parse-Netstat-0.14/share/netstat-samples/netstat-an-freebsd-9.20000644000175000017500000001045413047245267021743 0ustar s1s1Active Internet connections (including servers) Proto Recv-Q Send-Q Local Address Foreign Address (state) tcp4 0 0 192.168.1.21.610 192.168.1.10.2049 ESTABLISHED tcp4 0 0 192.168.1.21.764 192.168.1.10.2049 CLOSED tcp4 0 0 127.0.0.1.6013 *.* LISTEN tcp6 0 0 ::1.6013 *.* LISTEN tcp4 0 0 127.0.0.1.6012 *.* LISTEN tcp6 0 0 ::1.6012 *.* LISTEN tcp4 0 52 192.168.1.21.22 192.168.1.10.58271 ESTABLISHED tcp4 0 0 127.0.0.1.6011 *.* LISTEN tcp6 0 0 ::1.6011 *.* LISTEN tcp4 0 0 192.168.1.21.22 192.168.1.10.58270 ESTABLISHED tcp4 0 0 192.168.1.21.22 192.168.1.10.58269 ESTABLISHED tcp4 0 0 127.0.0.1.6010 *.* LISTEN tcp6 0 0 ::1.6010 *.* LISTEN tcp4 0 0 192.168.1.21.22 192.168.1.10.58268 ESTABLISHED tcp4 0 0 127.0.0.1.25 *.* LISTEN tcp4 0 0 *.22 *.* LISTEN tcp6 0 0 *.22 *.* LISTEN tcp4 0 0 *.4949 *.* LISTEN tcp4 0 0 *.682 *.* LISTEN tcp6 0 0 *.816 *.* LISTEN tcp4 0 0 *.913 *.* LISTEN tcp6 0 0 *.913 *.* LISTEN tcp4 0 0 *.111 *.* LISTEN tcp6 0 0 *.111 *.* LISTEN udp4 0 0 *.676 *.* udp6 0 0 *.847 *.* udp6 0 0 *.691 *.* udp4 0 0 *.* *.* udp4 0 0 *.913 *.* udp6 0 0 *.913 *.* udp6 0 0 *.* *.* udp4 0 0 *.664 *.* udp4 0 0 *.111 *.* udp6 0 0 *.872 *.* udp6 0 0 *.111 *.* udp4 0 0 *.514 *.* udp6 0 0 *.514 *.* Active UNIX domain sockets Address Type Recv-Q Send-Q Inode Conn Refs Nextref Addr fffffe00029912d0 stream 0 0 fffffe0002d8abd0 0 0 0 /tmp/ssh-zwZwlpzaip/agent.1089 fffffe00029911e0 stream 0 0 0 fffffe0002991000 0 0 fffffe0002991000 stream 0 0 0 fffffe00029911e0 0 0 fffffe0002991960 stream 0 0 0 fffffe0002991e10 0 0 fffffe0002991e10 stream 0 0 0 fffffe0002991960 0 0 fffffe0002991780 stream 0 0 0 fffffe0002991a50 0 0 fffffe0002991a50 stream 0 0 0 fffffe0002991780 0 0 fffffe0002991870 stream 0 0 0 fffffe00029913c0 0 0 fffffe00029913c0 stream 0 0 0 fffffe0002991870 0 0 fffffe0002991690 stream 0 0 fffffe00029c93f0 0 0 0 /var/run/rpcbind.sock fffffe0002991d20 stream 0 0 fffffe000281c9d8 0 0 0 /var/run/devd.pipe fffffe0002992000 dgram 0 0 0 fffffe00029914b0 0 0 fffffe0002991b40 dgram 0 0 0 fffffe00029915a0 0 fffffe00029910f0 fffffe00029910f0 dgram 0 0 0 fffffe00029915a0 0 fffffe0002991c30 fffffe0002991c30 dgram 0 0 0 fffffe00029915a0 0 0 fffffe00029915a0 dgram 0 0 fffffe00029ed1f8 0 fffffe0002991b40 0 /var/run/logpriv fffffe00029914b0 dgram 0 0 fffffe00029ed3f0 0 fffffe0002992000 0 /var/run/log Parse-Netstat-0.14/share/netstat-samples/netstat-anp-win320000644000175000017500000000167513047245267021152 0ustar s1s1Active Connections Proto Local Address Foreign Address State PID TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 988 c:\windows\system32\WS2_32.dll C:\WINDOWS\system32\RPCRT4.dll c:\windows\system32\rpcss.dll C:\WINDOWS\system32\svchost.exe -- unknown component(s) -- [svchost.exe] TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4 [System] TCP 127.0.0.1:1027 0.0.0.0:0 LISTENING 1244 [alg.exe] TCP 192.168.0.104:139 0.0.0.0:0 LISTENING 4 [System] UDP 0.0.0.0:1025 *:* 1120 C:\WINDOWS\system32\mswsock.dll c:\windows\system32\WS2_32.dll c:\windows\system32\DNSAPI.dll c:\windows\system32\dnsrslvr.dll C:\WINDOWS\system32\RPCRT4.dll [svchost.exe] UDP 0.0.0.0:500 *:* 696 [lsass.exe] Parse-Netstat-0.14/share/netstat-samples/netstat-anp-linux0000644000175000017500000000361413047245267021342 0ustar s1s1Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:1027 0.0.0.0:* LISTEN - tcp 0 0 builder.localdomain:1028 *:* LISTEN tcp 0 0 127.0.0.1:58159 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:58160 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:7634 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:631 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1234/program with space tcp 0 0 192.168.0.103:44922 1.2.3.4:143 ESTABLISHED 25820/thunderbird-b tcp6 0 0 ::1:1028 :::* LISTEN - udp 0 0 0.0.0.0:631 0.0.0.0:* - udp 0 0 192.168.0.103:56668 0.0.0.0:* - udp 0 0 192.168.0.103:52753 0.0.0.0:* 8888/opera udp6 0 0 :::42069 :::* - Active UNIX domain sockets (servers and established) Proto RefCnt Flags Type State I-Node PID/Program name Path unix 2 [ ] DGRAM 6906 - /var/spool/postfix/dev/log unix 2 [ ACC ] STREAM LISTENING 650654 - /tmp/orbit-t1/linc-76ff-0-3fc1dd3f2f2 unix 2 [ ACC ] STREAM LISTENING 1121541 16933/kate 123 /tmp/orbit-s1/linc-4225-0-267d23358095e Parse-Netstat-0.14/share/netstat-samples/netstat-n-solaris0000644000175000017500000000341113047245267021331 0ustar s1s1 UDP: IPv4 Local Address Remote Address State -------------------- -------------------- ---------- 8.8.17.4.15934 8.8.7.7.53 Connected 127.0.0.1.32859 127.0.0.1.514 Connected 127.0.0.1.32860 127.0.0.1.514 Connected TCP: IPv4 Local Address Remote Address Swind Send-Q Rwind Recv-Q State -------------------- -------------------- ----- ------ ----- ------ ----------- 8.8.17.4.1337 8.8.213.120.65472 262140 0 1049920 0 ESTABLISHED 8.8.17.4.44306 8.8.17.4.111 57304 0 1055220 0 TIME_WAIT 8.8.17.4.44064 8.8.17.4.32774 57260 0 1055220 0 TIME_WAIT 8.8.17.4.44308 8.8.17.4.32774 57260 0 1055220 0 TIME_WAIT 8.8.17.4.44066 8.8.17.4.111 57304 0 1055220 0 TIME_WAIT 8.8.17.4.44310 8.8.17.4.111 57304 0 1055220 0 TIME_WAIT Active UNIX domain sockets Address Type Vnode Conn Local Addr Remote Addr 30258256428 stream-ord 00000000 00000000 30575aa2b38 stream-ord 00000000 00000000 305744acaf8 stream-ord 00000000 00000000 30575aa3b88 stream-ord 00000000 00000000 3013c427d68 stream-ord 00000000 00000000 303b66230f8 stream-ord 00000000 00000000 3042fbbb228 stream-ord 30b59894f40 00000000 /tmp/ssh-MyY25402/agent.25402 30186d43d70 stream-ord 00000000 00000000 303e8e332f8 stream-ord 00000000 00000000 3049e75ece0 stream-ord 302d8344500 00000000 /var/tmp/amavisd-new/abgeber/amavisd.sock 3049e75f250 stream-ord 00000000 00000000 Parse-Netstat-0.14/share/netstat-samples/netstat-an-darwin0000644000175000017500000001632313047245267021310 0ustar s1s1Active Internet connections (including servers) Proto Recv-Q Send-Q Local Address Foreign Address (state) tcp4 0 0 10.8.0.6.54433 1.2.3.4.443 ESTABLISHED tcp46 0 0 *.80 *.* LISTEN tcp6 0 0 *.88 *.* LISTEN udp4 0 0 *.* *.* udp6 0 0 *.52919 *.* udp46 0 0 *.* *.* Active Multipath Internet connections Proto/ID Flags Local Address Foreign Address (state) Active LOCAL (UNIX) domain sockets Address Type Recv-Q Send-Q Inode Conn Refs Nextref Addr 4f1eb4c58685585f stream 0 0 0 4f1eb4c5868572ef 0 0 /var/run/mDNSResponder 4f1eb4c5868572ef stream 0 0 0 4f1eb4c58685585f 0 0 4f1eb4c578f0c92f stream 0 0 0 4f1eb4c578f0c2ef 0 0 4f1eb4c58bd4e227 stream 0 0 4f1eb4c5891011b7 0 0 0 /var/run/vmnat.40388 Registered kernel control modules id flags pcbcount rcvbuf sndbuf name 1 9 0 131072 131072 com.apple.flow-divert 2 1 1 16384 2048 com.apple.nke.sockwall 3 9 0 524288 524288 com.apple.content-filter 4 9 0 8192 2048 com.apple.packet-mangler 5 1 3 65536 65536 com.apple.net.necp_control 6 1 10 65536 65536 com.apple.net.netagent 7 9 5 524288 524288 com.apple.net.utun_control 8 1 0 65536 65536 com.apple.net.ipsec_control 9 0 39 8192 2048 com.apple.netsrc a 18 4 8192 2048 com.apple.network.statistics b 5 0 8192 2048 com.apple.network.tcp_ccdebug c 1 1 8192 2048 com.apple.network.advisory d 1 1 8192 2048 com.vmware.kext.vmci e 1 9 229376 229376 com.vmware.kext.vmnet f 1 168 8192 2048 com.vmware.kext.vmx86 Active kernel event sockets Proto Recv-Q Send-Q vendor class subcla kevt 0 0 1 1 11 kevt 0 0 1 1 7 kevt 0 0 1 1 1 kevt 0 0 1 4 0 kevt 0 0 1 6 1 kevt 0 0 1 6 1 kevt 0 0 1 1 2 kevt 0 0 1 6 1 kevt 0 0 1 6 1 kevt 0 0 1 1 10 kevt 0 0 1001 5 11 kevt 0 0 1 6 1 kevt 0 0 1 6 1 kevt 0 0 1 6 1 kevt 0 0 1 6 1 kevt 0 0 1 6 1 kevt 0 0 1 6 1 kevt 0 0 1 1 2 kevt 0 0 1 1 2 kevt 0 0 1 6 1 kevt 0 0 1 1 0 Active kernel control sockets Proto Recv-Q Send-Q unit id name kctl 0 0 1 2 com.apple.nke.sockwall kctl 0 0 1 5 com.apple.net.necp_control kctl 0 0 2 5 com.apple.net.necp_control kctl 0 0 3 5 com.apple.net.necp_control kctl 0 0 1 6 com.apple.net.netagent kctl 0 0 2 6 com.apple.net.netagent kctl 0 0 3 6 com.apple.net.netagent kctl 0 0 4 6 com.apple.net.netagent kctl 0 0 5 6 com.apple.net.netagent kctl 0 0 6 6 com.apple.net.netagent kctl 0 0 7 6 com.apple.net.netagent kctl 0 0 8 6 com.apple.net.netagent kctl 0 0 10 6 com.apple.net.netagent kctl 0 0 11 6 com.apple.net.netagent kctl 0 0 1 7 com.apple.net.utun_control kctl 0 0 2 7 com.apple.net.utun_control kctl 0 0 3 7 com.apple.net.utun_control kctl 0 0 4 7 com.apple.net.utun_control kctl 0 0 5 7 com.apple.net.utun_control kctl 0 0 1 9 com.apple.netsrc kctl 0 0 2 9 com.apple.netsrc kctl 0 0 3 9 com.apple.netsrc kctl 0 0 4 9 com.apple.netsrc kctl 0 0 5 9 com.apple.netsrc kctl 0 0 6 9 com.apple.netsrc kctl 0 0 7 9 com.apple.netsrc kctl 0 0 9 9 com.apple.netsrc kctl 0 0 10 9 com.apple.netsrc kctl 0 0 11 9 com.apple.netsrc kctl 0 0 12 9 com.apple.netsrc kctl 0 0 13 9 com.apple.netsrc kctl 0 0 14 9 com.apple.netsrc kctl 0 0 15 9 com.apple.netsrc kctl 0 0 16 9 com.apple.netsrc kctl 0 0 17 9 com.apple.netsrc kctl 0 0 18 9 com.apple.netsrc kctl 0 0 19 9 com.apple.netsrc kctl 0 0 20 9 com.apple.netsrc kctl 0 0 21 9 com.apple.netsrc kctl 0 0 22 9 com.apple.netsrc kctl 0 0 23 9 com.apple.netsrc kctl 0 0 24 9 com.apple.netsrc kctl 0 0 25 9 com.apple.netsrc kctl 0 0 26 9 com.apple.netsrc kctl 0 0 27 9 com.apple.netsrc kctl 0 0 28 9 com.apple.netsrc kctl 0 0 29 9 com.apple.netsrc kctl 0 0 30 9 com.apple.netsrc kctl 0 0 31 9 com.apple.netsrc kctl 0 0 32 9 com.apple.netsrc kctl 0 0 33 9 com.apple.netsrc kctl 0 0 34 9 com.apple.netsrc kctl 0 0 35 9 com.apple.netsrc kctl 0 0 36 9 com.apple.netsrc kctl 0 0 38 9 com.apple.netsrc kctl 0 0 41 9 com.apple.netsrc kctl 0 0 43 9 com.apple.netsrc kctl 0 0 44 9 com.apple.netsrc kctl 0 0 1 10 com.apple.network.statistics kctl 0 0 2 10 com.apple.network.statistics kctl 0 0 3 10 com.apple.network.statistics kctl 0 0 4 10 com.apple.network.statistics kctl 0 0 1 12 com.apple.network.advisory kctl 0 0 1 13 com.vmware.kext.vmci kctl 0 0 1 14 com.vmware.kext.vmnet kctl 0 0 2 14 com.vmware.kext.vmnet kctl 0 0 3 14 com.vmware.kext.vmnet kctl 0 0 4 14 com.vmware.kext.vmnet kctl 0 0 5 14 com.vmware.kext.vmnet kctl 0 0 6 14 com.vmware.kext.vmnet kctl 0 0 7 14 com.vmware.kext.vmnet kctl 0 0 8 14 com.vmware.kext.vmnet kctl 0 0 9 14 com.vmware.kext.vmnet kctl 0 0 1 15 com.vmware.kext.vmx86 Parse-Netstat-0.14/share/netstat-samples/netstat-an-freebsd-10.10000644000175000017500000001161613047245267022013 0ustar s1s1Active Internet connections (including servers) Proto Recv-Q Send-Q Local Address Foreign Address (state) tcp4 0 0 192.168.1.33.780 192.168.1.10.2049 CLOSE_WAIT tcp4 0 0 192.168.1.33.632 192.168.1.10.2049 CLOSED tcp4 0 0 127.0.0.1.6012 *.* LISTEN tcp6 0 0 ::1.6012 *.* LISTEN tcp4 0 52 192.168.1.33.22 192.168.1.10.41487 ESTABLISHED tcp4 0 0 127.0.0.1.6011 *.* LISTEN tcp6 0 0 ::1.6011 *.* LISTEN tcp4 0 0 192.168.1.33.22 192.168.1.10.61223 ESTABLISHED tcp4 0 0 127.0.0.1.6010 *.* LISTEN tcp6 0 0 ::1.6010 *.* LISTEN tcp4 0 0 192.168.1.33.22 192.168.1.10.18499 ESTABLISHED tcp4 0 0 192.168.1.33.22 192.168.1.10.30712 ESTABLISHED tcp4 0 0 127.0.0.1.25 *.* LISTEN tcp4 0 0 *.22 *.* LISTEN tcp6 0 0 *.22 *.* LISTEN tcp4 0 0 *.4949 *.* LISTEN tcp6 0 0 *.4949 *.* LISTEN tcp4 0 0 *.667 *.* LISTEN tcp6 0 0 *.896 *.* LISTEN tcp4 0 0 *.879 *.* LISTEN tcp6 0 0 *.879 *.* LISTEN tcp4 0 0 *.111 *.* LISTEN tcp6 0 0 *.111 *.* LISTEN udp4 0 0 *.682 *.* udp6 0 0 *.726 *.* udp6 0 0 *.948 *.* udp4 0 0 *.* *.* udp4 0 0 *.879 *.* udp6 0 0 *.879 *.* udp6 0 0 *.* *.* udp4 0 0 *.755 *.* udp4 0 0 *.111 *.* udp6 0 0 *.932 *.* udp6 0 0 *.111 *.* udp4 0 0 *.514 *.* udp6 0 0 *.514 *.* Active UNIX domain sockets Address Type Recv-Q Send-Q Inode Conn Refs Nextref Addr fffff80057aa11e0 stream 0 0 0 0 0 0 fffff80057aa12d0 stream 0 0 0 0 0 0 fffff8001b0bc5a0 stream 0 0 fffff80011150938 0 0 0 /tmp/ssh-52dQiqRzC4/agent.35116 fffff8001b0bc780 stream 0 0 0 fffff8001b0bcc30 0 0 fffff8001b0bcc30 stream 0 0 0 fffff8001b0bc780 0 0 fffff80002ad85a0 stream 0 0 fffff80030dfd760 0 0 0 /tmp/ssh-ZPrtis6Qgb/agent.21969 fffff8001b0bc2d0 stream 0 0 0 fffff80057aa10f0 0 0 fffff80057aa10f0 stream 0 0 0 fffff8001b0bc2d0 0 0 fffff80002ad82d0 stream 0 0 0 fffff80002ad84b0 0 0 fffff80002ad84b0 stream 0 0 0 fffff80002ad82d0 0 0 fffff800028b3960 stream 0 0 fffff800354e3588 0 0 0 /var/run/dbus/system_bus_socket fffff80002ad8a50 stream 0 0 0 fffff80002ad8c30 0 0 fffff80002ad8c30 stream 0 0 0 fffff80002ad8a50 0 0 fffff80002ad91e0 stream 0 0 fffff80002f5b1d8 0 0 0 /tmp/ssh-EXvnWwxbk4/agent.750 fffff80002ad93c0 stream 0 0 0 fffff80002ad90f0 0 0 fffff80002ad90f0 stream 0 0 0 fffff80002ad93c0 0 0 fffff80002ad9780 stream 0 0 fffff800029db000 0 0 0 /var/run/rpcbind.sock fffff80002ad9b40 stream 0 0 fffff800029a4000 0 0 0 /var/run/devd.pipe fffff80002ad80f0 dgram 0 0 0 fffff80002ad9960 0 fffff80002ad94b0 fffff80002ad9000 dgram 0 0 0 fffff80002ad9870 0 fffff80002ad92d0 fffff80002ad94b0 dgram 0 0 0 fffff80002ad9960 0 0 fffff80002ad92d0 dgram 0 0 0 fffff80002ad9870 0 fffff80002ad9690 fffff80002ad9690 dgram 0 0 0 fffff80002ad9870 0 fffff80002ad95a0 fffff80002ad95a0 dgram 0 0 0 fffff80002ad9870 0 0 fffff80002ad9870 dgram 0 0 fffff80002b3e938 0 fffff80002ad9000 0 /var/run/logpriv fffff80002ad9960 dgram 0 0 fffff80002b3eb10 0 fffff80002ad80f0 0 /var/run/log fffff80002ad9a50 seqpac 0 0 fffff80002947ce8 0 0 0 /var/run/devd.seqpacket.pipe Parse-Netstat-0.14/Changes0000644000175000017500000000405613047245267013072 0ustar s1s10.14 2017-02-10 (PERLANCAR) - Split Parse::Netstat::darwin. 0.13 2017-02-09 (PERLANCAR) - Add support for freebsd (Mac flavor), thanks LBE [RT#119959]. 0.12 2015-09-03 (PERLANCAR) - No functional changes. - [dist] Move spec prereqs from RuntimeRequires to DevelopRecommends to reduce deps but still allow indicating spec requirement. 0.11 2014-12-02 (PERLANCAR) - No functional changes. - Tweak Rinci metadata (add negative summary for CLI). 0.10 2014-12-01 (PERLANCAR) - Refactor into per-flavor modules (Parse::Netstat::{linux,freebsd,win32}). - Add support for Solaris flavor of netstat [RT#100618]. - Include sample data and output in each flavor module's POD. - Split CLI bin/parse-netstat to its own distribution App-ParseNetstat to keep this distribution's dependencies small. 0.09 2014-11-30 (PERLANCAR) - Parse FreeBSD (9.2, 10.1)'s output [RT#100607]. 0.08 2014-11-09 (PERLANCAR) - No functional changes. - Switch cli scripts to using Perinci::CmdLine::Lite. 0.07 2014-08-16 (SHARYANTO) - Happy 19th CPAN Day! - [build] CLI scripts are now generated automatically using Dist::Zilla::Plugin::ScriptFromFunc. The plugin is still at 0.01 so the generated script is not as polished as it should be. Stay tuned. 0.06 2014-02-07 (SHARYANTO) - Add support for parsing output of Windows netstat (thanks Chris Rettger). - Add command-line script: parse-netstat-win. 0.05 2014-02-07 (SHARYANTO) - Fix parsing UDP line (state was not parsed). - Add command-line script: parse-netstat. - Minor updates and tweaks. 0.04 2012-03-23 (SHARYANTO) - No functional changes. Replace Sub::Spec with Rinci. 0.03 2011-09-29 (SHARYANTO) - Fix parsing: allow whitespace in 'program' field. 0.02 2011-09-29 (SHARYANTO) - No functional changes. Add sample result in Synopsis. 0.01 2011-09-29 (SHARYANTO) - First release. Parse-Netstat-0.14/dist.ini0000644000175000017500000000046013047245267013236 0ustar s1s1version=0.14 name=Parse-Netstat [InsertCodeResult] [InsertExample] [@Author::PERLANCAR] :version=0.55 [Prereqs / TestRequires] File::Slurper=0 FindBin=0 Test::More=0.98 [Prereqs] perl=5.010001 strict=0 warnings=0 Exporter=0 [Prereqs / DevelopX_spec] -phase=develop -relationship=x_spec Rinci=1.1.0 Parse-Netstat-0.14/LICENSE0000644000175000017500000004400713047245267012604 0ustar s1s1This software is copyright (c) 2017, 2015, 2014, 2012, 2011 by perlancar@cpan.org. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2017, 2015, 2014, 2012, 2011 by perlancar@cpan.org. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2017, 2015, 2014, 2012, 2011 by perlancar@cpan.org. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Parse-Netstat-0.14/t/0000755000175000017500000000000013047245267012035 5ustar s1s1Parse-Netstat-0.14/t/00-compile.t0000644000175000017500000000256513047245267014077 0ustar s1s1use 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.054 use Test::More; plan tests => 6 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'Parse/Netstat.pm', 'Parse/Netstat/darwin.pm', 'Parse/Netstat/freebsd.pm', 'Parse/Netstat/linux.pm', 'Parse/Netstat/solaris.pm', 'Parse/Netstat/win32.pm' ); # no fake home requested my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib'; use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ and not eval { require blib; blib->VERSION('1.01') }; if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING}; Parse-Netstat-0.14/t/01-basics.t0000644000175000017500000001057513047245267013714 0ustar s1s1#!perl use 5.010; use strict; use warnings; use FindBin '$Bin'; use File::Slurper qw(read_text); use Parse::Netstat qw(parse_netstat); use Test::More 0.98; sub test_parse { my (%args) = @_; my $name = $args{name}; my $data = $args{data}; subtest $name => sub { my $res; my $eval_err; eval { my %fargs = (output => $data, %{$args{args} // {}}); $res = parse_netstat(%fargs); }; $eval_err = $@; if ($args{dies}) { ok($eval_err, "dies"); } else { ok(!$eval_err, "doesn't die") or diag $eval_err; } if (exists $args{status}) { is($res->[0], $args{status}, "result") or diag explain $res; } if ($res->[0] == 200) { my $parsed = $res->[2]; my $conns = $parsed->{active_conns}; my $num_tcp = grep {($_->{proto} // '') =~ /tcp[46]?/} @$conns; my $num_udp = grep {($_->{proto} // '') =~ /udp[46]?/} @$conns; my $num_unix = grep {($_->{proto} // '') =~ /unix/} @$conns; if (defined $args{num_tcp}) { is($num_tcp, $args{num_tcp}, "num_tcp=$args{num_tcp}"); } if (defined $args{num_udp}) { is($num_udp, $args{num_udp}, "num_udp=$args{num_udp}"); } if (defined $args{num_unix}) { is($num_unix, $args{num_unix}, "num_unix=$args{num_unix}"); } } else { ok(0, "result is not 200 ($res->[0])"); diag explain $res; } if ($args{post_parse}) { $args{post_parse}->($res); } }; } subtest "linux" => sub { my $data = read_text("$Bin/../share/netstat-samples/netstat-anp-linux"); test_parse(name=>'all' , data=>$data, args=>{flavor=>"linux"}, num_tcp=>10, num_udp=>4, num_unix=>3); test_parse(name=>'no tcp' , data=>$data, args=>{flavor=>"linux", tcp=>0}, num_tcp=>0 , num_udp=>4, num_unix=>3); test_parse(name=>'no udp' , data=>$data, args=>{flavor=>"linux", udp=>0}, num_tcp=>10, num_udp=>0, num_unix=>3); test_parse(name=>'no unix', data=>$data, args=>{flavor=>"linux", unix=>0}, num_tcp=>10, num_udp=>4, num_unix=>0); }; subtest "freebsd" => sub { my $data = read_text("$Bin/../share/netstat-samples/netstat-an-freebsd-10.1"); test_parse(name=>'all' , args=>{flavor=>"freebsd"}, data=>$data, num_tcp=>23, num_udp=>13, num_unix=>27); test_parse(name=>'no tcp' , args=>{flavor=>"freebsd", tcp=>0}, data=>$data, num_tcp=> 0, num_udp=>13, num_unix=>27); test_parse(name=>'no udp' , args=>{flavor=>"freebsd", udp=>0}, data=>$data, num_tcp=>23, num_udp=> 0, num_unix=>27); test_parse(name=>'no unix', args=>{flavor=>"freebsd", unix=>0}, data=>$data, num_tcp=>23, num_udp=>13, num_unix=> 0); }; subtest "darwin" => sub { my $data = read_text("$Bin/../share/netstat-samples/netstat-an-darwin"); test_parse(name=>'all' , args=>{flavor=>"darwin"}, data=>$data, num_tcp=>3, num_udp=>3, num_unix=>4); test_parse(name=>'no tcp' , args=>{flavor=>"darwin", tcp=>0}, data=>$data, num_tcp=>0, num_udp=>3, num_unix=>4); test_parse(name=>'no udp' , args=>{flavor=>"darwin", udp=>0}, data=>$data, num_tcp=>3, num_udp=>0, num_unix=>4); test_parse(name=>'no unix', args=>{flavor=>"darwin", unix=>0}, data=>$data, num_tcp=>3, num_udp=>3, num_unix=>0); }; subtest "solaris" => sub { my $data = read_text("$Bin/../share/netstat-samples/netstat-n-solaris"); test_parse(name=>'all' , args=>{flavor=>"solaris"}, data=>$data, num_tcp=>6, num_udp=>3, num_unix=>11); test_parse(name=>'no tcp' , args=>{flavor=>"solaris", tcp=>0}, data=>$data, num_tcp=>0, num_udp=>3, num_unix=>11); test_parse(name=>'no udp' , args=>{flavor=>"solaris", udp=>0}, data=>$data, num_tcp=>6, num_udp=>0, num_unix=>11); test_parse(name=>'no unix', args=>{flavor=>"solaris", unix=>0}, data=>$data, num_tcp=>6, num_udp=>3, num_unix=> 0); }; subtest "win32" => sub { my $data = read_text("$Bin/../share/netstat-samples/netstat-anp-win32"); test_parse(name=>'all' , args=>{flavor=>"win32"}, data=>$data, num_tcp=>4, num_udp=>2); test_parse(name=>'no tcp', args=>{flavor=>"win32", tcp=>0}, data=>$data, num_tcp=>0, num_udp=>2); test_parse(name=>'no udp', args=>{flavor=>"win32", udp=>0}, data=>$data, num_tcp=>4, num_udp=>0); }; DONE_TESTING: done_testing(); Parse-Netstat-0.14/t/release-rinci.t0000644000175000017500000000057313047245267014751 0ustar s1s1#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { print qq{1..0 # SKIP these tests are for release candidate testing\n}; exit } } # This file was automatically generated by Dist::Zilla::Plugin::Test::Rinci. use Test::More; eval "use Test::Rinci 0.01"; plan skip_all => "Test::Rinci 0.01 required for testing Rinci metadata" if $@; metadata_in_all_modules_ok(); Parse-Netstat-0.14/t/author-pod-syntax.t0000644000175000017500000000045413047245267015633 0ustar s1s1#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); Parse-Netstat-0.14/t/author-pod-coverage.t0000644000175000017500000000053613047245267016101 0ustar s1s1#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } # This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. use Test::Pod::Coverage 1.08; use Pod::Coverage::TrustPod; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); Parse-Netstat-0.14/weaver.ini0000644000175000017500000000002513047245267013561 0ustar s1s1[@Author::PERLANCAR] Parse-Netstat-0.14/MANIFEST0000644000175000017500000000123513047245267012724 0ustar s1s1# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.008. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README dist.ini lib/Parse/Netstat.pm lib/Parse/Netstat/darwin.pm lib/Parse/Netstat/freebsd.pm lib/Parse/Netstat/linux.pm lib/Parse/Netstat/solaris.pm lib/Parse/Netstat/win32.pm share/netstat-samples/netstat-an-darwin share/netstat-samples/netstat-an-freebsd-10.1 share/netstat-samples/netstat-an-freebsd-9.2 share/netstat-samples/netstat-anp-linux share/netstat-samples/netstat-anp-win32 share/netstat-samples/netstat-n-solaris t/00-compile.t t/01-basics.t t/author-pod-coverage.t t/author-pod-syntax.t t/release-rinci.t weaver.ini Parse-Netstat-0.14/META.json0000644000175000017500000004662213047245267013225 0ustar s1s1{ "abstract" : "Parse the output of \"netstat\" command", "author" : [ "perlancar " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.008, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Parse-Netstat", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0", "File::ShareDir::Install" : "0.06" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08", "Test::Rinci" : "0.01" }, "x_spec" : { "Rinci" : "v1.1.0" } }, "runtime" : { "requires" : { "Exporter" : "0", "perl" : "5.010001", "strict" : "0", "warnings" : "0" } }, "test" : { "requires" : { "File::Slurper" : "0", "File::Spec" : "0", "FindBin" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Test::More" : "0.98" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=Parse-Netstat" }, "homepage" : "https://metacpan.org/release/Parse-Netstat", "repository" : { "type" : "git", "url" : "git://github.com/perlancar/perl-Parse-Netstat.git", "web" : "https://github.com/perlancar/perl-Parse-Netstat" } }, "version" : "0.14", "x_Dist_Zilla" : { "perl" : { "version" : "5.024000" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::InsertCodeResult", "name" : "InsertCodeResult", "version" : "0.04" }, { "class" : "Dist::Zilla::Plugin::InsertExample", "name" : "InsertExample", "version" : "0.06" }, { "class" : "Dist::Zilla::Plugin::GatherDir", "config" : { "Dist::Zilla::Plugin::GatherDir" : { "exclude_filename" : [], "exclude_match" : [], "follow_symlinks" : 0, "include_dotfiles" : 0, "prefix" : "", "prune_directory" : [], "root" : "." } }, "name" : "@Author::PERLANCAR/@Filter/GatherDir", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@Author::PERLANCAR/@Filter/PruneCruft", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@Author::PERLANCAR/@Filter/ManifestSkip", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@Author::PERLANCAR/@Filter/MetaYAML", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@Author::PERLANCAR/@Filter/License", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::PodCoverageTests", "name" : "@Author::PERLANCAR/@Filter/PodCoverageTests", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@Author::PERLANCAR/@Filter/PodSyntaxTests", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::ExtraTests", "name" : "@Author::PERLANCAR/@Filter/ExtraTests", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@Author::PERLANCAR/@Filter/ExecDir", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@Author::PERLANCAR/@Filter/ShareDir", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@Author::PERLANCAR/@Filter/MakeMaker", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@Author::PERLANCAR/@Filter/Manifest", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@Author::PERLANCAR/@Filter/ConfirmRelease", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::PERLANCAR::BeforeBuild", "name" : "@Author::PERLANCAR/PERLANCAR::BeforeBuild", "version" : "0.55" }, { "class" : "Dist::Zilla::Plugin::Rinci::AbstractFromMeta", "name" : "@Author::PERLANCAR/Rinci::AbstractFromMeta", "version" : "0.09" }, { "class" : "Dist::Zilla::Plugin::PodnameFromFilename", "name" : "@Author::PERLANCAR/PodnameFromFilename", "version" : "0.01" }, { "class" : "Dist::Zilla::Plugin::PERLANCAR::EnsurePrereqToSpec", "name" : "@Author::PERLANCAR/PERLANCAR::EnsurePrereqToSpec", "version" : "0.04" }, { "class" : "Dist::Zilla::Plugin::PERLANCAR::MetaResources", "name" : "@Author::PERLANCAR/PERLANCAR::MetaResources", "version" : "0.03" }, { "class" : "Dist::Zilla::Plugin::CheckChangeLog", "name" : "@Author::PERLANCAR/CheckChangeLog", "version" : "0.02" }, { "class" : "Dist::Zilla::Plugin::CheckMetaResources", "name" : "@Author::PERLANCAR/CheckMetaResources", "version" : "0.001" }, { "class" : "Dist::Zilla::Plugin::CopyrightYearFromGit", "name" : "@Author::PERLANCAR/CopyrightYearFromGit", "version" : "0.002" }, { "class" : "Dist::Zilla::Plugin::IfBuilt", "name" : "@Author::PERLANCAR/IfBuilt", "version" : "0.03" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@Author::PERLANCAR/MetaJSON", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@Author::PERLANCAR/MetaConfig", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::GenShellCompletion", "name" : "@Author::PERLANCAR/GenShellCompletion", "version" : "0.11" }, { "class" : "Dist::Zilla::Plugin::Authority", "name" : "@Author::PERLANCAR/Authority", "version" : "1.009" }, { "class" : "Dist::Zilla::Plugin::OurDate", "name" : "@Author::PERLANCAR/OurDate", "version" : "0.03" }, { "class" : "Dist::Zilla::Plugin::OurDist", "name" : "@Author::PERLANCAR/OurDist", "version" : "0.02" }, { "class" : "Dist::Zilla::Plugin::PERLANCAR::OurPkgVersion", "name" : "@Author::PERLANCAR/PERLANCAR::OurPkgVersion", "version" : "0.04" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", "config" : { "Dist::Zilla::Plugin::PodWeaver" : { "finder" : [ ":InstallModules", ":ExecFiles" ], "plugins" : [ { "class" : "Pod::Weaver::Plugin::EnsurePod5", "name" : "@CorePrep/EnsurePod5", "version" : "4.013" }, { "class" : "Pod::Weaver::Plugin::H1Nester", "name" : "@CorePrep/H1Nester", "version" : "4.013" }, { "class" : "Pod::Weaver::Section::Name", "name" : "@Author::PERLANCAR/Name", "version" : "4.013" }, { "class" : "Pod::Weaver::Section::Version", "name" : "@Author::PERLANCAR/Version", "version" : "4.013" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Author::PERLANCAR/prelude", "version" : "4.013" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "SYNOPSIS", "version" : "4.013" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "DESCRIPTION", "version" : "4.013" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "OVERVIEW", "version" : "4.013" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "ATTRIBUTES", "version" : "4.013" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "METHODS", "version" : "4.013" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "FUNCTIONS", "version" : "4.013" }, { "class" : "Pod::Weaver::Section::Leftovers", "name" : "@Author::PERLANCAR/Leftovers", "version" : "4.013" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Author::PERLANCAR/postlude", "version" : "4.013" }, { "class" : "Pod::Weaver::Section::Completion::GetoptLongComplete", "name" : "@Author::PERLANCAR/Completion::GetoptLongComplete", "version" : "0.08" }, { "class" : "Pod::Weaver::Section::Completion::GetoptLongSubcommand", "name" : "@Author::PERLANCAR/Completion::GetoptLongSubcommand", "version" : "0.04" }, { "class" : "Pod::Weaver::Section::Completion::GetoptLongMore", "name" : "@Author::PERLANCAR/Completion::GetoptLongMore", "version" : "0.001" }, { "class" : "Pod::Weaver::Section::Homepage::DefaultCPAN", "name" : "@Author::PERLANCAR/Homepage::DefaultCPAN", "version" : "0.05" }, { "class" : "Pod::Weaver::Section::Source::DefaultGitHub", "name" : "@Author::PERLANCAR/Source::DefaultGitHub", "version" : "0.07" }, { "class" : "Pod::Weaver::Section::Bugs::DefaultRT", "name" : "@Author::PERLANCAR/Bugs::DefaultRT", "version" : "0.06" }, { "class" : "Pod::Weaver::Section::Authors", "name" : "@Author::PERLANCAR/Authors", "version" : "4.013" }, { "class" : "Pod::Weaver::Section::Legal", "name" : "@Author::PERLANCAR/Legal", "version" : "4.013" }, { "class" : "Pod::Weaver::Plugin::Rinci", "name" : "@Author::PERLANCAR/Rinci", "version" : "0.76" }, { "class" : "Pod::Weaver::Plugin::AppendPrepend", "name" : "@Author::PERLANCAR/AppendPrepend", "version" : "0.01" }, { "class" : "Pod::Weaver::Plugin::EnsureUniqueSections", "name" : "@Author::PERLANCAR/EnsureUniqueSections", "version" : "0.121550" }, { "class" : "Pod::Weaver::Plugin::SingleEncoding", "name" : "@Author::PERLANCAR/SingleEncoding", "version" : "4.013" }, { "class" : "Pod::Weaver::Plugin::PERLANCAR::SortSections", "name" : "@Author::PERLANCAR/PERLANCAR::SortSections", "version" : "0.05" } ] } }, "name" : "@Author::PERLANCAR/PodWeaver", "version" : "4.008" }, { "class" : "Dist::Zilla::Plugin::PruneFiles", "name" : "@Author::PERLANCAR/PruneFiles", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::ReadmeFromPod", "name" : "@Author::PERLANCAR/ReadmeFromPod", "version" : "0.35" }, { "class" : "Dist::Zilla::Plugin::Rinci::AddPrereqs", "name" : "@Author::PERLANCAR/Rinci::AddPrereqs", "version" : "0.13" }, { "class" : "Dist::Zilla::Plugin::Rinci::AddToDb", "name" : "@Author::PERLANCAR/Rinci::AddToDb", "version" : "0.01" }, { "class" : "Dist::Zilla::Plugin::Rinci::Validate", "name" : "@Author::PERLANCAR/Rinci::Validate", "version" : "0.23" }, { "class" : "Dist::Zilla::Plugin::SetScriptShebang", "name" : "@Author::PERLANCAR/SetScriptShebang", "version" : "0.01" }, { "class" : "Dist::Zilla::Plugin::Test::Compile", "config" : { "Dist::Zilla::Plugin::Test::Compile" : { "bail_out_on_fail" : 0, "fail_on_warning" : "author", "fake_home" : 0, "filename" : "t/00-compile.t", "module_finder" : [ ":InstallModules" ], "needs_display" : 0, "phase" : "test", "script_finder" : [ ":PerlExecFiles" ], "skips" : [] } }, "name" : "@Author::PERLANCAR/Test::Compile", "version" : "2.054" }, { "class" : "Dist::Zilla::Plugin::Test::Rinci", "name" : "@Author::PERLANCAR/Test::Rinci", "version" : "0.03" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN::WWWPAUSESimple", "name" : "@Author::PERLANCAR/UploadToCPAN::WWWPAUSESimple", "version" : "0.04" }, { "class" : "Dist::Zilla::Plugin::EnsureSQLSchemaVersionedTest", "name" : "@Author::PERLANCAR/EnsureSQLSchemaVersionedTest", "version" : "0.02" }, { "class" : "Dist::Zilla::Plugin::Acme::CPANLists::Blacklist", "name" : "@Author::PERLANCAR/Acme::CPANLists::Blacklist", "version" : "0.02" }, { "class" : "Dist::Zilla::Plugin::Prereqs::EnsureVersion", "name" : "@Author::PERLANCAR/Prereqs::EnsureVersion", "version" : "0.01" }, { "class" : "Dist::Zilla::Plugin::Prereqs::CheckCircular", "name" : "@Author::PERLANCAR/Prereqs::CheckCircular", "version" : "0.003" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "TestRequires", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "runtime", "type" : "requires" } }, "name" : "Prereqs", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "develop", "type" : "x_spec" } }, "name" : "DevelopX_spec", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExtraTestFiles", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":PerlExecFiles", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "6.008" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "6.008" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : 0 }, "version" : "6.008" } }, "x_authority" : "cpan:PERLANCAR", "x_serialization_backend" : "Cpanel::JSON::XS version 3.0213" } Parse-Netstat-0.14/META.yml0000644000175000017500000003157313047245267013054 0ustar s1s1--- abstract: 'Parse the output of "netstat" command' author: - 'perlancar ' build_requires: File::Slurper: '0' File::Spec: '0' FindBin: '0' IO::Handle: '0' IPC::Open3: '0' Test::More: '0.98' configure_requires: ExtUtils::MakeMaker: '0' File::ShareDir::Install: '0.06' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.008, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Parse-Netstat requires: Exporter: '0' perl: '5.010001' strict: '0' warnings: '0' resources: bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Parse-Netstat homepage: https://metacpan.org/release/Parse-Netstat repository: git://github.com/perlancar/perl-Parse-Netstat.git version: '0.14' x_Dist_Zilla: perl: version: '5.024000' plugins: - class: Dist::Zilla::Plugin::InsertCodeResult name: InsertCodeResult version: '0.04' - class: Dist::Zilla::Plugin::InsertExample name: InsertExample version: '0.06' - class: Dist::Zilla::Plugin::GatherDir config: Dist::Zilla::Plugin::GatherDir: exclude_filename: [] exclude_match: [] follow_symlinks: 0 include_dotfiles: 0 prefix: '' prune_directory: [] root: . name: '@Author::PERLANCAR/@Filter/GatherDir' version: '6.008' - class: Dist::Zilla::Plugin::PruneCruft name: '@Author::PERLANCAR/@Filter/PruneCruft' version: '6.008' - class: Dist::Zilla::Plugin::ManifestSkip name: '@Author::PERLANCAR/@Filter/ManifestSkip' version: '6.008' - class: Dist::Zilla::Plugin::MetaYAML name: '@Author::PERLANCAR/@Filter/MetaYAML' version: '6.008' - class: Dist::Zilla::Plugin::License name: '@Author::PERLANCAR/@Filter/License' version: '6.008' - class: Dist::Zilla::Plugin::PodCoverageTests name: '@Author::PERLANCAR/@Filter/PodCoverageTests' version: '6.008' - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@Author::PERLANCAR/@Filter/PodSyntaxTests' version: '6.008' - class: Dist::Zilla::Plugin::ExtraTests name: '@Author::PERLANCAR/@Filter/ExtraTests' version: '6.008' - class: Dist::Zilla::Plugin::ExecDir name: '@Author::PERLANCAR/@Filter/ExecDir' version: '6.008' - class: Dist::Zilla::Plugin::ShareDir name: '@Author::PERLANCAR/@Filter/ShareDir' version: '6.008' - class: Dist::Zilla::Plugin::MakeMaker config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@Author::PERLANCAR/@Filter/MakeMaker' version: '6.008' - class: Dist::Zilla::Plugin::Manifest name: '@Author::PERLANCAR/@Filter/Manifest' version: '6.008' - class: Dist::Zilla::Plugin::ConfirmRelease name: '@Author::PERLANCAR/@Filter/ConfirmRelease' version: '6.008' - class: Dist::Zilla::Plugin::PERLANCAR::BeforeBuild name: '@Author::PERLANCAR/PERLANCAR::BeforeBuild' version: '0.55' - class: Dist::Zilla::Plugin::Rinci::AbstractFromMeta name: '@Author::PERLANCAR/Rinci::AbstractFromMeta' version: '0.09' - class: Dist::Zilla::Plugin::PodnameFromFilename name: '@Author::PERLANCAR/PodnameFromFilename' version: '0.01' - class: Dist::Zilla::Plugin::PERLANCAR::EnsurePrereqToSpec name: '@Author::PERLANCAR/PERLANCAR::EnsurePrereqToSpec' version: '0.04' - class: Dist::Zilla::Plugin::PERLANCAR::MetaResources name: '@Author::PERLANCAR/PERLANCAR::MetaResources' version: '0.03' - class: Dist::Zilla::Plugin::CheckChangeLog name: '@Author::PERLANCAR/CheckChangeLog' version: '0.02' - class: Dist::Zilla::Plugin::CheckMetaResources name: '@Author::PERLANCAR/CheckMetaResources' version: '0.001' - class: Dist::Zilla::Plugin::CopyrightYearFromGit name: '@Author::PERLANCAR/CopyrightYearFromGit' version: '0.002' - class: Dist::Zilla::Plugin::IfBuilt name: '@Author::PERLANCAR/IfBuilt' version: '0.03' - class: Dist::Zilla::Plugin::MetaJSON name: '@Author::PERLANCAR/MetaJSON' version: '6.008' - class: Dist::Zilla::Plugin::MetaConfig name: '@Author::PERLANCAR/MetaConfig' version: '6.008' - class: Dist::Zilla::Plugin::GenShellCompletion name: '@Author::PERLANCAR/GenShellCompletion' version: '0.11' - class: Dist::Zilla::Plugin::Authority name: '@Author::PERLANCAR/Authority' version: '1.009' - class: Dist::Zilla::Plugin::OurDate name: '@Author::PERLANCAR/OurDate' version: '0.03' - class: Dist::Zilla::Plugin::OurDist name: '@Author::PERLANCAR/OurDist' version: '0.02' - class: Dist::Zilla::Plugin::PERLANCAR::OurPkgVersion name: '@Author::PERLANCAR/PERLANCAR::OurPkgVersion' version: '0.04' - class: Dist::Zilla::Plugin::PodWeaver config: Dist::Zilla::Plugin::PodWeaver: finder: - ':InstallModules' - ':ExecFiles' plugins: - class: Pod::Weaver::Plugin::EnsurePod5 name: '@CorePrep/EnsurePod5' version: '4.013' - class: Pod::Weaver::Plugin::H1Nester name: '@CorePrep/H1Nester' version: '4.013' - class: Pod::Weaver::Section::Name name: '@Author::PERLANCAR/Name' version: '4.013' - class: Pod::Weaver::Section::Version name: '@Author::PERLANCAR/Version' version: '4.013' - class: Pod::Weaver::Section::Region name: '@Author::PERLANCAR/prelude' version: '4.013' - class: Pod::Weaver::Section::Generic name: SYNOPSIS version: '4.013' - class: Pod::Weaver::Section::Generic name: DESCRIPTION version: '4.013' - class: Pod::Weaver::Section::Generic name: OVERVIEW version: '4.013' - class: Pod::Weaver::Section::Collect name: ATTRIBUTES version: '4.013' - class: Pod::Weaver::Section::Collect name: METHODS version: '4.013' - class: Pod::Weaver::Section::Collect name: FUNCTIONS version: '4.013' - class: Pod::Weaver::Section::Leftovers name: '@Author::PERLANCAR/Leftovers' version: '4.013' - class: Pod::Weaver::Section::Region name: '@Author::PERLANCAR/postlude' version: '4.013' - class: Pod::Weaver::Section::Completion::GetoptLongComplete name: '@Author::PERLANCAR/Completion::GetoptLongComplete' version: '0.08' - class: Pod::Weaver::Section::Completion::GetoptLongSubcommand name: '@Author::PERLANCAR/Completion::GetoptLongSubcommand' version: '0.04' - class: Pod::Weaver::Section::Completion::GetoptLongMore name: '@Author::PERLANCAR/Completion::GetoptLongMore' version: '0.001' - class: Pod::Weaver::Section::Homepage::DefaultCPAN name: '@Author::PERLANCAR/Homepage::DefaultCPAN' version: '0.05' - class: Pod::Weaver::Section::Source::DefaultGitHub name: '@Author::PERLANCAR/Source::DefaultGitHub' version: '0.07' - class: Pod::Weaver::Section::Bugs::DefaultRT name: '@Author::PERLANCAR/Bugs::DefaultRT' version: '0.06' - class: Pod::Weaver::Section::Authors name: '@Author::PERLANCAR/Authors' version: '4.013' - class: Pod::Weaver::Section::Legal name: '@Author::PERLANCAR/Legal' version: '4.013' - class: Pod::Weaver::Plugin::Rinci name: '@Author::PERLANCAR/Rinci' version: '0.76' - class: Pod::Weaver::Plugin::AppendPrepend name: '@Author::PERLANCAR/AppendPrepend' version: '0.01' - class: Pod::Weaver::Plugin::EnsureUniqueSections name: '@Author::PERLANCAR/EnsureUniqueSections' version: '0.121550' - class: Pod::Weaver::Plugin::SingleEncoding name: '@Author::PERLANCAR/SingleEncoding' version: '4.013' - class: Pod::Weaver::Plugin::PERLANCAR::SortSections name: '@Author::PERLANCAR/PERLANCAR::SortSections' version: '0.05' name: '@Author::PERLANCAR/PodWeaver' version: '4.008' - class: Dist::Zilla::Plugin::PruneFiles name: '@Author::PERLANCAR/PruneFiles' version: '6.008' - class: Dist::Zilla::Plugin::ReadmeFromPod name: '@Author::PERLANCAR/ReadmeFromPod' version: '0.35' - class: Dist::Zilla::Plugin::Rinci::AddPrereqs name: '@Author::PERLANCAR/Rinci::AddPrereqs' version: '0.13' - class: Dist::Zilla::Plugin::Rinci::AddToDb name: '@Author::PERLANCAR/Rinci::AddToDb' version: '0.01' - class: Dist::Zilla::Plugin::Rinci::Validate name: '@Author::PERLANCAR/Rinci::Validate' version: '0.23' - class: Dist::Zilla::Plugin::SetScriptShebang name: '@Author::PERLANCAR/SetScriptShebang' version: '0.01' - class: Dist::Zilla::Plugin::Test::Compile config: Dist::Zilla::Plugin::Test::Compile: bail_out_on_fail: '0' fail_on_warning: author fake_home: 0 filename: t/00-compile.t module_finder: - ':InstallModules' needs_display: 0 phase: test script_finder: - ':PerlExecFiles' skips: [] name: '@Author::PERLANCAR/Test::Compile' version: '2.054' - class: Dist::Zilla::Plugin::Test::Rinci name: '@Author::PERLANCAR/Test::Rinci' version: '0.03' - class: Dist::Zilla::Plugin::UploadToCPAN::WWWPAUSESimple name: '@Author::PERLANCAR/UploadToCPAN::WWWPAUSESimple' version: '0.04' - class: Dist::Zilla::Plugin::EnsureSQLSchemaVersionedTest name: '@Author::PERLANCAR/EnsureSQLSchemaVersionedTest' version: '0.02' - class: Dist::Zilla::Plugin::Acme::CPANLists::Blacklist name: '@Author::PERLANCAR/Acme::CPANLists::Blacklist' version: '0.02' - class: Dist::Zilla::Plugin::Prereqs::EnsureVersion name: '@Author::PERLANCAR/Prereqs::EnsureVersion' version: '0.01' - class: Dist::Zilla::Plugin::Prereqs::CheckCircular name: '@Author::PERLANCAR/Prereqs::CheckCircular' version: '0.003' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: TestRequires version: '6.008' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: runtime type: requires name: Prereqs version: '6.008' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: develop type: x_spec name: DevelopX_spec version: '6.008' - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: '6.008' - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: '6.008' - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: '6.008' - class: Dist::Zilla::Plugin::FinderCode name: ':ExtraTestFiles' version: '6.008' - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: '6.008' - class: Dist::Zilla::Plugin::FinderCode name: ':PerlExecFiles' version: '6.008' - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: '6.008' - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: '6.008' - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: '6.008' - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: '6.008' zilla: class: Dist::Zilla::Dist::Builder config: is_trial: '0' version: '6.008' x_authority: cpan:PERLANCAR x_serialization_backend: 'YAML::Tiny version 1.69'