Sys-HostIP-2.120/0000775000175000017500000000000013531737155013062 5ustar sawyersawyerSys-HostIP-2.120/Changes0000644000175000017500000001113013531737155014347 0ustar sawyersawyerRevision history for Perl extension Sys::HostIP. 2.120 2019-08-29 15:00:44+03:00 Asia/Jerusalem * Fix test failures on systems with a Russian locale. * Warn users if the interface can't be detected. 2.110 2019-02-23 17:40:31+02:00 Asia/Jerusalem * Implement fallback to `ip` on systems which don't have `ifconfig`. (Adam Balali) * Increase perlcritic compliance. 2.100 2018-01-20 23:17:24+01:00 Europe/Amsterdam * Work around ip() failures on non-English systems. (Paul Cochrane) * Better diagnostics in case of failure. (Paul Cochrane) 2.000 2017-03-27 14:20:12+02:00 Europe/Amsterdam * Fix Windows 7 Finish, Italian, French, German. (Paul Cochrane) * Fix Swedish. (Paul Cochrane) 1.99 2017-03-22 13:52:36+01:00 Europe/Amsterdam * Restore missing NAME section. (Nick Morrott) * Add Travis-CI. (Paul Cochrane) * Cleanup whitespace. (Paul Cochrane) * Minimum Perl version (5.6). (Paul Cochrane) * Add missing build prereqs. (Paul Cochrane) * Add copyright and license info to docs and README. (Paul Cochrane) 1.98 2016-08-27 08:56:19+02:00 Europe/Amsterdam * Accept empty interfaces names on Windows. (Hilko Bengen) * Add Windows 10 test (en-US). (Hilko Bengen) 1.97 03.02.13 * Adding support for Tru64 UNIX. (Thank you, Robert Urban!) 1.96 25.10.12 * No functional changes. * RT #80399: doc typo by Peter Newman. 1.95 23.02.12 * Trying to please testers more. (I'm looking at you, Chris!) 1.94 18.02.12 * Don't return 127.0.0.1 as default device if it wasn't really found. (tests have verified some machines don't have it) 1.93 14.02.12 * GH #4: Matthew Musgrove (Mr. Muskrat) unearthed a bug in tests that would plan an incorrect number of tests by operating system. Fixed. 1.92 14.02.12 * GH #3, RT #74701: Doc fix by Mr. Muskrat. * Dump some data in tests to try and fix failing tests. 1.91 06.02.12 * Functional interface is back. * * Sys::HostIP will remain backwards compatible. * * Fix bug reported by Mr. Muskrat where ifconfig would be searched even on Windows. This failed because Windows doesn't have ifconfig. * Refactoring, cleanups. 1.90 05.02.12 * Functional interface is now deprecated. * Fix taint mode, use File::Basename for it. * Remove need for Test::TinyMocker, Test::Exception. * Other cleanups. 1.81 20.01.11 * Refactoring testing code. * Adding test to Windows 7 (Hilko Bengen). 1.8 18.01.11 * More tests, thanks to fenderson (Amir Meiry). * Fix for Windows 7 (Hilko Bengen). * Adding test data for Windows XP and Windows 2K (Hilko Bengen). * Clean ups. 1.7 15.09.10 * Refactoring, refactoring, refactoring. * If you're using object oriented style, the data is now cached! * Create if_info on edit. * Sorted version numbers 1.6 12.09.10 * ifconfig attr as documented in POD * Sorting ifconfig sub to _get_ifconfig 1.5 11.09.10 * Moved to proper object oriented interface * Cleaning up all the POD * Cleaning up code 1.4 11.09.10 * New maintainer: Sawyer X (XSAWYERX) * Fixed RT #24002 (thanks gmc@gmcx.net and MARKLE) * Fixed RT #44845 (thanks Mikhael ) * Rewrote tests, doubled them * Using clean EXPORT_OK now * Allow multiple 127.0.0.1 in tests (VPS servers may have multiple) * Moved to Dist::Zilla * Cleaned up the Changes (reversed the order, hell yes) * Cleaned up the POD a bit 1.3.1 Mon Sep 29 20:37:07 PST 2003 fixed line wrapping in documentation. 1.3.0 Mon Sep 29 00:42::55 PST 2003 finally rewrote _get_win32_interface_info from scratch. All methods seem to work now. $/ is now localized before every system call (thanks martin.thurn@ngc.com). added aix support (thanks benny@discoveringmontana.com). 1.2.2 Thu Jan 9 12:46:59 PST 2003 fixed error with || precedence on line 24 that spit out a warning for non linux systems (thanks saad@docisland.org and nipotan@k5.dion.ne.jp) changed default ifconfig command to include "-a" flag 1.2.1 Mon Jul 8 01:02:03 2002 fixed typo on line 58 1.2 Sun Apr 7 21:05:23 2002 now ip() is exported (and works as a normal sub instead of a class method) to insure compatability with old module 1.1 Sun Apr 7 17:30:15 2002 almost complete rewrite of old (1.0) version Sys-HostIP-2.120/Makefile.PL0000644000175000017500000000304513531737155015034 0ustar sawyersawyer# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.012. use strict; use warnings; use 5.006; use ExtUtils::MakeMaker 7.1101; my %WriteMakefileArgs = ( "ABSTRACT" => "Try extra hard to get IP address related info", "AUTHOR" => "Sawyer X , Jonathan Schatz , Paul Cochrane ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "7.1101" }, "DISTNAME" => "Sys-HostIP", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.006", "NAME" => "Sys::HostIP", "PREREQ_PM" => { "Carp" => 0, "Exporter" => 0, "File::Basename" => 0, "parent" => 0 }, "TEST_REQUIRES" => { "Capture::Tiny" => 0, "Data::Dumper" => 0, "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::CPAN::Meta" => 0, "Test::More" => 0, "Test::Pod" => 0 }, "VERSION" => "2.120", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Capture::Tiny" => 0, "Carp" => 0, "Data::Dumper" => 0, "Exporter" => 0, "File::Basename" => 0, "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::CPAN::Meta" => 0, "Test::More" => 0, "Test::Pod" => 0, "parent" => 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); Sys-HostIP-2.120/MANIFEST0000644000175000017500000000133613531737155014214 0ustar sawyersawyer# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.012. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README lib/Sys/HostIP.pm t/00-compile.t t/01-base.t t/02-base-mocked-windows.t t/03-iface-undetected.t t/10-ifconfig.t t/11-ipconfig.t t/12-ip.t t/99-kwalitee.t t/author-pod-syntax.t t/data/ip-linux.txt t/data/ipconfig-2k.txt t/data/ipconfig-win10.txt t/data/ipconfig-win2008-sv_SE.txt t/data/ipconfig-win7-de_DE.txt t/data/ipconfig-win7-empty-name.txt t/data/ipconfig-win7-fi_FI.txt t/data/ipconfig-win7-fr_FR.txt t/data/ipconfig-win7-it_IT.txt t/data/ipconfig-win7-ru-utf8.txt t/data/ipconfig-win7.txt t/data/ipconfig-winxp-ru-utf8.txt t/data/ipconfig-xp.txt t/lib/Utils.pm t/release-distmeta.t Sys-HostIP-2.120/README0000644000175000017500000000056513531737155013746 0ustar sawyersawyerThis archive contains the distribution Sys-HostIP, version 2.120: Try extra hard to get IP address related info This software is copyright (c) 2019 by Sawyer X. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. This README file was generated by Dist::Zilla::Plugin::Readme v6.012. Sys-HostIP-2.120/META.yml0000644000175000017500000000177413531737155014342 0ustar sawyersawyer--- abstract: 'Try extra hard to get IP address related info' author: - 'Sawyer X ' - 'Jonathan Schatz ' - 'Paul Cochrane ' build_requires: Capture::Tiny: '0' Data::Dumper: '0' File::Spec: '0' IO::Handle: '0' IPC::Open3: '0' Test::CPAN::Meta: '0' Test::More: '0' Test::Pod: '0' configure_requires: ExtUtils::MakeMaker: '7.1101' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.012, 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: Sys-HostIP provides: Sys::HostIP: file: lib/Sys/HostIP.pm version: '2.120' requires: Carp: '0' Exporter: '0' File::Basename: '0' parent: '0' perl: '5.006' resources: bugtracker: https://github.com/xsawyerx/sys-hostip/issues repository: git://github.com/xsawyerx/sys-hostip.git version: '2.120' x_generated_by_perl: v5.28.1 x_serialization_backend: 'YAML::Tiny version 1.73' Sys-HostIP-2.120/lib/0000775000175000017500000000000013531737155013630 5ustar sawyersawyerSys-HostIP-2.120/lib/Sys/0000775000175000017500000000000013531737155014406 5ustar sawyersawyerSys-HostIP-2.120/lib/Sys/HostIP.pm0000644000175000017500000003045513531737155016117 0ustar sawyersawyerpackage Sys::HostIP; $Sys::HostIP::VERSION = '2.120'; # ABSTRACT: Try extra hard to get IP address related info use strict; use warnings; use Carp; use Exporter; use File::Basename 'dirname'; use parent 'Exporter'; our @EXPORT_OK = qw( ip ips interfaces ifconfig ); our $IS_WIN = $^O =~ qr/(MSWin32|cygwin)/xms; ## no critic qw(Variables::ProhibitPunctuationVars) sub new { ## no critic qw(Subroutines::RequireArgUnpacking) my $class = shift or croak 'Cannot create new method in a functional way'; my %opts = @_; my $self = bless {%opts}, $class; # only get ifconfig binary if it's not a windows $self->{'ifconfig'} ||= $IS_WIN ? '' : $self->_get_ifconfig_binary; $self->{'if_info'} ||= $self->_get_interface_info; return $self; } sub ifconfig { my $self = shift; my $path = shift; if ( !ref $self ) { return $self->_get_ifconfig_binary; } # set path $path and $self->{'ifconfig'} = $path; return $self->{'ifconfig'}; } sub ip { my $self = shift || 'Sys::HostIP'; my $if_info; if ( !ref $self ) { $if_info = $self->_get_interface_info; } else { $if_info = $self->if_info; } if ($IS_WIN) { my @if_keys = sort keys %{$if_info}; return scalar @if_keys != 0 ? ( $if_info->{ $if_keys[0] } ) : ''; } else { my $lo_found; foreach my $key ( sort keys %{$if_info} ) { # we don't want the loopback if ( $if_info->{$key} eq '127.0.0.1' ) { $lo_found++; next; } # now we return the first one that comes up return ( $if_info->{$key} ); } # we get here if loopback is the only active device $lo_found and return '127.0.0.1'; return ''; } } sub ips { my $self = shift || 'Sys::HostIP'; if ( !ref $self ) { return [ values %{ $self->_get_interface_info } ]; } return [ values %{ $self->if_info } ]; } sub interfaces { my $self = shift || 'Sys::HostIP'; if ( !ref $self ) { return $self->_get_interface_info; } return $self->if_info; } sub if_info { my $self = shift; return $self->{'if_info'}; } sub _get_ifconfig_binary { my $self = shift; my $ifconfig = '/sbin/ifconfig -a'; ## no critic qw(Variables::ProhibitPunctuationVars) if ( $^O =~ /(?: linux|openbsd|freebsd|netbsd|solaris|darwin )/xmsi ) { $ifconfig = -f '/sbin/ifconfig' ? '/sbin/ifconfig -a' : '/sbin/ip address'; } elsif ( $^O eq 'aix' ) { $ifconfig = '/usr/sbin/ifconfig -a'; } elsif ( $^O eq 'irix' ) { $ifconfig = '/usr/etc/ifconfig'; } elsif ( $^O eq 'dec_osf' ) { $ifconfig = '/sbin/ifconfig'; } else { carp "Unknown system ($^O), guessing ifconfig is in /sbin/ifconfig " . "(email xsawyerx\@cpan.org with the location of your ifconfig)\n"; } return $ifconfig; } sub _get_interface_info { my $self = shift; my $interface_info = $IS_WIN ? $self->_get_win32_interface_info() : $self->_get_unix_interface_info(); my $warning_msg = "Unable to detect interface information!\n" . "Please open an issue on https://github.com/xsawyerx/sys-hostip/issues with your 'ipconfig' or 'ifconfig' output"; warn $warning_msg if values %$interface_info == 0; return $interface_info; } sub _clean_ifconfig_env { my $self = shift; # this is an attempt to fix tainting problems # removing $BASH_ENV, which exists if /bin/sh is your bash delete $ENV{'BASH_ENV'}; # now we set the local $ENV{'PATH'} to be only the path to ifconfig # We have localized %ENV in the call to this, so we disable critic warning ## no critic qw(Variables::RequireLocalizedPunctuationVars) my $ifconfig = $self->ifconfig; $ENV{'PATH'} = dirname $ifconfig; return $ifconfig; } sub _get_unix_interface_info { my $self = shift; # localize the environment local %ENV; # make sure nothing else has touched $/ local $/ = "\n"; my ( $ip, $interface, %if_info ); # clean environment for taint mode my $ifconfig_bin = $self->_clean_ifconfig_env(); my @ifconfig = `$ifconfig_bin`; foreach my $line (@ifconfig) { # TODO: refactor this into tests # output from 'ifconfig -a' looks something like this on every *nix i # could get my hand on except linux (this one's actually from OpenBSD): # # gershiwin:~# /sbin/ifconfig -a # lo0: flags=8009 # inet 127.0.0.1 netmask 0xff000000 # lo1: flags=8008 # xl0: flags=8843 # media: Ethernet autoselect (100baseTX full-duplex) # status: active # inet 10.0.0.2 netmask 0xfffffff0 broadcast 10.0.0.255 # sl0: flags=c010 # sl1: flags=c010 # # in linux it's a little bit different: # # [jschatz@nooky Sys-IP]$ /sbin/ifconfig # eth0 Link encap:Ethernet HWaddr 00:C0:4F:60:6F:C2 # inet addr:10.0.3.82 Bcast:10.0.255.255 Mask:255.255.0.0 # UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 # Interrupt:19 Base address:0xec00 # lo Link encap:Local Loopback # inet addr:127.0.0.1 Mask:255.0.0.0 # UP LOOPBACK RUNNING MTU:3924 Metric:1 # # In linux, using /sbin/ip it looks like: # [goldenboy:~] adamb $ ip address # 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default # link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 # inet 127.0.0.1/8 scope host lo # valid_lft forever preferred_lft forever # inet6 ::1/128 scope host # valid_lft forever preferred_lft forever # 2: eth0: mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000 # link/ether 9c:b6:54:a5:64:60 brd ff:ff:ff:ff:ff:ff # # so the regexen involved here have to deal with the following: 1) # there's no ':' after an interface's name in linux 2) in linux, it's # "inet addr:127.0.0.1" instead of "inet 127.0.0.1" hence the somewhat # hairy regexen /(^\w+(?:\d)?(?:\:\d)?)/ (which also handles aliased ip # addresses , ie eth0:1) and /inet(?:addr\:)?(\d+\.\d+\.\d+\.\d+)/ # # so we parse through the list returned. if the line starts with some # letters followed (possibly) by an number and a colon, then we've got an # interface. if the line starts with a space, then it's the info from the # interface that we just found, and we stick the contents into %if_info if ( ( $line =~ /^\s+/x ) && ($interface) ) { $if_info{$interface} .= $line; } # FIXME: refactor this regex elsif ( ($interface) = ( $line =~ /^(?:\d+\:\s){0,1}(\w+(?:\d)?(?:\.\d+)?(?:\:\d+)?)/x )) { $line =~ s/\w+\d(\:)?\s+//x; $if_info{$interface} = $line; } } foreach my $key ( keys %if_info ) { # now we want to get rid of all the other crap in the ifconfig # output. we just want the ip address. perhaps a future version can # return even more useful results (netmask, etc)..... if ( my ($ip) = ( $if_info{$key} =~ /inet\s(?:addr\:)?(\d+(?:\.\d+){3})/x ) ) { $if_info{$key} = $ip; } else { # ok, no ip address here, which means this interface isn't # active. some os's (openbsd for instance) spit out ifconfig info for # inactive devices. this is pretty much worthless for us, so we # delete it from the hash delete $if_info{$key}; } } # now we do some cleanup by deleting keys that have no associated info # (some os's like openbsd list inactive interfaces when 'ifconfig -a' is # used, and we don't care about those return \%if_info; } sub _run_ipconfig { return `ipconfig`; } sub _get_win32_interface_info { my $self = shift; my %regexes = ( address => qr/ \s+ IP(?:v4)? .*? : \s+ (\d+ (?: \. \d+ ){3} ) /x, adapter => qr/ ^ (?: Ethernet(?:\s?|-)\w+ | .*?\s+Ethernet ) \s+ (.*) : /x, ); my @ipconfig = $self->_run_ipconfig(); my ( $interface, %if_info ); foreach my $line (@ipconfig) { chomp($line); if ( $line =~ /Windows/xms ) { # ignore the header next; } elsif ( $line =~ /^\s$/xms ) { next; } elsif ( ( $line =~ $regexes{'address'} ) and defined $interface ) { $if_info{$interface} = $1; $interface = undef; } elsif ( $line =~ $regexes{'adapter'} ) { $interface = $1; chomp $interface; $interface =~ s/\s+$//gxms; # remove trailing whitespace, if any } } return \%if_info; } 1; __END__ =head1 NAME Sys::HostIP - Try extra hard to get IP address related info =head1 SYNOPSIS use Sys::HostIP; my $hostip = Sys::HostIP->new; my $ips = $hostip->ips; my $interfaces = $hostip->interfaces; =head1 DESCRIPTION Sys::HostIP does what it can to determine the ip address of your machine. All 3 methods work fine on every system that I've been able to test on. (Irix, OpenBSD, FreeBSD, NetBSD, Solaris, Linux, OSX, Win32, Cygwin). It does this by parsing ifconfig(8) (ipconfig on Win32/Cygwin) output. It has an object oriented interface and a functional one for compatibility with older versions. =head1 ATTRIBUTES =head2 ifconfig my $hostip = Sys::HostIP->new( ifconfig => '/path/to/your/ifconfig' ); You can set the location of ifconfig with this attribute if the code doesn't know where your ifconfig lives. If you use the object oriented interface, this value is cached. =head2 if_info The interface information. This is either created on new, or you can create it yourself at initialize. # get the cached if_info my $if_info = $hostip->if_info; # create custom one at initialize my $hostip = Sys::HostIP->new( if_info => {...} ); =head1 METHODS =head2 ip my $ip = $hostip->ip; Returns a scalar containing a best guess of your host machine's IP address. On *nix (Unix, BSD, GNU/Linux, OSX, etc.) systems, it will return the loopback interface (127.0.0.1) if it can't find anything else. =head2 ips my $all_ips = $hostip->ips; foreach my $ip ( @{$all_ips} ) { print "IP: $ip\n"; } Returns an array ref containing all the IP addresses of your machine. =head2 interfaces my $interfaces = $hostip->interfaces; foreach my $interface ( keys %{$interfaces} ) { my $ip = $interfaces->{$interface}; print "$interface => $ip\n"; } Returns a hash ref containing all pairs of interfaces and their corresponding IP addresses Sys::HostIP could find on your machine. =head2 EXPORT Nothing by default! To export something explicitly, use the syntax: Nothing. use HostIP qw/ip ips interfaces/; # that will get you those three subroutines, for example All of these subroutines will match the object oriented interface methods. =over 4 =item * ip my $ip = ip(); =item * ips my $ips = ips(); =item * interfaces my $interfaces = interfaces(); =back =head1 HISTORY Originally written by Jonathan Schatz . Currently maintained by Paul Cochrane and Sawyer X . =head1 TODO I haven't tested the win32 code with dialup or wireless connections. Machines with output in some languages other than English fail. Neverthless, the code has been shown to work in German, Swedish, French, Italian, and Finnish locales. =head1 COPYRIGHT AND LICENSE Copyright (C) prior to 2010, Jonathan Schatz . Copyright (C) 2010-2019, Sawyer X . This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over 4 =item * ifconfig(8) =item * ipconfig =back Sys-HostIP-2.120/META.json0000644000175000017500000000353613531737155014510 0ustar sawyersawyer{ "abstract" : "Try extra hard to get IP address related info", "author" : [ "Sawyer X ", "Jonathan Schatz ", "Paul Cochrane " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Sys-HostIP", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "7.1101" } }, "develop" : { "requires" : { "Test::CPAN::Meta" : "0", "Test::Pod" : "1.41" } }, "runtime" : { "requires" : { "Carp" : "0", "Exporter" : "0", "File::Basename" : "0", "parent" : "0", "perl" : "5.006" } }, "test" : { "requires" : { "Capture::Tiny" : "0", "Data::Dumper" : "0", "File::Spec" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Test::CPAN::Meta" : "0", "Test::More" : "0", "Test::Pod" : "0" } } }, "provides" : { "Sys::HostIP" : { "file" : "lib/Sys/HostIP.pm", "version" : "2.120" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/xsawyerx/sys-hostip/issues" }, "repository" : { "type" : "git", "url" : "git://github.com/xsawyerx/sys-hostip.git", "web" : "https://github.com/xsawyerx/sys-hostip" } }, "version" : "2.120", "x_generated_by_perl" : "v5.28.1", "x_serialization_backend" : "JSON::XS version 3.04" } Sys-HostIP-2.120/LICENSE0000644000175000017500000004364113531737155014075 0ustar sawyersawyerThis software is copyright (c) 2019 by Sawyer X. 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) 2019 by Sawyer X. 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) 2019 by Sawyer X. 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 Sys-HostIP-2.120/t/0000775000175000017500000000000013531737155013325 5ustar sawyersawyerSys-HostIP-2.120/t/11-ipconfig.t0000644000175000017500000000534613531737155015535 0ustar sawyersawyer#!perl use strict; use warnings; use Test::More tests => 4 * 12; use File::Spec; use Sys::HostIP; use lib '.'; use t::lib::Utils qw/mock_win32_hostip/; ## no critic qw(Subroutines::RequireFinalReturn) sub test_mock_ipconfig { my ( $file, $expected_results, $test_name ) = @_; # Mock Windows local $Sys::HostIP::IS_WIN = 1; my $hostip = mock_win32_hostip($file); isa_ok( $hostip, 'Sys::HostIP' ); is_deeply( $hostip->_get_win32_interface_info, $expected_results, $test_name, ); } test_mock_ipconfig( 'ipconfig-2k.txt', { 'Local Area Connection' => '169.254.109.232' }, 'Correct Windows 2000 interface', ); test_mock_ipconfig( 'ipconfig-xp.txt', { 'Local Area Connection' => '0.0.0.0' }, 'Correct Windows XP interface', ); test_mock_ipconfig( 'ipconfig-win7.txt', { 'Local Area Connection' => '192.168.0.10', 'Local Area Connection 2' => '192.168.1.20', }, 'Correct Windows 7 interface', ); test_mock_ipconfig( 'ipconfig-win7-empty-name.txt', { '' => '192.168.1.101', }, 'Windows 7 interface, empty name', ); test_mock_ipconfig( 'ipconfig-win10.txt', { 'Ethernet' => '192.168.1.100', }, 'Correct Windows 10 interface', ); test_mock_ipconfig( 'ipconfig-win2008-sv_SE.txt', { 'Anslutning till lokalt n�tverk' => '192.168.40.241', }, 'Correct Windows Server 2008 interface in Swedish locale', ); test_mock_ipconfig( 'ipconfig-win7-de_DE.txt', { 'LAN-Verbindung' => '10.0.2.15', }, 'Correct Windows 7 interface in German locale', ); test_mock_ipconfig( 'ipconfig-win7-fr_FR.txt', { 'LAN-Verbindung' => '192.168.2.118', 'VirtualBox Host-Only Network' => '192.168.56.1', }, 'Correct Windows 7 interface in French locale', ); test_mock_ipconfig( 'ipconfig-win7-it_IT.txt', { 'LAN-Verbindung' => '192.168.2.118', 'VirtualBox Host-Only Network' => '192.168.56.1', }, 'Correct Windows 7 interface in Italian locale', ); test_mock_ipconfig( 'ipconfig-win7-fi_FI.txt', { 'LAN-Verbindung' => '192.168.2.118', 'VirtualBox Host-Only Network' => '192.168.56.1', }, 'Correct Windows 7 interface in Finnish locale', ); test_mock_ipconfig( 'ipconfig-winxp-ru-utf8.txt', { 'адаптер' => '10.0.2.15', }, 'Correct Windows XP interface in Russian locale', ); test_mock_ipconfig( 'ipconfig-win7-ru-utf8.txt', { 'Подключение по локальной сети' => '192.168.1.51', 'VirtualBox Host-Only Network' => '192.168.56.1', }, 'Correct Windows 7 interface in Russian locale', ); Sys-HostIP-2.120/t/10-ifconfig.t0000644000175000017500000000135213531737155015513 0ustar sawyersawyer#!perl use strict; use warnings; use Test::More; use Sys::HostIP; plan tests => $^O =~ qr/(MSWin32|cygwin)/x ? 5 : 7; { ## no critic qw(TestingAndDebugging::ProhibitNoWarnings) no warnings 'redefine'; *Sys::HostIP::_get_ifconfig_binary = sub { my $object = shift; isa_ok( $object, 'Sys::HostIP' ); cmp_ok( @_, '==', 0, 'Got no parameters' ); return 'test'; }; *Sys::HostIP::_get_interface_info = sub {}; } is( Sys::HostIP->ifconfig, 'test', 'ifconfig without object' ); my $object = Sys::HostIP->new; is( $object->ifconfig('my_path'), 'my_path', 'ifconfig with object and param' ); $object->{'ifconfig'} = 'my_ifconfig'; is( $object->ifconfig, 'my_ifconfig', 'ifconfig without path'); Sys-HostIP-2.120/t/01-base.t0000644000175000017500000000030713531737155014640 0ustar sawyersawyer#!perl use strict; use warnings; use lib '.'; use t::lib::Utils qw/base_tests/; use Test::More 'tests' => 11; # run base tests on actual system my $hostip = Sys::HostIP->new; base_tests($hostip); Sys-HostIP-2.120/t/02-base-mocked-windows.t0000644000175000017500000000161013531737155017567 0ustar sawyersawyer#!perl use strict; use warnings; use lib '.'; use t::lib::Utils qw/base_tests mock_win32_hostip/; use Test::More; my @ipconfigs = qw( ipconfig-2k.txt ipconfig-win10.txt ipconfig-win2008-sv_SE.txt ipconfig-win7-de_DE.txt ipconfig-win7-empty-name.txt ipconfig-win7-fi_FI.txt ipconfig-win7-fr_FR.txt ipconfig-win7-it_IT.txt ipconfig-win7-ru-utf8.txt ipconfig-win7.txt ipconfig-xp.txt ipconfig-winxp-ru-utf8.txt ); my $num_base_tests = 11; # this is the number of times the mocked _run_ipconfig() method is called # per call to base_tests() my $num_windows_mocking_checks = 4; plan tests => ( $num_base_tests + $num_windows_mocking_checks ) * scalar @ipconfigs; # run mocked windows base tests for my $ipconfig ( @ipconfigs ) { note $ipconfig; # Mock Windows local $Sys::HostIP::IS_WIN = 1; my $hostip = mock_win32_hostip($ipconfig); base_tests($hostip); } Sys-HostIP-2.120/t/lib/0000775000175000017500000000000013531737155014073 5ustar sawyersawyerSys-HostIP-2.120/t/lib/Utils.pm0000644000175000017500000000554313531737155015536 0ustar sawyersawyerpackage t::lib::Utils; # ABSTRACT: Utilities to help testing multiple systems use strict; use warnings; use vars qw( @ISA @EXPORT_OK ); use Carp; use Exporter; use File::Spec; use Sys::HostIP qw/ip ips ifconfig interfaces/; use Test::More; @ISA = qw(Exporter); @EXPORT_OK = qw( mock_run_ipconfig mock_win32_hostip mock_linux_hostip base_tests ); sub mock_win32_hostip { my $file = shift; { ## no critic qw(TestingAndDebugging::ProhibitNoWarnings) no warnings qw/redefine once/; *Sys::HostIP::_run_ipconfig = sub { ok( 1, 'Windows was called' ); return mock_run_ipconfig($file); }; } my $hostip = Sys::HostIP->new; return $hostip; } sub mock_linux_hostip { my $file = shift; { ## no critic qw(TestingAndDebugging::ProhibitNoWarnings) no warnings qw/redefine once/; *Sys::HostIP::_run_ipconfig = sub { return mock_run_ipconfig($file); }; } my $hostip = Sys::HostIP->new; return $hostip; } sub mock_run_ipconfig { my $filename = shift; my $file = File::Spec->catfile( 't', 'data', $filename ); open my $fh, '<', $file or die "Error opening $file: $!\n"; my @output = <$fh>; close $fh or die "Error closing $file: $!\n"; return @output; } ## no critic qw(Subroutines::RequireFinalReturn) sub base_tests { my $hostip = shift; # -- ip() -- my $sub_ip = ip(); my $class_ip = $hostip->ip; diag("Class IP: $class_ip"); like( $class_ip, qr/^ \d+ (?: \. \d+ ){3} $/x, 'IP by class looks ok' ); is( $class_ip, $sub_ip, 'IP by class matches IP by sub' ); # -- ips() -- my $sub_ips = ips(); my $class_ips = $hostip->ips; isa_ok( $class_ips, 'ARRAY', 'scalar context ips() gets arrayref' ); my $ip_in_ips_list = 1 == grep {/^$class_ip$/x} @{$class_ips}; ok( $ip_in_ips_list, 'Found IP in IPs by class' ); is( scalar @{$class_ips}, scalar @{$sub_ips}, 'Length of class and sub ips() output is equal' ); is_deeply( [sort @{$class_ips}], [sort @{$sub_ips}], 'IPs by class match IPs by sub' ); # -- interfaces() -- my $sub_interfaces = interfaces(); my $interfaces = $hostip->interfaces; isa_ok( $interfaces, 'HASH', 'scalar context interfaces() gets hashref' ); cmp_ok( scalar keys ( %{$interfaces} ), '==', scalar @{$class_ips}, 'Matching number of interfaces and ips', ); is_deeply($interfaces, $sub_interfaces, 'interfaces() output by class and sub are equal'); # -- if_info() -- my $if_info = $hostip->if_info; isa_ok( $if_info, 'HASH', 'scalar context if_info() gets hashref' ); my $if_info_hostip = Sys::HostIP->new(if_info => { 'if_name' => '1.2.3.4' }); is_deeply( $if_info_hostip->if_info, { 'if_name' => '1.2.3.4' }, 'if_info set as attribute' ); } 1; Sys-HostIP-2.120/t/author-pod-syntax.t0000644000175000017500000000045413531737155017121 0ustar sawyersawyer#!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(); Sys-HostIP-2.120/t/99-kwalitee.t0000644000175000017500000000046013531737155015554 0ustar sawyersawyer#!perl use strict; use warnings; use Test::More; BEGIN { plan skip_all => 'Disabled until we can install Test::Kwalitee::Extra'; plan skip_all => 'these tests are for release candidate testing' unless $ENV{RELEASE_TESTING}; } use Test::Kwalitee::Extra qw(:experimental); done_testing; Sys-HostIP-2.120/t/data/0000775000175000017500000000000013531737155014236 5ustar sawyersawyerSys-HostIP-2.120/t/data/ipconfig-win10.txt0000644000175000017500000000073113531737155017530 0ustar sawyersawyer Windows IP Configuration Ethernet adapter Ethernet 2: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Ethernet adapter Ethernet: Connection-specific DNS Suffix . : example.org Link-local IPv6 Address . . . . . : fe80::2927:d4e6:18b4:432%2 IPv4 Address. . . . . . . . . . . : 192.168.1.100 Subnet Mask . . . . . . . . . . . : 255.255.0.0 Default Gateway . . . . . . . . . : 192.168.1.1 Sys-HostIP-2.120/t/data/ipconfig-win7.txt0000644000175000017500000000172713531737155017464 0ustar sawyersawyer Windows IP Configuration Ethernet adapter Local Area Connection 2: Connection-specific DNS Suffix . : Link-local IPv6 Address . . . . . : fe80::2cd0:c94d:1cc9:4b3d%13 IPv4 Address. . . . . . . . . . . : 192.168.1.20 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.1 Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : Link-local IPv6 Address . . . . . : fe80::c18b:8f1d:2e1c:6d2a%11 IPv4 Address. . . . . . . . . . . : 192.168.0.10 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : Tunnel adapter isatap.{91888E9E-F0EA-4089-AF7D-AC0D2589F38B}: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Tunnel adapter isatap.{81903339-BEA3-459E-BC3D-F426BF766FCE}: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Sys-HostIP-2.120/t/data/ipconfig-winxp-ru-utf8.txt0000644000175000017500000000065113531737155021250 0ustar sawyersawyer Настройка протокола IP для Windows Подключение по локальной сети - Ethernet адаптер: DNS-суффикс этого подключения . . : IP-адрес . . . . . . . . . . . . : 10.0.2.15 Маска подсети . . . . . . . . . . : 255.255.255.0 Основной шлюз . . . . . . . . . . : 10.0.2.2 Sys-HostIP-2.120/t/data/ipconfig-2k.txt0000644000175000017500000000041413531737155017104 0ustar sawyersawyer Windows 2000 IP Configuration Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : Autoconfiguration IP Address. . . : 169.254.109.232 Subnet Mask . . . . . . . . . . . : 255.255.0.0 Default Gateway . . . . . . . . . : Sys-HostIP-2.120/t/data/ipconfig-xp.txt0000644000175000017500000000043313531737155017220 0ustar sawyersawyer Windows IP Configuration Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : IP Address. . . . . . . . . . . . : 0.0.0.0 Subnet Mask . . . . . . . . . . . : 0.0.0.0 Default Gateway . . . . . . . . . : Sys-HostIP-2.120/t/data/ip-linux.txt0000644000175000017500000000322413531737155016543 0ustar sawyersawyer1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp0s31f6: mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000 link/ether 18:db:f2:2b:af:26 brd ff:ff:ff:ff:ff:ff 3: wlp2s0: mtu 1500 qdisc mq state UP group default qlen 1000 link/ether f0:d5:bf:51:ad:15 brd ff:ff:ff:ff:ff:ff inet 192.168.2.107/24 brd 192.168.2.255 scope global wlp2s0 valid_lft forever preferred_lft forever inet6 fe80::7caf:9455:eb84:50d9/64 scope link valid_lft forever preferred_lft forever 9: vboxnet0: mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000 link/ether 0a:00:27:00:00:00 brd ff:ff:ff:ff:ff:ff inet 192.168.23.1/24 brd 192.168.23.255 scope global vboxnet0 valid_lft forever preferred_lft forever inet6 fe80::800:27ff:fe00:0/64 scope link valid_lft forever preferred_lft forever 10: vboxnet1: mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 0a:00:27:00:00:01 brd ff:ff:ff:ff:ff:ff 21: tun0: mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100 link/none inet 10.8.0.2/24 brd 10.8.0.255 scope global tun0 valid_lft forever preferred_lft forever inet6 fe80::e057:30b6:8a1b:2fd3/64 scope link flags 800 valid_lft forever preferred_lft forever Sys-HostIP-2.120/t/data/ipconfig-win7-de_DE.txt0000644000175000017500000000136313531737155020416 0ustar sawyersawyer Windows-IP-Konfiguration Ethernet-Adapter LAN-Verbindung: Verbindungsspezifisches DNS-Suffix: Verbindungslokale IPv6-Adresse . : fe80::417a:e1a3:e92e:76f2%11 IPv4-Adresse . . . . . . . . . . : 10.0.2.15 Subnetzmaske . . . . . . . . . . : 255.255.255.0 Standardgateway . . . . . . . . . : 10.0.2.2 Tunneladapter isatap.{3505548F-914A-4E9F-B2A8-C05189D0D45C}: Medienstatus. . . . . . . . . . . : Medium getrennt Verbindungsspezifisches DNS-Suffix: Tunneladapter LAN-Verbindung*: Verbindungsspezifisches DNS-Suffix: IPv6-Adresse. . . . . . . . . . . : 2001:0:9d38:78cf:c3f:89fb:af44:9349 Verbindungslokale IPv6-Adresse . : fe80::c3f:89fb:af44:9349%13 Standardgateway . . . . . . . . . : :: Sys-HostIP-2.120/t/data/ipconfig-win7-ru-utf8.txt0000644000175000017500000000456613531737155021000 0ustar sawyersawyer Настройка протокола IP для Windows Адаптер беспроводной локальной сети Беспроводное сетевое соединение 2: Состояние среды. . . . . . . . : Среда передачи недоступна. DNS-суффикс подключения . . . . . : Адаптер беспроводной локальной сети Беспроводное сетевое соединение: Состояние среды. . . . . . . . : Среда передачи недоступна. DNS-суффикс подключения . . . . . : localdomain Ethernet adapter Подключение по локальной сети: DNS-суффикс подключения . . . . . : localdomain IPv6-адрес. . . . . . . . . . . . : 2a01:c23:c446:6a00:70a6:7ff9:c53f:d301 Временный IPv6-адрес. . . . . . . : 2a01:c23:c446:6a00:1dd:3c27:dbb4:504a Локальный IPv6-адрес канала . . . : fe80::70a6:7ff9:c53f:d301%10 IPv4-адрес. . . . . . . . . . . . : 192.168.1.51 Маска подсети . . . . . . . . . . : 255.255.255.0 Основной шлюз. . . . . . . . . : fe80::7a29:edff:fe40:e3d9%10 192.168.1.1 Ethernet adapter VirtualBox Host-Only Network: DNS-суффикс подключения . . . . . : Локальный IPv6-адрес канала . . . : fe80::f86a:7f15:950b:162e%18 IPv4-адрес. . . . . . . . . . . . : 192.168.56.1 Маска подсети . . . . . . . . . . : 255.255.255.0 Основной шлюз. . . . . . . . . : Туннельный адаптер isatap.{CF46C24D-337B-4325-BBA4-BCDBC8C8F2A2}: Состояние среды. . . . . . . . : Среда передачи недоступна. DNS-суффикс подключения . . . . . : Туннельный адаптер Teredo Tunneling Pseudo-Interface: Состояние среды. . . . . . . . : Среда передачи недоступна. DNS-суффикс подключения . . . . . : Туннельный адаптер isatap.localdomain: Состояние среды. . . . . . . . : Среда передачи недоступна. DNS-суффикс подключения . . . . . : localdomain Sys-HostIP-2.120/t/data/ipconfig-win2008-sv_SE.txt0000644000175000017500000000126113531737155020715 0ustar sawyersawyer IP-konfiguration f�r Windows Ethernet-anslutning Anslutning till lokalt n�tverk: Anslutningsspecifika DNS-suffix . : L�nklokal IPv6-adress . . . . . . : ff88::b6fa:c6e1:9a9a:9114%10 IPv4-adress . . . . . . . . . . . : 192.168.40.241 N�tmask . . . . . . . . . . . . . : 255.255.255.0 Standard-gateway. . . . . . . . . : 192.168.40.1 Tunnelanslutning: Anslutning till lokalt n�tverk*: Tillst�nd . . . . . . . . . . . . : Fr�nkopplad Anslutningsspecifika DNS-suffix . : Tunnelanslutning: Anslutning till lokalt n�tverk* 8: Tillst�nd . . . . . . . . . . . . : Fr�nkopplad Anslutningsspecifika DNS-suffix . : Sys-HostIP-2.120/t/data/ipconfig-win7-it_IT.txt0000644000175000017500000000310313531737155020460 0ustar sawyersawyer Configurazione IP di Windows Scheda Ethernet LAN-Verbindung: Suffisso DNS specifico per connessione: S_W_3V_1_3_0 Indirizzo IPv6 . . . . . . . . . . . . . . . . . : 2003:e7:93ce:2801:71f4:f151:8100:f395 Indirizzo IPv6 temporaneo. . . . . . . . . . . . : 2003:e7:93ce:2801:dd3:a13a:4d7b:9b35 Indirizzo IPv6 locale rispetto al collegamento . : fe80::71f4:f151:8100:f395%11 Indirizzo IPv4. . . . . . . . . . . . : 192.168.2.118 Subnet mask . . . . . . . . . . . . . : 255.255.255.0 Gateway predefinito . . . . . . . . . : fe80::1%11 192.168.2.1 Scheda Ethernet VirtualBox Host-Only Network: Suffisso DNS specifico per connessione: Indirizzo IPv6 locale rispetto al collegamento . : fe80::a8fa:b31b:672b:b415%14 Indirizzo IPv4. . . . . . . . . . . . : 192.168.56.1 Subnet mask . . . . . . . . . . . . . : 255.255.255.0 Gateway predefinito . . . . . . . . . : Scheda Tunnel isatap.S_W_3V_1_3_0: Stato supporto. . . . . . . . . . . . : Supporto disconnesso Suffisso DNS specifico per connessione: S_W_3V_1_3_0 Scheda Tunnel LAN-Verbindung* 3: Suffisso DNS specifico per connessione: Indirizzo IPv6 . . . . . . . . . . . . . . . . . : 2001:0:9d38:78cf:c02:3711: a4ee:a12d Indirizzo IPv6 locale rispetto al collegamento . : fe80::c02:3711:a4ee:a12d%1 3 Gateway predefinito . . . . . . . . . : Scheda Tunnel isatap.{2F276BC5-ADC1-4179-BFB7-161CEA6B8A27}: Stato supporto. . . . . . . . . . . . : Supporto disconnesso Suffisso DNS specifico per connessione: Sys-HostIP-2.120/t/data/ipconfig-win7-empty-name.txt0000644000175000017500000000161213531737155021527 0ustar sawyersawyer Windows IP Configuration Ethernet adapter Local Area Connection 3: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Link-local IPv6 Address . . . . . : fe80::1d6c:95:b3d7:8b4c%20 Default Gateway . . . . . . . . . : Ethernet adapter : Connection-specific DNS Suffix . : example.org Link-local IPv6 Address . . . . . : fe80::9437:94dc:5211:414c%16 IPv4 Address. . . . . . . . . . . : 192.168.1.101 Subnet Mask . . . . . . . . . . . : 255.255.0.0 Default Gateway . . . . . . . . . : 192.168.1.1 Tunnel adapter isatap.{1212A406-F319-4841-B7DC-7B919C7BE3D9}: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Tunnel adapter isatap.example.org: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : example.org Sys-HostIP-2.120/t/data/ipconfig-win7-fr_FR.txt0000644000175000017500000000301113531737155020444 0ustar sawyersawyer Configuration IP de Windows Carte Ethernet LAN-Verbindung : Suffixe DNS propre la connexion. . . : S_W_23V_1_3_0 Adresse IPv6. . . . . . . . . . .. . .: 2003:e7:93ce:2801:71f4:f151:8100:f395 Adresse IPv6 temporaire . . . . . . . .: 2003:e7:93ce:2801:8dd:1829:d3ce:9915 Adresse IPv6 de liaison locale. . . . .: fe80::71f4:f151:8100:f395%11 Adresse IPv4. . . . . . . . . . . . . .: 192.168.2.118 Masque de sous-rseau. . . .. . . . . : 255.255.255.0 Passerelle par dfaut. . . .. . . . . : fe80::1%11 192.168.2.1 Carte Ethernet VirtualBox Host-Only Network : Suffixe DNS propre la connexion. . . : Adresse IPv6 de liaison locale. . . . .: fe80::a8fa:b31b:672b:b415%14 Adresse IPv4. . . . . . . . . . . . . .: 192.168.56.1 Masque de sous-rseau. . . .. . . . . : 255.255.255.0 Passerelle par dfaut. . . .. . . . . : Carte Tunnel isatap.S_W_23V_1_3_0 : Statut du mdia. . . . . . . . . . . . : Mdia dconnect Suffixe DNS propre la connexion. . . : S_W_23V_1_3_0 Carte Tunnel LAN-Verbindung* 3 : Suffixe DNS propre la connexion. . . : Adresse IPv6. . . . . . . . . . .. . .: 2001:0:9d38:78cf:c02:3711:a4ee:a12d Adresse IPv6 de liaison locale. . . . .: fe80::c02:3711:a4ee:a12d%13 Passerelle par dfaut. . . .. . . . . : Carte Tunnel isatap.{2F276BC5-ADC1-4179-BFB7-161CEA6B8A27} : Statut du mdia. . . . . . . . . . . . : Mdia dconnect Suffixe DNS propre la connexion. . . : Sys-HostIP-2.120/t/data/ipconfig-win7-fi_FI.txt0000644000175000017500000000273013531737155020431 0ustar sawyersawyer Windows IP-mritykset Ethernet-sovitin LAN-Verbindung: Yhteyskohtainen DNS-liite . . . . : S_W_3V_1_3_0 IPv6-osoite . . . . . . . . . . . : 2003:e7:93ce:2801:71f4:f151:8100:f395 Tilapinen IPv6-osoite. . . . . . : 2003:e7:93ce:2801:2d03:317f:1567:19ee Linkin paikallinen IPv6-osoite. . : fe80::71f4:f151:8100:f395%11 IPv4-osoite . . . . . . . . . . . : 192.168.2.118 Aliverkon peite . . . . . . . . . : 255.255.255.0 Oletusyhdyskytv. . . . . . . . : fe80::1%11 192.168.2.1 Ethernet-sovitin VirtualBox Host-Only Network: Yhteyskohtainen DNS-liite . . . . : Linkin paikallinen IPv6-osoite. . : fe80::a8fa:b31b:672b:b415%14 IPv4-osoite . . . . . . . . . . . : 192.168.56.1 Aliverkon peite . . . . . . . . . : 255.255.255.0 Oletusyhdyskytv. . . . . . . . : Tunnelisovitin isatap.S_W_3V_1_3_0: Laitteen tila . . . . . . . . . . : Ei kytketty Yhteyskohtainen DNS-liite . . . . : S_W_3V_1_3_0 Tunnelisovitin LAN-Verbindung* 3: Yhteyskohtainen DNS-liite . . . . : IPv6-osoite . . . . . . . . . . . : 2001:0:9d38:78cf:c02:3711:a4ee:a12d Linkin paikallinen IPv6-osoite. . : fe80::c02:3711:a4ee:a12d%13 Oletusyhdyskytv. . . . . . . . : Tunnelisovitin isatap.{2F276BC5-ADC1-4179-BFB7-161CEA6B8A27}: Laitteen tila . . . . . . . . . . : Ei kytketty Yhteyskohtainen DNS-liite . . . . : Sys-HostIP-2.120/t/release-distmeta.t0000644000175000017500000000040113531737155016733 0ustar sawyersawyer#!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::MetaTests. use Test::CPAN::Meta; meta_yaml_ok(); Sys-HostIP-2.120/t/00-compile.t0000644000175000017500000000263313531737155015361 0ustar sawyersawyeruse 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058 use Test::More; plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'Sys/HostIP.pm' ); # no fake home requested my @switches = ( -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; diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} } $^X, @switches, '-e', "require q[$lib]")) if $ENV{PERL_COMPILE_TEST_DEBUG}; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-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}; Sys-HostIP-2.120/t/03-iface-undetected.t0000644000175000017500000000224313531737155017122 0ustar sawyersawyer#!perl use strict; use warnings; use lib '.'; use Test::More 'tests' => 4; use Sys::HostIP qw/ip/; use Capture::Tiny qw/capture/; # check unavailable interface on Windows { # Mock Windows local $Sys::HostIP::IS_WIN = 1; { ## no critic qw(TestingAndDebugging::ProhibitNoWarnings) no warnings qw/redefine once/; *Sys::HostIP::_get_win32_interface_info = sub { return {}; }; } my ($stdout, $stderr, @result) = capture { ip() }; like( $stderr, qr/Unable to detect interface information!/, "Inform user if interface info not detectable" ); is( $result[0], '', "Empty ip info returned" ); } # check unavailable interface on *nix { { ## no critic qw(TestingAndDebugging::ProhibitNoWarnings) no warnings qw/redefine once/; *Sys::HostIP::_get_unix_interface_info = sub { return {}; }; } my ($stdout, $stderr, @result) = capture { ip() }; like( $stderr, qr/Unable to detect interface information!/, "Inform user if interface info not detectable" ); is( $result[0], '', "Empty ip info returned" ); } Sys-HostIP-2.120/t/12-ip.t0000644000175000017500000000047213531737155014343 0ustar sawyersawyer#!perl use strict; use warnings; use t::lib::Utils qw/mock_linux_hostip base_tests/; use Test::More; use Sys::HostIP; if ($^O =~ qr/(linux)/x) { plan tests => 11; my $hostip = mock_linux_hostip('ip-linux.txt'); base_tests($hostip); } else { plan skip_all => 'these tests are only for Linux'; }