App-Slaughter

 view release on metacpan or  search on metacpan

lib/Slaughter/Info/freebsd.pm  view on Meta::CPAN

    #
    my $ipv4 = 1;
    my $ipv6 = 1;

    #
    #  Parse the output of /sbin/ifconfig.
    #
    foreach my $line ( split( /[\r\n]/, `ifconfig` ) )
    {
        chomp($line);
        next unless ( $line =~ /(inet|inet6)/ );

        if ( $line =~ /inet ([^ \t]+)/ )
        {
            my $addr = $1;
            next if ( $addr =~ /^127\./i );
            $ref->{ 'ip_' . $ipv4 } = $addr;
            $ipv4 += 1;
        }
        if ( $line =~ /inet6 ([^ \t]+)/ )
        {
            my $addr = $1;
            next if ( $addr =~ /fe80/i );
            $ref->{ 'ip6_' . $ipv6 } = $addr;
            $ipv6 += 1;
        }
    }

    # counts of addresses
    $ref->{ 'ip_count' }  = $ipv4;

lib/Slaughter/Info/linux.pm  view on Meta::CPAN

    $ip = "/bin/ip"  if ( -x "/bin/ip" );


    if ( defined($ip) )
    {

        #
        #  Two commands to find the IP addresses we have
        #
        my @cmd = ( " -o -f inet addr show scope global",
                    " -o -f inet6 addr show scope global"
                  );

        #
        #  Run each
        #
        foreach my $cmd (@cmd)
        {
            my $count  = 1;
            my $family = "ip";
            $family = "ip6" if ( $cmd =~ /inet6/i );

            foreach my $line ( split( /[\r\n]/, `$ip $cmd` ) )
            {
                next if ( !defined($line) || !length($line) );
                chomp($line);

                #
                #  This matches something like:
                #
                #  eth0 inet 192.168.1.9/24 brd 192.168.1.255 scope global eth0
                #
                # or
                #  eth0 inet6 2001:41c8:1:5abb::62/64 scope global valid_lft forever preferred_lft forever
                #
                #
                if ( $line =~ /(inet|inet6)[ \t]+([^ \t+]+)[ \t]+/ )
                {
                    my $proto = $1;
                    my $ip    = $2;

                    #
                    #  Strip off /24, /128, etc.
                    #
                    $ip =~ s/\/.*//g;

                    #

lib/Slaughter/Info/openbsd.pm  view on Meta::CPAN

    #
    my $ipv4 = 1;
    my $ipv6 = 1;

    #
    #  Parse the output of /sbin/ifconfig.
    #
    foreach my $line ( split( /[\r\n]/, `ifconfig` ) )
    {
        chomp($line);
        next unless ( $line =~ /(inet|inet6)/ );

        if ( $line =~ /inet ([^ \t]+)/ )
        {
            my $addr = $1;
            next if ( $addr =~ /^127\./i );
            $ref->{ 'ip_' . $ipv4 } = $addr;
            $ipv4 += 1;
        }
        if ( $line =~ /inet6 ([^ \t]+)/ )
        {
            my $addr = $1;
            next if ( $addr =~ /fe80/i );
            $ref->{ 'ip6_' . $ipv6 } = $addr;
            $ipv6 += 1;
        }
    }

    # counts of addresses
    $ref->{ 'ip_count' }  = $ipv4;

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.397 second using v1.00-cache-2.02-grep-82fe00e-cpan-b63e86051f13 )