Net-CIDR-Set-0.19/0000775000175000017500000000000015044372357011305 5ustar rrrrNet-CIDR-Set-0.19/META.json0000644000175000017500000000667415044372357012741 0ustar rrrr{ "abstract" : "Manipulate sets of IP addresses", "author" : [ "Andy Armstrong " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.032, CPAN::Meta::Converter version 2.150010", "keywords" : [ "CIDR", "INET", "LPM", "Longest", "Prefix", "Match" ], "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Net-CIDR-Set", "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "7.22", "Module::Metadata" : "1.000015" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Dist::Zilla::Plugin::UsefulReadme" : "v0.2.0", "Pod::Coverage::TrustPod" : "0", "Pod::Markdown::Github" : "0", "Software::Security::Policy::Individual" : "0.10", "Test2::Tools::Basic" : "1.302200", "Test::CPAN::Changes" : "0.19", "Test::CleanNamespaces" : "0.15", "Test::DistManifest" : "0", "Test::EOF" : "0", "Test::EOL" : "0", "Test::Kwalitee" : "1.21", "Test::MinimumVersion" : "0", "Test::MixedScripts" : "v0.3.0", "Test::More" : "0.88", "Test::NoTabs" : "0", "Test::Perl::Critic" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08", "Test::Pod::LinkCheck" : "0", "Test::Portability::Files" : "0", "Test::Spelling" : "0.17", "Test::TrailingSpace" : "0.0203", "Test::Vars" : "0.015" } }, "runtime" : { "requires" : { "Carp" : "0", "namespace::autoclean" : "0", "overload" : "0", "perl" : "v5.14.0", "strict" : "0", "warnings" : "0" } }, "test" : { "recommends" : { "CPAN::Meta" : "2.120900" }, "requires" : { "Data::Dumper" : "0", "File::Spec" : "0", "Module::Metadata" : "1.000015", "Test::More" : "0" } } }, "provides" : { "Net::CIDR::Set" : { "file" : "lib/Net/CIDR/Set.pm", "version" : "0.19" }, "Net::CIDR::Set::IPv4" : { "file" : "lib/Net/CIDR/Set/IPv4.pm", "version" : "0.19" }, "Net::CIDR::Set::IPv6" : { "file" : "lib/Net/CIDR/Set/IPv6.pm", "version" : "0.19" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=Net-CIDR-Set" }, "repository" : { "type" : "git", "url" : "git://github.com/robrwo/perl-Net-CIDR-Set.git", "web" : "https://github.com/robrwo/perl-Net-CIDR-Set" }, "x_authority" : "cpan:RRWO" }, "version" : "0.19", "x_contributors" : [ "Thomas Eckardt ", "Brian Gottreu ", "Robert Rothenberg ", "Stig Palmquist " ], "x_generated_by_perl" : "v5.34.3", "x_serialization_backend" : "Cpanel::JSON::XS version 4.38", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later" } Net-CIDR-Set-0.19/SIGNATURE0000644000175000017500000001213215044372357012566 0ustar rrrrThis file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.90. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: RIPEMD160 SHA256 c067b732d3367a2ba4842ff37d7e3838f37e088d5012fba594f1cf7fd9947383 CONTRIBUTING.md SHA256 05841b961ad08b821f417665ee85398bcc604734b4df9897b9822030c6e65150 Changes SHA256 8e4ff6a6d548cf5c95403c028ced2dd9ca0fa39cc6261234a96a346905569460 LICENSE SHA256 fb7ee27b2f5a824485e7734e8f719633e11964e09ecbfb33f46e10fedb083d51 MANIFEST SHA256 022be3692c61ef8acd19b28fab4e4e1a126907e023223fba87c4e97ac0357f83 MANIFEST.SKIP SHA256 5d834bc91fab9fb17c518f839338a7a26ecc9d723127516ad86d84cf52e6db0d META.json SHA256 fb6bcfad3d309d1ea10fd6e580d4985e8399333a93a6ed25cc3931693704bd01 META.yml SHA256 7379172617b30635dd5f9a3d61c46719f9937d0064a92c034be1cf4bba883d81 Makefile.PL SHA256 eee45785e190022ff528e43a52a6dc3b52df578b2c43faec3a9850e98d3c6584 README.md SHA256 ec83df0fad0985bd60c786e249565e81b31b1712a38c985e53cdd42c3ad74c6c SECURITY.md SHA256 17510e7e4c8373ed4edff4b8b9b70400c7d56a8404b57b9aa1f5aa630fc4fc16 cpanfile SHA256 fa61c1123300b769732e228a4c1ff35e192fa5f77d509843860018bd5aafca11 dist.ini SHA256 d0a4af36fcb50dc11b211020262afa979d1f8a668e66bf1356d1963de2bef0c4 lib/Net/CIDR/Set.pm SHA256 39b01679d62b1c2f1379f8bf7a58c4247d81a19b8364671016daccdc5fe8f0cd lib/Net/CIDR/Set/IPv4.pm SHA256 cfc23aa9896eaa3900f9301b7521587b6ff47625b6f8f6ed5de3265ab6fa2146 lib/Net/CIDR/Set/IPv6.pm SHA256 23367278754969396ab295c1decde22bb7d9d513a0dba9d68309a5c242918263 t/00-load.t SHA256 cbbce087773b93b285f2dd5681d7e1113567373bb3ce04fe7a555586379a8e37 t/00-report-prereqs.dd SHA256 a09abf0f981c4a98250030a586579bd1ed1a78a2e3eecbcdaf9757213a18ca0f t/00-report-prereqs.t SHA256 72b1fd92691fbf47ba031bd3c386e3b26a525f3625b573417a85ea99422bec2c t/author-clean-namespaces.t SHA256 fb4b993dfe576260071aad804155a00480524fdf18248527fee79dabb09a757b t/author-critic.t SHA256 fbe6cdd54a8c2e95b5eb624cdc1799f9ea3d28e4fca551e23738cf9a0a829e32 t/author-eof.t SHA256 39688092e3ab6bcd8565f6c6a905a83ea0b1f83131addb90af67e02a9e105751 t/author-eol.t SHA256 914bde9f0ea3cadd6afb992b32d87f5027d1a0921b6b8fec75db045bac31956e t/author-minimum-version.t SHA256 6ffbab65ded619a32c48fcd4cb442ee5d16af939868b2e9048c1a0089e57a740 t/author-mixed-unicode-scripts.t SHA256 ecde133e827bceea4152161fec7f2893989292cb9b95ae922d8330d4d35ec10f t/author-no-tabs.t SHA256 1ee64d4f8248deb3541453ec521ac8057c9a4ba365946b6a02ee760ad28ce164 t/author-pod-coverage.t SHA256 8835ccb71da79a1b53a576dd349e188d444fce139e1f9f62976458c066b8edf9 t/author-pod-linkcheck.t SHA256 990d68004efb70685591511fc90e7e79b078467cca14d74a628bc6f93426fed9 t/author-pod-spell.t SHA256 305c657c6b73f10767a0ea286b8a73d693940f4cbb8b6a0a4d34e2b5a1c04635 t/author-pod-syntax.t SHA256 da2b42d19f0e73aaab56a0bb5dffc2d761be48ee53e305c7fe9f0921279fa2a1 t/author-portability.t SHA256 418b26a02b554bcf470d9f2f28750cc2a053f4ae21e722d42cad67bfde9bf37a t/basic.t SHA256 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 t/etc/perlcritic.rc SHA256 436dac01b388165bd739dc17e6003b623e9abfac69bde95104fbcc4f7b15edb4 t/ipv6.t SHA256 bcbb915b1eeb783580e56a3c29fc2fe72f7030f7807007805eecc1e8d96ddf23 t/is_cidr.t SHA256 3d904633d371863df574e3f7438576820ea7758848fb3743de4e9f981199c50e t/misc.t SHA256 057c4f0d470458199e5b8036d713bd3f4dc5ef9850e34b8f31f4304078c880f4 t/octal.t SHA256 606a78deb7e2c0dacba1512f92d1b51852a448ffebe8eabb77c27bdbb9d179a4 t/operations.t SHA256 adc7df1d52c8808f0e2779227a9f662477250c3ca69133cabe7b3934a05262e2 t/private.t SHA256 20690e642fce0015220d5b4fc1382f9a4360be0cf2ee8ddbde91e6ff4d311f29 t/release-cpan-changes.t SHA256 c7abebad263617efe56a21c1387a18c4054ed60f55212c15e199c4443edd815e t/release-dist-manifest.t SHA256 6817b484798f726a44e9aee17da6e80979b4ace77349f0d0b4a13cd935172cba t/release-fixme.t SHA256 426c441a368792fa6be6a2e35ff0ac997faa48575d090646e9570e056109bb32 t/release-kwalitee.t SHA256 6157040bb26db4ca06dd9c19043099fe31004612d27961308558fa2e3e6a7bbe t/release-trailing-space.t SHA256 e83346b20f03081a0d8ec321847a5233f145801b164449a380000e082a53ec73 t/release-unused-vars.t SHA256 c75f797d2b2032f8f26e590bbeb909a10a13c707e87eea5eb3397a1b375f13dc weaver.ini -----BEGIN PGP SIGNATURE----- iQGzBAEBAwAdFiEEeIwq7Pfyfxtssr5nHmWrcYGDC6wFAmiR9O8ACgkQHmWrcYGD C6wEZQv/anjPB+z70Q0TdEeDgNMhLf/j3WjExWa1WG1BGgN5qX4I+At5YwsbvpTb 8tcbcrhy6O6nQfjtcSewayTkz2D/gb2NUiufRdv2nByxT2g4r4TpbbDCRVbW+l+t ibJXJ84Yd8i8BeBHIIzBx0Qu1cjNxqZXh1tIsRMrSQLC6LTtH2bv/n0ITjV+N4NU LDq89tqUS1D762AuHXrVPDjUmESHQozcaWLvxGY580fQ2WleF38e3PaW74RgzSYp g3rZOuAeTDsKZgAyz17NsG3YbxaAH8+orLvnr3XdNcyq1Km2qkP2SLkBDoXlxEG8 Lr09bIE9ZGjmrvYdE3EeWkPnoPmtqqygdKa8x6uehBVeSN3bWVAlxyA7caZNQdK5 yPYVpv1xPqRpdAX7cXyJygS4ejki5w4zEweBUJ7ir3Q4DYRhC6/s8hUzVty+UV1o izaxAigXAtDlkNpj89hqhk+q1pCT2JprmQoYKAx/R576YPpvURJlXvjxCTTCg5p/ QD3ljjWj =zYUR -----END PGP SIGNATURE----- Net-CIDR-Set-0.19/MANIFEST0000644000175000017500000000153715044372357012442 0ustar rrrr# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.032. CONTRIBUTING.md Changes LICENSE MANIFEST MANIFEST.SKIP META.json META.yml Makefile.PL README.md SECURITY.md SIGNATURE cpanfile dist.ini lib/Net/CIDR/Set.pm lib/Net/CIDR/Set/IPv4.pm lib/Net/CIDR/Set/IPv6.pm t/00-load.t t/00-report-prereqs.dd t/00-report-prereqs.t t/author-clean-namespaces.t t/author-critic.t t/author-eof.t t/author-eol.t t/author-minimum-version.t t/author-mixed-unicode-scripts.t t/author-no-tabs.t t/author-pod-coverage.t t/author-pod-linkcheck.t t/author-pod-spell.t t/author-pod-syntax.t t/author-portability.t t/basic.t t/etc/perlcritic.rc t/ipv6.t t/is_cidr.t t/misc.t t/octal.t t/operations.t t/private.t t/release-cpan-changes.t t/release-dist-manifest.t t/release-fixme.t t/release-kwalitee.t t/release-trailing-space.t t/release-unused-vars.t weaver.ini Net-CIDR-Set-0.19/t/0000775000175000017500000000000015044372357011550 5ustar rrrrNet-CIDR-Set-0.19/t/author-mixed-unicode-scripts.t0000644000175000017500000000240415044372357017452 0ustar rrrr BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } use strict; use warnings; # This test was generated with Dist::Zilla::Plugin::Test::MixedScripts v0.1.5. use Test2::Tools::Basic 1.302200; use Test::MixedScripts qw( file_scripts_ok ); my @scxs = ( ); my @files = ( 'lib/Net/CIDR/Set.pm', 'lib/Net/CIDR/Set/IPv4.pm', 'lib/Net/CIDR/Set/IPv6.pm', 't/00-load.t', 't/00-report-prereqs.dd', 't/00-report-prereqs.t', 't/author-clean-namespaces.t', 't/author-critic.t', 't/author-eof.t', 't/author-eol.t', 't/author-minimum-version.t', 't/author-mixed-unicode-scripts.t', 't/author-no-tabs.t', 't/author-pod-coverage.t', 't/author-pod-linkcheck.t', 't/author-pod-spell.t', 't/author-pod-syntax.t', 't/author-portability.t', 't/basic.t', 't/etc/perlcritic.rc', 't/ipv6.t', 't/is_cidr.t', 't/misc.t', 't/octal.t', 't/operations.t', 't/private.t', 't/release-cpan-changes.t', 't/release-dist-manifest.t', 't/release-fixme.t', 't/release-kwalitee.t', 't/release-trailing-space.t', 't/release-unused-vars.t' ); file_scripts_ok($_, { scripts => \@scxs } ) for @files; done_testing; Net-CIDR-Set-0.19/t/author-pod-spell.t0000644000175000017500000000101315044372357015125 0ustar rrrr BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } use strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::PodSpelling 2.007006 use Test::Spelling 0.17; use Pod::Wordlist; add_stopwords(); all_pod_files_spelling_ok( qw( bin lib ) ); __DATA__ Andy Armstrong Brian CIDR Eckardt Gottreu IPv4 IPv6 Inc Message Net Palmquist Robert Rothenberg Set Stig Systems Thomas andy gottreu lib masse rrwo stigtsp superset Net-CIDR-Set-0.19/t/author-no-tabs.t0000644000175000017500000000224415044372357014600 0ustar rrrr BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::NoTabs 0.15 use Test::More 0.88; use Test::NoTabs; my @files = ( 'lib/Net/CIDR/Set.pm', 'lib/Net/CIDR/Set/IPv4.pm', 'lib/Net/CIDR/Set/IPv6.pm', 't/00-load.t', 't/00-report-prereqs.dd', 't/00-report-prereqs.t', 't/author-clean-namespaces.t', 't/author-critic.t', 't/author-eof.t', 't/author-eol.t', 't/author-minimum-version.t', 't/author-mixed-unicode-scripts.t', 't/author-no-tabs.t', 't/author-pod-coverage.t', 't/author-pod-linkcheck.t', 't/author-pod-spell.t', 't/author-pod-syntax.t', 't/author-portability.t', 't/basic.t', 't/etc/perlcritic.rc', 't/ipv6.t', 't/is_cidr.t', 't/misc.t', 't/octal.t', 't/operations.t', 't/private.t', 't/release-cpan-changes.t', 't/release-dist-manifest.t', 't/release-fixme.t', 't/release-kwalitee.t', 't/release-trailing-space.t', 't/release-unused-vars.t' ); notabs_ok($_) foreach @files; done_testing; Net-CIDR-Set-0.19/t/author-clean-namespaces.t0000644000175000017500000000056315044372357016436 0ustar rrrr BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::CleanNamespaces 0.006 use Test::More 0.94; use Test::CleanNamespaces 0.15; subtest all_namespaces_clean => sub { all_namespaces_clean() }; done_testing; Net-CIDR-Set-0.19/t/release-dist-manifest.t0000644000175000017500000000033115044372357016115 0ustar rrrr BEGIN { unless ($ENV{RELEASE_TESTING}) { print qq{1..0 # SKIP these tests are for release candidate testing\n}; exit } } use strict; use warnings; use Test::More; use Test::DistManifest; manifest_ok(); Net-CIDR-Set-0.19/t/author-critic.t0000644000175000017500000000037515044372357014515 0ustar rrrr#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } use strict; use warnings; use Test::Perl::Critic %{+{ "-profile" => "t/etc/perlcritic.rc", }}; all_critic_ok(); Net-CIDR-Set-0.19/t/misc.t0000644000175000017500000000136715044372357012675 0ustar rrrr#!perl use strict; use warnings; use Test::More tests => 6; use Net::CIDR::Set; { eval { Net::CIDR::Set->new( 'foo' ) }; like $@, qr{Can't decode}, 'parse error on new'; } { my $set = Net::CIDR::Set->new; eval { $set->add( 'foo' ) }; like $@, qr{Can't decode}, 'parse error on add'; eval { $set->add( '10.0.0.0/8' ) }; ok !$@, 'can still parse ipv4'; eval { $set->add( '::' ) }; like $@, qr{Can't decode}, 'ipv4 personality set'; } { my $set = Net::CIDR::Set->new; eval { $set->add( 'foo' ) }; like $@, qr{Can't decode}, 'parse error on add'; eval { $set->add( '::' ) }; ok !$@, 'can still parse ipv6'; # eval { $set->add( '10.0.0.0/8' ) }; # like $@, qr{Can't decode}, 'ipv6 personality set'; } # vim:ts=2:sw=2:et:ft=perl Net-CIDR-Set-0.19/t/octal.t0000644000175000017500000000031615044372357013035 0ustar rrrr#!perl use strict; use warnings; use Test::More tests => 1; use Net::CIDR::Set; my $priv = eval { Net::CIDR::Set->new("010.0.0.0/8") }; like $@, qr{Can't decode 010.0.0.0/8}, "parse error with octal"; Net-CIDR-Set-0.19/t/author-eol.t0000644000175000017500000000227615044372357014021 0ustar rrrr BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::EOL 0.19 use Test::More 0.88; use Test::EOL; my @files = ( 'lib/Net/CIDR/Set.pm', 'lib/Net/CIDR/Set/IPv4.pm', 'lib/Net/CIDR/Set/IPv6.pm', 't/00-load.t', 't/00-report-prereqs.dd', 't/00-report-prereqs.t', 't/author-clean-namespaces.t', 't/author-critic.t', 't/author-eof.t', 't/author-eol.t', 't/author-minimum-version.t', 't/author-mixed-unicode-scripts.t', 't/author-no-tabs.t', 't/author-pod-coverage.t', 't/author-pod-linkcheck.t', 't/author-pod-spell.t', 't/author-pod-syntax.t', 't/author-portability.t', 't/basic.t', 't/etc/perlcritic.rc', 't/ipv6.t', 't/is_cidr.t', 't/misc.t', 't/octal.t', 't/operations.t', 't/private.t', 't/release-cpan-changes.t', 't/release-dist-manifest.t', 't/release-fixme.t', 't/release-kwalitee.t', 't/release-trailing-space.t', 't/release-unused-vars.t' ); eol_unix_ok($_, { trailing_whitespace => 1 }) foreach @files; done_testing; Net-CIDR-Set-0.19/t/ipv6.t0000644000175000017500000000156115044372357012622 0ustar rrrr#!perl use strict; use warnings; use Test::More tests => 6; use Net::CIDR::Set; { ok my $set = eval { Net::CIDR::Set->new( '2001:0db8:1234::/48' ) }, 'parsed'; ok !$@, 'no error' or diag $@; my @r = $set->as_range_array( 2 ); is_deeply [@r], ['2001:db8:1234::-2001:db8:1234:ffff:ffff:ffff:ffff:ffff'], 'range'; } { ok my $set = eval { Net::CIDR::Set->new( '2001:10::/28', '2001::/32', '2001:db8::/32', '2002::/16', '::/128', '::1/128', '::ffff:0:0/96', 'fc00::/7', 'fe80::/10', 'fec0::/10', 'ff00::/8', ); }, 'parsed'; ok !$@, 'no error' or diag $@; my @r = $set->as_cidr_array( 1 ); is_deeply [@r], [ '::/127', '::ffff:0:0/96', '2001::/32', '2001:10::/28', '2001:db8::/32', '2002::/16', 'fc00::/7', 'fe80::/9', 'ff00::/8' ], 'correct data'; } # vim:ts=2:sw=2:et:ft=perl Net-CIDR-Set-0.19/t/is_cidr.t0000644000175000017500000000375515044372357013361 0ustar rrrr#!perl use strict; use warnings; use Test::More tests => 38; use Net::CIDR::Set; # These tests are meant to exercise the _is_cidr() function. # # as_string -> as_range_array -> iterate_ranges -> decode -> _is_cidr { # 18 tests my @input = ( "194.79.0.0-194.79.1.255", "194.79.0.0-194.79.1.254", "194.79.0.1-194.79.1.255", "85.63.41.0-85.63.41.15", "85.63.41.0-85.63.41.13", "85.63.41.2-85.63.41.13", "85.63.41.2-85.63.41.15", '2001:0db8:1234::/48', '2001:0db8:1234::/48, 2001:0db8:1235::/48', '2001:0db8:1235::/48, 2001:0db8:1236::/48', '2001:0db8:1234::-2001:0db8:1234:ffff::', '2001:0db8:1234::-2001:0db8:1235:ffff::', '2001:0db8:1235::-2001:0db8:1236:ffff::', '2001:0db8:1234::-2001:0db8:1235::', "60.200.0.0/24, 60.200.1.0/24, 60.200.2.0/24, 60.200.3.0/24", "60.200.0.0/24, 60.200.1.0/24, 60.200.2.0/24", "60.200.0.0/24, 60.200.2.0/24", "60.200.0.0/24, 60.200.1.0/25", ); # 16 more tests for my $i (0..7) { my $j = $i + 1; push @input, "60.200.$i.0/24, 60.200.$j.0/24"; push @input, "60:200:${i}::/48, 60:200:${j}::/48"; } for my $orig_string (@input) { my $set = Net::CIDR::Set->new($orig_string); my $new_string = $set->as_string(); my $s2 = Net::CIDR::Set->new($new_string); ok $set->equals( $s2 ) or diag("$orig_string vs $new_string", "\n\t(strings needn't be identical, just logically equivalent)"); } } { # 4 tests my %input = ( "60.200.0.0/24, 60.200.1.0/24, 60.200.2.0/24, 60.200.3.0/24" => ['60.200.0.0/22'], "60.200.0.0/24, 60.200.1.0/24, 60.200.2.0/24" => ['60.200.0.0-60.200.2.255'], "60.200.0.0/24, 60.200.2.0/24" => ['60.200.0.0/24', '60.200.2.0/24'], "60.200.0.0/24, 60.200.1.0/25" => ['60.200.0.0-60.200.1.127'], ); for my $orig_string (sort keys %input) { my $set = Net::CIDR::Set->new($orig_string); my @range = $set->as_range_array(); is_deeply(\@range, $input{$orig_string}); } } # vim:ts=2:sw=2:et:ft=perl Net-CIDR-Set-0.19/t/author-portability.t0000644000175000017500000000033215044372357015573 0ustar rrrr BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } use strict; use warnings; use Test::More; use Test::Portability::Files; run_tests(); Net-CIDR-Set-0.19/t/00-report-prereqs.dd0000644000175000017500000000611515044372357015271 0ustar rrrrdo { my $x = { 'build' => { 'requires' => { 'ExtUtils::MakeMaker' => '7.22', 'Module::Metadata' => '1.000015' } }, 'configure' => { 'requires' => { 'ExtUtils::MakeMaker' => '0' } }, 'develop' => { 'requires' => { 'Dist::Zilla::Plugin::UsefulReadme' => 'v0.2.0', 'Pod::Coverage::TrustPod' => '0', 'Pod::Markdown::Github' => '0', 'Software::Security::Policy::Individual' => '0.10', 'Test2::Tools::Basic' => '1.302200', 'Test::CPAN::Changes' => '0.19', 'Test::CleanNamespaces' => '0.15', 'Test::DistManifest' => '0', 'Test::EOF' => '0', 'Test::EOL' => '0', 'Test::Kwalitee' => '1.21', 'Test::MinimumVersion' => '0', 'Test::MixedScripts' => 'v0.3.0', 'Test::More' => '0.88', 'Test::NoTabs' => '0', 'Test::Perl::Critic' => '0', 'Test::Pod' => '1.41', 'Test::Pod::Coverage' => '1.08', 'Test::Pod::LinkCheck' => '0', 'Test::Portability::Files' => '0', 'Test::Spelling' => '0.17', 'Test::TrailingSpace' => '0.0203', 'Test::Vars' => '0.015' } }, 'runtime' => { 'requires' => { 'Carp' => '0', 'namespace::autoclean' => '0', 'overload' => '0', 'perl' => 'v5.14.0', 'strict' => '0', 'warnings' => '0' } }, 'test' => { 'recommends' => { 'CPAN::Meta' => '2.120900' }, 'requires' => { 'Data::Dumper' => '0', 'File::Spec' => '0', 'Module::Metadata' => '1.000015', 'Test::More' => '0' } } }; $x; }Net-CIDR-Set-0.19/t/basic.t0000644000175000017500000000347015044372357013020 0ustar rrrr#!perl use strict; use warnings; use Test::More tests => 10; use Net::CIDR::Set; { ok defined( my $set = Net::CIDR::Set->new ), "set created OK"; isa_ok $set, 'Net::CIDR::Set'; $set->add( '127.0.0.1' ); my @got = $set->as_address_array; is_deeply [@got], ['127.0.0.1'], "got address"; } { my $set = Net::CIDR::Set->new; $set->add( '192.168.0.0/16' ); { my @got = $set->as_cidr_array; is_deeply [@got], ['192.168.0.0/16'], "got cidr"; } $set->remove( '192.168.0.65' ); { my @got = $set->as_range_array; is_deeply [@got], [ '192.168.0.0-192.168.0.64', '192.168.0.66-192.168.255.255' ], "got range"; my $s2 = Net::CIDR::Set->new( @got ); ok $set->equals( $s2 ), "can reparse"; } { my @got = $set->as_cidr_array; is_deeply [@got], [ '192.168.0.0/26', '192.168.0.64', '192.168.0.66/31', '192.168.0.68/30', '192.168.0.72/29', '192.168.0.80/28', '192.168.0.96/27', '192.168.0.128/25', '192.168.1.0/24', '192.168.2.0/23', '192.168.4.0/22', '192.168.8.0/21', '192.168.16.0/20', '192.168.32.0/19', '192.168.64.0/18', '192.168.128.0/17' ], "got cidr"; my $s2 = Net::CIDR::Set->new( @got ); ok $set->equals( $s2 ), "can reparse"; } } { my @private = map { Net::CIDR::Set->new( $_ ) } '10.0.0.0/8', '192.168.0.0/16', '172.16.0.0/12'; my $all_priv = Net::CIDR::Set->new; for my $priv ( @private ) { $all_priv = $all_priv->union( $priv ); } my @got = $all_priv->as_cidr_array; is_deeply [@got], [ '10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', ], "union"; } { my $s1 = Net::CIDR::Set->new( '10.0.0.0/9' ); my $s2 = Net::CIDR::Set->new( '10.128.0.0/9' ); my $hit = $s1->intersection( $s2 ); ok $hit->is_empty, "no intersection" or diag "got $hit"; } # vim:ts=2:sw=2:et:ft=perl Net-CIDR-Set-0.19/t/release-kwalitee.t0000644000175000017500000000052715044372357015162 0ustar rrrr BEGIN { unless ($ENV{RELEASE_TESTING}) { print qq{1..0 # SKIP these tests are for release candidate testing\n}; exit } } # this test was generated with Dist::Zilla::Plugin::Test::Kwalitee 2.12 use strict; use warnings; use Test::More 0.88; use Test::Kwalitee 1.21 'kwalitee_ok'; kwalitee_ok( qw( -use_strict ) ); done_testing; Net-CIDR-Set-0.19/t/release-trailing-space.t0000644000175000017500000000116315044372357016254 0ustar rrrr#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { print qq{1..0 # SKIP these tests are for release candidate testing\n}; exit } } use strict; use warnings; use Test::More; eval "use Test::TrailingSpace"; if ($@) { plan skip_all => "Test::TrailingSpace required for trailing space test."; } else { plan tests => 1; } # TODO: add .pod, .PL, the README/Changes/TODO/etc. documents and possibly # some other stuff. my $finder = Test::TrailingSpace->new( { root => '.', filename_regex => qr#\.(?:p[lm]|pod)\z#, }, ); # TEST $finder->no_trailing_space( "No trailing space was found." ); Net-CIDR-Set-0.19/t/release-cpan-changes.t0000644000175000017500000000055315044372357015703 0ustar rrrr BEGIN { unless ($ENV{RELEASE_TESTING}) { print qq{1..0 # SKIP these tests are for release candidate testing\n}; exit } } use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::CPAN::Changes 0.013 use Test::More 0.96 tests => 1; use Test::CPAN::Changes; subtest 'changes_ok' => sub { changes_file_ok('Changes'); }; Net-CIDR-Set-0.19/t/release-unused-vars.t0000644000175000017500000000035115044372357015624 0ustar rrrr BEGIN { unless ($ENV{RELEASE_TESTING}) { print qq{1..0 # SKIP these tests are for release candidate testing\n}; exit } } use Test::More 0.96 tests => 1; use Test::Vars; subtest 'unused vars' => sub { all_vars_ok(); }; Net-CIDR-Set-0.19/t/release-fixme.t0000644000175000017500000000040515044372357014460 0ustar rrrr#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { print qq{1..0 # SKIP these tests are for release candidate testing\n}; exit } } # This test is generated by Dist::Zilla::Plugin::Test::Fixme use strict; use warnings; use Test::Fixme; run_tests(); Net-CIDR-Set-0.19/t/private.t0000644000175000017500000000750715044372357013416 0ustar rrrr#!perl use strict; use warnings; use Test::More tests => 150; use Net::CIDR::Set; use Net::CIDR::Set::IPv4; use Net::CIDR::Set::IPv6; { # _inc for my $b ( 0 .. 31 ) { my $n = 1 << $b; my $p = $n - 1; my $q = $n + 1; is unpack( 'N', Net::CIDR::Set::_inc( pack 'N', $p ) ), $n, "_inc($p) == $n"; is unpack( 'N', Net::CIDR::Set::_inc( pack 'N', $n ) ), $q, "_inc($n) == $q"; is unpack( 'N', Net::CIDR::Set::_dec( pack 'N', $n ) ), $p, "_dec($n) == $p"; is unpack( 'N', Net::CIDR::Set::_dec( pack 'N', $q ) ), $n, "_dec($q) == $n"; } my @big = ( { name => '0 to 1', before => [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], after => [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ] }, { name => 'wrap some', before => [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255 ], after => [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ] }, { name => 'wrap all', before => [ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ], after => [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] }, ); for my $b ( @big ) { my $name = $b->{name}; my @inc = unpack 'C*', Net::CIDR::Set::_inc( pack 'C*', @{ $b->{before} } ); is_deeply [@inc], $b->{after}, "$name: _inc"; my @dec = unpack 'C*', Net::CIDR::Set::_dec( pack 'C*', @inc ); is_deeply [@dec], $b->{before}, "$name: _dec"; } } { my @case = ( { ip => '127.0.0.1', expect => [ [ 0, 127, 0, 0, 1 ], [ 0, 127, 0, 0, 2 ] ] }, { ip => '192.168.0.0/16', expect => [ [ 0, 192, 168, 0, 0 ], [ 0, 192, 169, 0, 0 ] ] }, { ip => '192.168.0.0/255.255.0.0', expect => [ [ 0, 192, 168, 0, 0 ], [ 0, 192, 169, 0, 0 ] ] }, { ip => '192.168.0.0/0.0.255.255', error => qr{Can't decode} }, { ip => '0.0.0.0/0', expect => [ [ 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0 ] ] }, { ip => '192.168.0.12-192.168.1.13', expect => [ [ 0, 192, 168, 0, 12 ], [ 0, 192, 168, 1, 14 ] ] }, { ip => '0.0.0.0-255.255.255.255', expect => [ [ 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0 ] ] }, ); for my $case ( @case ) { my @enc = eval { Net::CIDR::Set::IPv4->encode( $case->{ip} ) }; if ( my $error = $case->{error} ) { like $@, $error, 'error'; } else { my @got = map { [ unpack 'C*', $_ ] } @enc; is_deeply [@got], $case->{expect}, "encode $case->{ip}"; } } } { my @case = ( { range => [ [ 0, 127, 0, 0, 1 ], [ 0, 127, 0, 0, 2 ] ], generic => 0, expect => '127.0.0.1', }, { range => [ [ 0, 127, 0, 0, 1 ], [ 0, 127, 0, 0, 2 ] ], generic => 1, expect => '127.0.0.1/32', }, { range => [ [ 0, 127, 0, 0, 1 ], [ 0, 127, 0, 0, 2 ] ], generic => 2, expect => '127.0.0.1-127.0.0.1', }, { range => [ [ 0, 192, 168, 0, 12 ], [ 0, 192, 168, 1, 14 ] ], generic => 0, expect => '192.168.0.12-192.168.1.13', }, { range => [ [ 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0 ] ], generic => 0, expect => '0.0.0.0/0', }, { range => [ [ 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0 ] ], generic => 1, expect => '0.0.0.0/0', }, { range => [ [ 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0 ] ], generic => 2, expect => '0.0.0.0-255.255.255.255', }, ); for my $case ( @case ) { my $got = Net::CIDR::Set::IPv4->decode( ( map { pack 'C*', @$_ } @{ $case->{range} } ), $case->{generic} ); is $got, $case->{expect}, "$got"; } } { is Net::CIDR::Set::_conjunction( or => 1, 2, 3 ), '1, 2 or 3', '_conjunction'; is Net::CIDR::Set::_and( 1, 2, 3 ), '1, 2 and 3', '_and'; } # vim:ts=2:sw=2:et:ft=perl Net-CIDR-Set-0.19/t/etc/0000775000175000017500000000000015044372357012323 5ustar rrrrNet-CIDR-Set-0.19/t/etc/perlcritic.rc0000644000175000017500000000000015044372357014775 0ustar rrrrNet-CIDR-Set-0.19/t/author-pod-linkcheck.t0000644000175000017500000000074115044372357015750 0ustar rrrr#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } use strict; use warnings; use Test::More; foreach my $env_skip ( qw( SKIP_POD_LINKCHECK ) ){ plan skip_all => "\$ENV{$env_skip} is set, skipping" if $ENV{$env_skip}; } eval "use Test::Pod::LinkCheck"; if ( $@ ) { plan skip_all => 'Test::Pod::LinkCheck required for testing POD'; } else { Test::Pod::LinkCheck->new->all_pod_ok; } Net-CIDR-Set-0.19/t/author-pod-syntax.t0000644000175000017500000000045415044372357015344 0ustar rrrr#!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(); Net-CIDR-Set-0.19/t/author-pod-coverage.t0000644000175000017500000000212215044372357015603 0ustar rrrr#!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::Test::Pod::Coverage::Configurable 0.07. use Test::Pod::Coverage 1.08; use Test::More 0.88; BEGIN { if ( $] <= 5.008008 ) { plan skip_all => 'These tests require Pod::Coverage::TrustPod, which only works with Perl 5.8.9+'; } } use Pod::Coverage::TrustPod; my %skip = map { $_ => 1 } qw( ); my @modules; for my $module ( all_modules() ) { next if $skip{$module}; push @modules, $module; } plan skip_all => 'All the modules we found were excluded from POD coverage test.' unless @modules; plan tests => scalar @modules; my %trustme = (); my @also_private; for my $module ( sort @modules ) { pod_coverage_ok( $module, { coverage_class => 'Pod::Coverage::TrustPod', also_private => \@also_private, trustme => $trustme{$module} || [], }, "pod coverage for $module" ); } done_testing(); Net-CIDR-Set-0.19/t/author-eof.t0000644000175000017500000000064115044372357014005 0ustar rrrr BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } use strict; use warnings; use Test::More; # Generated by Dist::Zilla::Plugin::Test::EOF 0.0600 eval "use Test::EOF"; plan skip_all => 'Test::EOF required to test for correct end of file flag' if $@; all_perl_files_ok({ minimum_newlines => 1, maximum_newlines => 4 }); done_testing(); Net-CIDR-Set-0.19/t/author-minimum-version.t0000644000175000017500000000035615044372357016375 0ustar rrrr BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } use strict; use warnings; use Test::More; use Test::MinimumVersion; all_minimum_version_from_metayml_ok(); Net-CIDR-Set-0.19/t/00-report-prereqs.t0000644000175000017500000001362515044372357015151 0ustar rrrr#!perl use strict; use warnings; # This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.029 use Test::More tests => 1; use Module::Metadata; use File::Spec; # from $version::LAX my $lax_version_re = qr/(?: undef | (?: (?:[0-9]+) (?: \. | (?:\.[0-9]+) (?:_[0-9]+)? )? | (?:\.[0-9]+) (?:_[0-9]+)? ) | (?: v (?:[0-9]+) (?: (?:\.[0-9]+)+ (?:_[0-9]+)? )? | (?:[0-9]+)? (?:\.[0-9]+){2,} (?:_[0-9]+)? ) )/x; # hide optional CPAN::Meta modules from prereq scanner # and check if they are available my $cpan_meta = "CPAN::Meta"; my $cpan_meta_pre = "CPAN::Meta::Prereqs"; my $HAS_CPAN_META = eval "require $cpan_meta; $cpan_meta->VERSION('2.120900')" && eval "require $cpan_meta_pre"; ## no critic # Verify requirements? my $DO_VERIFY_PREREQS = 1; sub _max { my $max = shift; $max = ( $_ > $max ) ? $_ : $max for @_; return $max; } sub _merge_prereqs { my ($collector, $prereqs) = @_; # CPAN::Meta::Prereqs object if (ref $collector eq $cpan_meta_pre) { return $collector->with_merged_prereqs( CPAN::Meta::Prereqs->new( $prereqs ) ); } # Raw hashrefs for my $phase ( keys %$prereqs ) { for my $type ( keys %{ $prereqs->{$phase} } ) { for my $module ( keys %{ $prereqs->{$phase}{$type} } ) { $collector->{$phase}{$type}{$module} = $prereqs->{$phase}{$type}{$module}; } } } return $collector; } my @include = qw( ); my @exclude = qw( ); # Add static prereqs to the included modules list my $static_prereqs = do './t/00-report-prereqs.dd'; # Merge all prereqs (either with ::Prereqs or a hashref) my $full_prereqs = _merge_prereqs( ( $HAS_CPAN_META ? $cpan_meta_pre->new : {} ), $static_prereqs ); # Add dynamic prereqs to the included modules list (if we can) my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; my $cpan_meta_error; if ( $source && $HAS_CPAN_META && (my $meta = eval { CPAN::Meta->load_file($source) } ) ) { $full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs); } else { $cpan_meta_error = $@; # capture error from CPAN::Meta->load_file($source) $source = 'static metadata'; } my @full_reports; my @dep_errors; my $req_hash = $HAS_CPAN_META ? $full_prereqs->as_string_hash : $full_prereqs; # Add static includes into a fake section for my $mod (@include) { $req_hash->{other}{modules}{$mod} = 0; } for my $phase ( qw(configure build test runtime develop other) ) { next unless $req_hash->{$phase}; next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING}); for my $type ( qw(requires recommends suggests conflicts modules) ) { next unless $req_hash->{$phase}{$type}; my $title = ucfirst($phase).' '.ucfirst($type); my @reports = [qw/Module Want Have/]; for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) { next if grep { $_ eq $mod } @exclude; my $want = $req_hash->{$phase}{$type}{$mod}; $want = "undef" unless defined $want; $want = "any" if !$want && $want == 0; if ($mod eq 'perl') { push @reports, ['perl', $want, $]]; next; } my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required"; my $file = $mod; $file =~ s{::}{/}g; $file .= ".pm"; my ($prefix) = grep { -e File::Spec->catfile($_, $file) } @INC; if ($prefix) { my $have = Module::Metadata->new_from_file( File::Spec->catfile($prefix, $file) )->version; $have = "undef" unless defined $have; push @reports, [$mod, $want, $have]; if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META && $type eq 'requires' ) { if ( $have !~ /\A$lax_version_re\z/ ) { push @dep_errors, "$mod version '$have' cannot be parsed ($req_string)"; } elsif ( ! $full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) { push @dep_errors, "$mod version '$have' is not in required range '$want'"; } } } else { push @reports, [$mod, $want, "missing"]; if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) { push @dep_errors, "$mod is not installed ($req_string)"; } } } if ( @reports ) { push @full_reports, "=== $title ===\n\n"; my $ml = _max( map { length $_->[0] } @reports ); my $wl = _max( map { length $_->[1] } @reports ); my $hl = _max( map { length $_->[2] } @reports ); if ($type eq 'modules') { splice @reports, 1, 0, ["-" x $ml, "", "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s\n", -$ml, $_->[0], $hl, $_->[2]) } @reports; } else { splice @reports, 1, 0, ["-" x $ml, "-" x $wl, "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s %*s\n", -$ml, $_->[0], $wl, $_->[1], $hl, $_->[2]) } @reports; } push @full_reports, "\n"; } } } if ( @full_reports ) { diag "\nVersions for all modules listed in $source (including optional ones):\n\n", @full_reports; } if ( $cpan_meta_error || @dep_errors ) { diag "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n"; } if ( $cpan_meta_error ) { my ($orig_source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; diag "\nCPAN::Meta->load_file('$orig_source') failed with: $cpan_meta_error\n"; } if ( @dep_errors ) { diag join("\n", "\nThe following REQUIRED prerequisites were not satisfied:\n", @dep_errors, "\n" ); } pass('Reported prereqs'); # vim: ts=4 sts=4 sw=4 et: Net-CIDR-Set-0.19/t/operations.t0000644000175000017500000000132115044372357014113 0ustar rrrr#!perl use strict; use warnings; use Test::More tests => 4; use Net::CIDR::Set; use Data::Dumper; { my $s1 = Net::CIDR::Set->new( '0.0.0.0-0.0.0.255', '0.0.2.0-255.255.255.255' ); my $s2 = Net::CIDR::Set->new( '0.0.1.0-0.0.1.255' ); my $s3 = $s1->union( $s2 ); is_deeply [ $s3->as_cidr_array ], ['0.0.0.0/0'], 'union'; my $s4 = $s1->intersection( $s2 ); is_deeply [ $s4->as_cidr_array ], [], 'intersection'; my $s5 = $s1->complement->union( $s2->complement->union ); is_deeply [ $s5->as_cidr_array ], ['0.0.0.0/0'], 'complement + union'; my $s6 = $s1->complement->intersection( $s2->complement ); is_deeply [ $s6->as_cidr_array ], [], 'complement + intersection'; } # vim:ts=2:sw=2:et:ft=perl Net-CIDR-Set-0.19/t/00-load.t0000644000175000017500000000031015044372357013061 0ustar rrrruse Test::More tests => 3; BEGIN { use_ok( 'Net::CIDR::Set' ); use_ok( 'Net::CIDR::Set::IPv4' ); use_ok( 'Net::CIDR::Set::IPv6' ); } diag( "Testing Net::CIDR::Set $Net::CIDR::Set::VERSION" ); Net-CIDR-Set-0.19/lib/0000775000175000017500000000000015044372357012053 5ustar rrrrNet-CIDR-Set-0.19/lib/Net/0000775000175000017500000000000015044372357012601 5ustar rrrrNet-CIDR-Set-0.19/lib/Net/CIDR/0000775000175000017500000000000015044372357013322 5ustar rrrrNet-CIDR-Set-0.19/lib/Net/CIDR/Set/0000775000175000017500000000000015044372357014055 5ustar rrrrNet-CIDR-Set-0.19/lib/Net/CIDR/Set/IPv6.pm0000644000175000017500000000777515044372357015215 0ustar rrrrpackage Net::CIDR::Set::IPv6; use warnings; use strict; use Carp; use namespace::autoclean; # ABSTRACT: Encode / decode IPv6 addresses our $VERSION = '0.19'; sub new { bless \my $x, shift } sub _pack_ipv4 { my @nums = split /[.]/, shift, -1; return unless @nums == 4; for ( @nums ) { return unless /^\d{1,3}$/ and !/^0\d{1,2}$/ and $_ < 256; } return pack "CC*", 0, @nums; } sub _426 { my @nums = split /[.]/, shift, -1; return if grep $_ > 255, @nums; return join( ":", unpack( 'H*', pack 'C*', @nums ) =~ /..../g ); } sub _pack { my $ip = shift; return pack( 'H*', '0' x 33 ) if $ip eq '::'; return if $ip =~ /^:/ and $ip !~ s/^::/:/; return if $ip =~ /:$/ and $ip !~ s/::$/:/; my @nums = split /:/, $ip, -1; return unless @nums <= 8; my ( $empty, $ipv4, $str ) = ( 0, '', '' ); for ( @nums ) { return if $ipv4; $str .= "0" x ( 4 - length ) . $_, next if /^[a-fA-F\d]{1,4}$/; do { return if $empty++ }, $str .= "X", next if $_ eq ''; next if $ipv4 = _pack_ipv4( $_ ); return; } return if $ipv4 and @nums > 6; $str =~ s/X/"0" x (($ipv4 ? 25 : 33)-length($str))/e if $empty; return pack( "H*", "00" . $str ) . $ipv4; } sub _unpack { return _compress_ipv6( join( ":", unpack( "xH*", shift ) =~ /..../g ) ); } # Replace longest run of null blocks with a double colon sub _compress_ipv6 { my $ip = shift; if ( my @runs = $ip =~ /((?:(?:^|:)(?:0000))+:?)/g ) { my $max = $runs[0]; for ( @runs[ 1 .. $#runs ] ) { $max = $_ if length( $max ) < length; } $ip =~ s/$max/::/; } $ip =~ s/:0{1,3}/:/g; return $ip; } sub _width2bits { my ( $width, $size ) = @_; return pack 'B*', ( '1' x ( $width + 8 ) ) . ( '0' x ( $size - $width ) ); } sub _is_cidr { my ( $lo, $hi ) = @_; my $mask = ~( $lo ^ $hi ); my $bits = unpack 'B*', $mask; return unless $hi eq ($lo | $hi); return unless $bits =~ /^(1*)0*$/; return length( $1 ) - 8; } sub _encode { my ( $self, $ip ) = @_; if ( $ip =~ m{^(.+?)/(.+)$} ) { my $mask = $2; return unless my $addr = _pack( $1 ); return unless my $bits = _width2bits( $mask, 128 ); return ( $addr & $bits, Net::CIDR::Set::_inc( $addr | ~$bits ) ); } elsif ( $ip =~ m{^(.+?)-(.+)$} ) { my ( $from, $to ) = ( $1, $2 ); return unless my $lo = _pack( $from ); return unless my $hi = _pack( $to ); return ( $lo, Net::CIDR::Set::_inc( $hi ) ); } else { return $self->_encode( "$ip/128" ); } } sub encode { my ( $self, $ip ) = @_; my @r = $self->_encode( $ip ) or croak "Can't decode $ip as an IPv6 address"; return @r; } sub decode { my $self = shift; my $lo = shift; my $hi = Net::CIDR::Set::_dec( shift ); my $generic = shift || 0; if ( $generic < 1 && $lo eq $hi ) { # Single address return _unpack( $lo ); } elsif ( $generic < 2 && defined( my $w = _is_cidr( $lo, $hi ) ) ) { # Valid CIDR range return join '/', _unpack( $lo ), $w; } else { # General range return join '-', _unpack( $lo ), _unpack( $hi ); } } sub nbits { 128 } 1; __END__ =pod =encoding UTF-8 =head1 NAME Net::CIDR::Set::IPv6 - Encode / decode IPv6 addresses =head1 VERSION version 0.19 =for Pod::Coverage new =for Pod::Coverage encode =for Pod::Coverage decode =for Pod::Coverage nbits =head1 SOURCE The development version is on github at L and may be cloned from L =head1 SUPPORT 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 Andy Armstrong =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2009, 2014, 2025 by Message Systems, Inc. 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 Net-CIDR-Set-0.19/lib/Net/CIDR/Set/IPv4.pm0000644000175000017500000000605315044372357015177 0ustar rrrrpackage Net::CIDR::Set::IPv4; use warnings; use strict; use Carp; use namespace::autoclean; # ABSTRACT: Encode / decode IPv4 addresses our $VERSION = '0.19'; sub new { bless \my $x, shift } sub _pack { my @nums = split /[.]/, shift, -1; return unless @nums == 4; for ( @nums ) { return unless /^\d{1,3}$/ and !/^0\d{1,2}$/ and $_ < 256; } return pack "CC*", 0, @nums; } sub _unpack { join ".", unpack "xC*", shift } sub _width2bits { my ( $width, $size ) = @_; return pack 'B*', ( '1' x ( $width + 8 ) ) . ( '0' x ( $size - $width ) ); } sub _ip2bits { my $ip = shift or return; vec( $ip, 0, 8 ) = 255; my $bits = unpack 'B*', $ip; return unless $bits =~ /^1*0*$/; # Valid mask? return $ip; } sub _is_cidr { my ( $lo, $hi ) = @_; my $mask = ~( $lo ^ $hi ); my $bits = unpack 'B*', $mask; return unless $hi eq ($lo | $hi); return unless $bits =~ /^(1*)0*$/; return length( $1 ) - 8; } sub _encode { my ( $self, $ip ) = @_; if ( $ip =~ m{^(.+?)/(.+)$} ) { my $mask = $2; return unless my $addr = _pack( $1 ); return unless my $bits = ( $mask =~ /^\d+$/ ) ? _width2bits( $mask, 32 ) : _ip2bits( _pack( $mask ) ); return ( $addr & $bits, Net::CIDR::Set::_inc( $addr | ~$bits ) ); } elsif ( $ip =~ m{^(.+?)-(.+)$} ) { return unless my $lo = _pack( $1 ); return unless my $hi = _pack( $2 ); return ( $lo, Net::CIDR::Set::_inc( $hi ) ); } else { return $self->_encode( "$ip/32" ); } } sub encode { my ( $self, $ip ) = @_; my @r = $self->_encode( $ip ) or croak "Can't decode $ip as an IPv4 address"; return @r; } sub decode { my $self = shift; my $lo = shift; my $hi = Net::CIDR::Set::_dec( shift ); my $generic = shift || 0; if ( $generic < 1 && $lo eq $hi ) { # Single address return _unpack( $lo ); } elsif ( $generic < 2 && defined( my $w = _is_cidr( $lo, $hi ) ) ) { # Valid CIDR range return join '/', _unpack( $lo ), $w; } else { # General range return join '-', _unpack( $lo ), _unpack( $hi ); } } sub nbits { 32 } 1; __END__ =pod =encoding UTF-8 =head1 NAME Net::CIDR::Set::IPv4 - Encode / decode IPv4 addresses =head1 VERSION version 0.19 =for Pod::Coverage new =for Pod::Coverage encode =for Pod::Coverage decode =for Pod::Coverage nbits =head1 SOURCE The development version is on github at L and may be cloned from L =head1 SUPPORT 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 Andy Armstrong =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2009, 2014, 2025 by Message Systems, Inc. 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 Net-CIDR-Set-0.19/lib/Net/CIDR/Set.pm0000644000175000017500000004254315044372357014421 0ustar rrrrpackage Net::CIDR::Set; # ABSTRACT: Manipulate sets of IP addresses use v5.14; use warnings; use Carp qw( croak confess ); use Net::CIDR::Set::IPv4; use Net::CIDR::Set::IPv6; use overload '""' => 'as_string'; use namespace::autoclean; our $VERSION = '0.19'; { my %type_map = ( ipv4 => 'Net::CIDR::Set::IPv4', ipv6 => 'Net::CIDR::Set::IPv6', ); sub new { my $self = shift; my $class = ref $self || $self; my $set = bless { ranges => [] }, $class; my $opt = 'HASH' eq ref $_[0] ? shift : {}; if ( defined( my $type = delete $opt->{type} ) ) { my $coder_class = $type_map{$type} || $type; $set->{coder} = $coder_class->new; } elsif ( ref $self ) { $set->{coder} = $self->{coder}; } my @unk = keys %$opt; croak "Unknown options: ", _and( sort @unk ) if @unk; $set->add( @_ ) if @_; return $set; } } # Return the index of the first element >= the supplied value. If the # supplied value is larger than any element in the list the returned # value will be equal to the size of the list. sub _find_pos { my $self = shift; my $val = shift; my $low = shift || 0; my $high = scalar( @{ $self->{ranges} } ); while ( $low < $high ) { my $mid = int( ( $low + $high ) / 2 ); my $cmp = $val cmp $self->{ranges}[$mid]; if ( $cmp < 0 ) { $high = $mid; } elsif ( $cmp > 0 ) { $low = $mid + 1; } else { return $mid; } } return $low; } sub _inc { my @b = reverse unpack 'C*', shift; for ( @b ) { last unless ++$_ == 256; $_ = 0; } return pack 'C*', reverse @b; } sub _dec { my @b = reverse unpack 'C*', shift; for ( @b ) { last unless $_-- == 0; $_ = 255; } return pack 'C*', reverse @b; } sub _guess_coder { my ( $self, $ip ) = @_; for my $class ( qw( Net::CIDR::Set::IPv4 Net::CIDR::Set::IPv6 ) ) { my $coder = $class->new; ( eval { $coder->encode( $ip ) } ); return $coder unless $@; } croak "Can't decode $ip as an IPv4 or IPv6 address"; } sub _encode { my ( $self, $ip ) = @_; my $cdr = $self->{coder} ||= $self->_guess_coder( $ip ); return $cdr->encode( $ip ); } { for my $dele ( qw( _decode _nbits ) ) { no strict 'refs'; ## no critic (ProhibitNoStrict) my $meth = $dele =~ s/^_//r; *{$dele} = sub { my $self = shift; my $cdr = $self->{coder} || croak "Don't know how to $meth yet"; return $cdr->$meth( @_ ); }; } } sub _conjunction { my ( $conj, @list ) = @_; my $last = pop @list; return join " $conj ", join( ', ', @list ), $last; } sub _and { _conjunction( 'and', @_ ) } sub _check_and_coerce { my ( $self, @others ) = @_; my %class = map { eval { ( defined $_ && $_->nbits || '' ) => $_ } } map { $_->{coder} } grep { defined } $self, @others; my @found = sort grep $_, keys %class; croak "Can't mix ", _and( @found ), " bit addresses" if @found > 1; $self->{coder} ||= $class{ $found[0] }; return $self; } sub invert { my $self = shift; my @pad = ( 0 ) x ( $self->_nbits / 8 ); my ( $min, $max ) = map { pack 'C*', $_, @pad } 0, 1; if ( $self->is_empty ) { $self->{ranges} = [ $min, $max ]; return; } if ( $self->{ranges}[0] eq $min ) { shift @{ $self->{ranges} }; } else { unshift @{ $self->{ranges} }, $min; } if ( $self->{ranges}[-1] eq $max ) { pop @{ $self->{ranges} }; } else { push @{ $self->{ranges} }, $max; } } sub copy { my $self = shift; my $copy = $self->new; @{ $copy->{ranges} } = @{ $self->{ranges} }; return $copy; } sub _add_range { my ( $self, $from, $to ) = @_; my $fpos = $self->_find_pos( $from ); my $tpos = $self->_find_pos( _inc( $to ), $fpos ); $from = $self->{ranges}[ --$fpos ] if ( $fpos & 1 ); $to = $self->{ranges}[ $tpos++ ] if ( $tpos & 1 ); splice @{ $self->{ranges} }, $fpos, $tpos - $fpos, ( $from, $to ); } sub add { my ( $self, @addr ) = @_; for my $ip ( map { split /\s*,\s*/ } @addr ) { my ( $lo, $hi ) = $self->_encode( $ip ) or croak "Can't decode $ip"; $self->_add_range( $lo, $hi ); } } sub remove { my $self = shift; $self->invert; $self->add( @_ ); $self->invert; } sub merge { my $self = shift; $self->_check_and_coerce( @_ ); # TODO: This isn't very efficient - and merge gets called from all # sorts of other places. for my $other ( @_ ) { my $iter = $other->_iterate_runs; while ( my ( $from, $to ) = $iter->() ) { $self->_add_range( $from, $to ); } } } *contains = *contains_all; sub contains_all { my $self = shift; my $class = ref $self; return $class->new( @_ )->subset( $self ); } sub contains_any { my $self = shift; my $class = ref $self; return !$class->new( @_ )->intersection( $self )->is_empty; } sub _iterate_runs { my $self = shift; my $pos = 0; my $limit = scalar( @{ $self->{ranges} } ); return sub { return if $pos >= $limit; my @r = @{ $self->{ranges} }[ $pos, $pos + 1 ]; $pos += 2; return @r; }; } sub compliment { croak "That's very kind of you - but I expect you meant complement"; } sub complement { my $new = shift->copy; # TODO: What if it's empty? $new->invert; return $new; } sub union { my $new = shift->copy; $new->merge( @_ ); return $new; } sub intersection { my $self = shift; my $class = ref $self; my $new = $class->new; $new->merge( map { $_->complement } $self, @_ ); $new->invert; return $new; } sub xor { my $self = shift; return $self->union( @_ ) ->intersection( $self->intersection( @_ )->complement ); } sub diff { my $self = shift; my $other = shift; return $self->intersection( $other->union( @_ )->complement ); } sub is_empty { my $self = shift; return @{ $self->{ranges} } == 0; } sub superset { my $other = pop; return $other->subset( reverse( @_ ) ); } sub subset { my $self = shift; my $other = shift || croak "I need two sets to compare"; return $self->equals( $self->intersection( $other ) ); } sub equals { return unless @_; # Array of array refs my @edges = map { $_->{ranges} } @_; my $medge = scalar( @edges ) - 1; POS: for ( my $pos = 0;; $pos++ ) { my $v = $edges[0]->[$pos]; if ( defined( $v ) ) { for ( @edges[ 1 .. $medge ] ) { my $vv = $_->[$pos]; return unless defined( $vv ) && $vv eq $v; } } else { for ( @edges[ 1 .. $medge ] ) { return if defined $_->[$pos]; } } last POS unless defined( $v ); } return 1; } sub iterate_addresses { my ( $self, @args ) = @_; my $iter = $self->_iterate_runs; my @r = (); return sub { while ( 1 ) { @r = $iter->() or return unless @r; return $self->_decode( ( my $last, $r[0] ) = ( $r[0], _inc( $r[0] ) ), @args ) unless $r[0] eq $r[1]; @r = (); } }; } sub iterate_cidr { my ( $self, @args ) = @_; my $iter = $self->_iterate_runs; my $size = $self->_nbits; my @r = (); return sub { while ( 1 ) { @r = $iter->() or return unless @r; unless ( $r[0] eq $r[1] ) { ( my $bits = unpack 'B*', $r[0] ) =~ /(0*)$/; my $pad = length $1; $pad = $size if $pad > $size; while ( 1 ) { my $next = _inc( $r[0] | pack 'B*', ( '0' x ( length( $bits ) - $pad ) ) . ( '1' x $pad ) ); return $self->_decode( ( my $last, $r[0] ) = ( $r[0], $next ), @args ) if $next le $r[1]; $pad--; } } @r = (); } }; } sub iterate_ranges { my ( $self, @args ) = @_; my $iter = $self->_iterate_runs; return sub { return unless my @r = $iter->(); return $self->_decode( @r, @args ); }; } sub as_array { my ( $self, $iter ) = @_; my @addr = (); while ( my $addr = $iter->() ) { push @addr, $addr; } return @addr; } sub as_address_array { my $self = shift; return $self->as_array( $self->iterate_addresses( @_ ) ); } sub as_cidr_array { my $self = shift; return $self->as_array( $self->iterate_cidr( @_ ) ); } sub as_range_array { my $self = shift; return $self->as_array( $self->iterate_ranges( @_ ) ); } sub as_string { join ', ', shift->as_range_array( @_ ) } 1; __END__ =pod =encoding UTF-8 =head1 NAME Net::CIDR::Set - Manipulate sets of IP addresses =head1 VERSION version 0.19 =head1 SYNOPSIS use Net::CIDR::Set; my $priv = Net::CIDR::Set->new( '10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16' ); for my $ip ( @addr ) { if ( $priv->contains( $ip ) ) { print "$ip is private\n"; } } =head1 DESCRIPTION C represents sets of IP addresses and allows standard set operations (union, intersection, membership test etc) to be performed on them. In spite of the name it can work with sets consisting of arbitrary ranges of IP addresses - not just CIDR blocks. Both IPv4 and IPv6 addresses are handled - but they may not be mixed in the same set. You may explicitly set the personality of a set: my $ip4set = Net::CIDR::Set->new({ type => 'ipv4 }, '10.0.0.0/8'); Normally this isn't necessary - the set will guess its personality from the first data that is added to it. =head1 ATTRIBUTES =head2 type Either C, C or the name of a coder class. See L and L for examples of coder classes. =head1 METHODS =head2 new Create a new Net::CIDR::Set. All arguments are optional. May be passed a list of list of IP addresses or ranges which, if present, will be passed to L. The first argument may be a hash reference which will be inspected for named options. Currently the only option that may be passed is L. =head2 invert Invert (negate, complement) a set in-place. my $set = Net::CIDR::Set->new; $set->invert; =head2 copy Make a deep copy of a set. my $set2 = $set->copy; =head2 add Add a number of addresses or ranges to a set. $set->add( '10.0.0.0/8', '192.168.0.32-192.168.0.63', '127.0.0.1' ); It is legal to add ranges that overlap with each other and/or with the ranges already in the set. Overlapping ranges are merged. =head2 remove Remove a number of addresses or ranges from a set. $set->remove( '8.8.0.0/16', '158.152.1.58' ); There is no requirement that the addresses being removed be members of the set. =head2 merge Merge the contents of other sets into this set. $set = Net::CIDR::Set->new; $set->merge($s1, $s2); =head2 contains A synonym for C. =head2 contains_all Return true if the set contains all of the supplied addresses. Given this set: my $set = Net::CIDR::Set->new('244.188.12.0/12'); this condition is true: if ( $set->contains_all('244.188.12.128/32') ) { # ... } while this condition is false: if ( $set->contains_all('244.188.12.0/8') ) { # ... } =head2 contains_any Return true if there is any overlap between the supplied addresses/ranges and the contents of the set. =head2 complement Return a new set that is the complement of this set. my $inv = $set->complement; =head2 union Return a new set that is the union of a number of sets. This is equivalent to a logical OR between sets. my $everything = $east->union($west); =head2 intersection Return a new set that is the intersection of a number of sets. This is equivalent to a logical AND between sets. my $overlap = $north->intersection($south); =head2 xor Return a new set that is the exclusive-or of existing sets. my $xset = $this->xor($that); The resulting set will contain all addresses that are members of one set but not the other. =head2 diff Return a new set containing all the addresses that are present in this set but not another. my $diff = $this->diff($that); =head2 is_empty Return a true value if the set is empty. if ( $set->is_empty ) { print "Nothing there!\n"; } =head2 superset Return true if this set is a superset of the supplied set. =head2 subset Return true if this set is a subset of the supplied set. =head2 equals Return true if this set is identical to another set. if ( $set->equals($foo) ) { print "We have the same addresses.\n"; } =head2 iterate_addresses Return an iterator (a closure) that will return each of the addresses in the set in ascending order. This code my $set = Net::CIDR::Set->new('192.168.37.0/24'); my $iter = $set->iterate_addresses; while ( my $ip = $iter->() ) { print "Got $ip\n"; } outputs 256 distinct addresses from 192.168.37.0 to 192.168.27.255. =head2 iterate_cidr Return an iterator (a closure) that will return each of the CIDR blocks in the set in ascending order. This code my $set = Net::CIDR::Set->new('192.168.37.9-192.168.37.134'); my $iter = $set->iterate_cidr; while ( my $cidr = $iter->() ) { print "Got $cidr\n"; } outputs Got 192.168.37.9 Got 192.168.37.10/31 Got 192.168.37.12/30 Got 192.168.37.16/28 Got 192.168.37.32/27 Got 192.168.37.64/26 Got 192.168.37.128/30 Got 192.168.37.132/31 Got 192.168.37.134 This is the most compact CIDR representation of the set because its limits don't fall on convenient CIDR boundaries. =head2 iterate_ranges Return an iterator (a closure) that will return each of the ranges in the set in ascending order. This code my $set = Net::CIDR::Set->new( '192.168.37.9-192.168.37.134', '127.0.0.1', '10.0.0.0/8' ); my $iter = $set->iterate_ranges; while ( my $range = $iter->() ) { print "Got $range\n"; } outputs Got 10.0.0.0/8 Got 127.0.0.1 Got 192.168.37.9-192.168.37.134 =head2 as_array Convenience method that gathers all of the output from one of the iterators above into an array. my @ranges = $set->as_array( $set->iterate_ranges ); Normally you will use one of C, C or C instead. =head2 as_address_array Return an array containing all of the distinct addresses in a set. Note that this may very easily create a very large array. At the time of writing it is, for example, unlikely that you have enough memory for an array containing all of the possible IPv6 addresses... =head2 as_cidr_array Return an array containing all of the distinct CIDR blocks in a set. =head2 as_range_array Return an array containing all of the ranges in a set. =head2 as_string Return a compact string representation of a set. =for Pod::Coverage compliment =head1 Retrieving Set Contents The following methods allow the contents of a set to be retrieved in various representations. Each of the following methods accepts an optional numeric argument that controls the formatting of the returned addresses. It may take one of the following values: =over =item C<0> Format each range of addresses as compactly as possible. If the range contains only a single address format it as such. If it can be represented as a single CIDR block use CIDR representation (/) otherwise format it as an arbitrary range (-). =item C<1> Always format as either a CIDR block or an arbitrary range even if the range is just a single address. =item C<2> Always use arbitrary range format (-) even if the range is a single address or a legal CIDR block. =back Here's an example of the different formatting options: my $set = Net::CIDR::Set->new( '127.0.0.1', '192.168.37.0/24', '10.0.0.11-10.0.0.17' ); for my $fmt ( 0 .. 2 ) { print "Using format $fmt:\n"; print " $_\n" for $set->as_range_array( $fmt ); } And here's the output from that code: Using format 0: 10.0.0.11-10.0.0.17 127.0.0.1 192.168.37.0/24 Using format 1: 10.0.0.11-10.0.0.17 127.0.0.1/32 192.168.37.0/24 Using format 2: 10.0.0.11-10.0.0.17 127.0.0.1-127.0.0.1 192.168.37.0-192.168.37.255 Note that this option never affects the addresses that are returned; only how they are formatted. For most purposes the formatting argument can be omitted; it's default value is C<0> which provides the most general formatting. =head1 SOURCE The development version is on github at L and may be cloned from L =head1 SUPPORT Only the latest version of this module will be supported. This module requires Perl v5.14 or later. Future releases may only support Perl versions released in the last ten (10) years. 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. =head2 Reporting Security Vulnerabilities If the bug you are reporting has security implications which make it inappropriate to send to a public issue tracker, then see F for instructions how to report security vulnerabilities. =head1 AUTHOR Andy Armstrong The current maintainer is Robert Rothenberg . The encode and decode routines were stolen en masse from Douglas Wilson's L. =head1 CONTRIBUTORS =for stopwords Thomas Eckardt Brian Gottreu Robert Rothenberg Stig Palmquist =over 4 =item * Thomas Eckardt =item * Brian Gottreu =item * Robert Rothenberg =item * Stig Palmquist =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2009, 2014, 2025 by Message Systems, Inc. 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 Net-CIDR-Set-0.19/MANIFEST.SKIP0000644000175000017500000000172615044372357013207 0ustar rrrr# Avoid version control files. \bRCS\b \bCVS\b ,v$ \B\.svn\b \B\.cvsignore$ \B\.git # Avoid Makemaker generated and utility files. \bMakefile$ \bblib \bMakeMaker-\d \bpm_to_blib$ \bblibdirs$ # Avoid VMS specific Makmaker generated files \bDescrip.MMS$ \bDESCRIP.MMS$ \bdescrip.mms$ # Avoid Module::Build generated and utility files. \bBuild$ \bBuild.bat$ \b_build \bBuild.COM$ \bBUILD.COM$ \bbuild.com$ # Avoid Devel::Cover generated files \bcover_db # Avoid temp and backup files. \.tmp$ \.old$ \.bak$ \#$ \.# \.rej$ # Avoid OS-specific files/dirs # Mac OSX metadata \B\.DS_Store # Mac OSX SMB mount metadata files \B\._ # Avoid archives of this distribution \bNet-CIDR-Set-[\d\.\_]+ \.tmproj$ \.tar\.gz$ \.swp$ \.vim$ ^\.cvsignore # Makemaker generated files and dirs. ^Makefile$ ^andy/ ^blib/ ^pm_to_blib$ # Temp, old and emacs backup files. ~$ ^\.DS_Store \.(old|tmp|bak)$ ^#.*#$ ^\.# ^cover_db ^try[.]store$ ^\.prove$ ^tags$ ^perltags$ ^MYMETA\.yml$ ^MYMETA\.json$ Net-CIDR-Set-0.19/CONTRIBUTING.md0000644000175000017500000001577315044372357013551 0ustar rrrr# HOW TO CONTRIBUTE Thank you for considering contributing to Net-CIDR-Set. There are multiple ways that you can help with this project. Any contributions (bug reports, feature requests, security issues, or patches) must cite any tools which generated the reports or code, and any software that the code is based on. Contributions must not include content generated by large language models (LLMs) or other probabilistic tools, including but not limited to Anthropic, Copilot or ChatGPT. This policy covers code, documentation, pull requests, issues, comments, and any other contributions to this project. See [AI Contributions](#ai-contributions) below for more more details. ## Report Bugs and Submit Feature Requests Please report any bugs or feature requests on the bugtracker website . 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. Using the bugtracker is preferable to emailing the maintainer, as identified in the AUTHOR section of the POD. But if you are unable to use the bugtracker, then you may email the current maintainer, Robert Rothenberg . ### Reporting Security Vulnerabilities Security issues should not be reported on the bugtracker website. Please see `SECURITY.md` for instructions how to report security vulnerabilities. ## Submitting Patches The source code is available via GitHub at . Patches should be based on a recent fork of the `main` branch. This distribution is managed with [Dist::Zilla](https://dzil.org/). This means that many of the usual files you might expect are not in the repository, but are generated at release time, as is much of the documentation. Some generated files are kept in the repository as a convenience (e.g. `Makefile.PL` or `cpanfile`). Generally, **you do not need Dist::Zilla to contribute patches**. You do need Dist::Zilla to create a tarball. See [Installing and using Dist::Zilla](#installing-and-using-distzilla) below for guidance. ### Getting dependencies If you have [App::cpanminus](https://metacpan.org/pod/App::cpanminus) 1.6 or later installed, you can use `cpanm` to satisfy dependencies like this: $ cpanm --installdeps . Otherwise, look for either a `Makefile.PL` or `cpanfile` file for a list of dependencies to satisfy. ### Running tests You can run tests directly using the `prove` tool: $ prove -l $ prove -lv t/some_test_file.t For most cases, `prove` is entirely sufficient to test any patches you have. ### Code style and tidying Please try to match any existing coding style. If there is a `.perltidyrc` file, please install [Perl::Tidy](https://metacpan.org/pod/Perl::Tidy) and use `perltidy` before submitting patches. If there is a `tidyall.ini` file, you can also install [Code::TidyAll](https://metacpan.org/pod/Code::TidyAll) and run `tidyall` on a file or `tidyall -a` to tidy all files. ### Patching documentation Much of the documentation POD is generated at release time. Some is generated boilerplate; other documentation is built from [Pod::Weaver](https://metacpan.org/pod/Pod::Weaver) pseudo-POD directives in the source like '=attr', '=method' or '=export'. If you would like to submit a documentation edit, please limit yourself to the documentation you see. If you see typos or documentation issues in the generated docs, please email the maintainers or open a bug ticket instead of patching. ### Where to send patches and pull requests If you found this distribution on GitHub, sending a pull-request is the best way to contribute. If a pull-request isn't possible, a bug ticket with a patch file is the next best option. As a last resort, an email to the maintainer is acceptable. ## Installing and using Dist::Zilla Dist::Zilla is not required for contributing, but if you'd like to learn more, this section will get you up to speed. Dist::Zilla is a very powerful authoring tool, optimised for maintaining a large number of distributions with a high degree of automation, but it has a large dependency chain, a bit of a learning curve and requires a number of author-specific plugins. To install it from CPAN, I recommend one of the following approaches for the quickest installation: # using CPAN.pm, but bypassing non-functional pod tests $ cpan TAP::Harness::Restricted $ PERL_MM_USE_DEFAULT=1 HARNESS_CLASS=TAP::Harness::Restricted cpan Dist::Zilla # using cpanm, bypassing *all* tests $ cpanm -n Dist::Zilla In either case, it's probably going to take several minutes. Go for a walk, go get a cup of your favourite beverage, take a bathroom break, or whatever. When you get back, Dist::Zilla should be ready for you. Then you need to install any plugins specific to this distribution: $ cpan `dzil authordeps` $ dzil authordeps | cpanm Once installed, here are some dzil commands you might try: $ dzil build $ dzil test You can learn more about Dist::Zilla at . ## AI Contributions Contributions must not include content generated by large language models (LLMs) or other probabilistic tools, including but not limited to Anthropic, Copilot or ChatGPT. This policy covers code, documentation, pull requests, issues, comments, and any other contributions to this project. This restriction is based on several concerns: ### Maintainer burden These tools make it easy to generate large amounts of plausible-looking bug reports or code that the contributor does not understand and cannot explain. Instead, the burden of understanding is placed on the maintainers. ### Correctness and security These tools generate code based on probabilities of symbols in their models. There is no semantic model about what the code does. There is no guarantee that it is correct, and no indication of what security implications it may have. ### Copyright issues These tools may use models that are trained on copyrighted content, both accidentally and intentionally, and their output often includes that content verbatim, without attribution. Since the legality of this is uncertain, these contributions may violate the licenses of copyrighted works. Using these tools also requires training their models on the source code from this project, and it makes it likely that code from this project will be used in other projects in ways that violate this project's license. ### Ethical issues These tools require an unreasonable amount of energy and water to build and operate, and they are being used to undermine labour and justify layoffs. These are harms that the maintainers of this project do not want to perpetuate, even if only indirectly. # Credits This file was adapted from an initial `CONTRIBUTING.mkdn` file from David Golden under the terms of the Apache 2 license. The text in "AI Contributions" was adapted from the [Contributing to Servo](https://book.servo.org/contributing.html) section of The Servo Book, which is licensed as no rights reserved under [CC0](https://creativecommons.org/public-domain/cc0/). Net-CIDR-Set-0.19/dist.ini0000644000175000017500000000573215044372357012756 0ustar rrrrname = Net-CIDR-Set author = Andy Armstrong license = Perl_5 copyright_holder = Message Systems, Inc. copyright_year = 2009, 2014, 2025 [Meta::Contributors] contributor = Thomas Eckardt [Keywords] keyword = CIDR keyword = INET keyword = LPM keyword = Longest Prefix Match [GatherDir] exclude_match = cpanfile* exclude_match = LICENSE exclude_match = SECURITY.md [PruneCruft] [ManifestSkip] [CPANFile] [License] [ExtraTests] [ExecDir] [ShareDir] [MakeMaker] [Manifest] [TestRelease] [ConfirmRelease] [Signature] [UploadToCPAN] [RecommendedPrereqs] [AutoPrereqs] [Prereqs / BuildRequires ] -phase = build -relationship = requires ExtUtils::MakeMaker = 7.22 Module::Metadata = 1.000015 [Prereqs / DevelopRequires ] -phase = develop -relationship = requires Software::Security::Policy::Individual = 0.10 Test::CPAN::Changes = 0 Test::Vars = 0.015 ; [EnsurePrereqsInstalled] ; :version = 0.003 ; type = requires ; type = recommends [SecurityPolicy] -policy = Individual timeframe = 2 weeks perl_support_years = 10 git_url = https://github.com/robrwo/perl-Net-CIDR-Set report_url = https://github.com/robrwo/perl-Net-CIDR-Set/security/advisories [PodWeaver] [UsefulReadme] type = gfm filename = README.md location = build [CopyFilesFromBuild] copy = LICENSE copy = README.md copy = SECURITY.md copy = cpanfile [PruneFiles] match = ~$ [GitHub::Meta] repo = robrwo/perl-Net-CIDR-Set.git fork = 0 [MetaResources] x_authority = cpan:RRWO bugtracker.web = https://rt.cpan.org/Public/Dist/Display.html?Name=Net-CIDR-Set ; repository.url = git://github.com/robrwo/perl-Net-CIDR-Set.git ; repository.web = https://github.com/robrwo/perl-Net-CIDR-Set [MetaProvides::Package] [MetaJSON] [MetaYAML] ; authordep Test::Warnings ; authordep Pod::Weaver::Plugin::AppendPrepend ; authordep Pod::Weaver::Section::Contributors ; authordep Pod::Weaver::Section::SourceGitHub [PodSyntaxTests] [Test::DistManifest] [Test::CleanNamespaces] [Test::EOF] [Test::EOL] :version = 0.14 [Test::Fixme] [Test::MinimumVersion] [Test::NoTabs] [Test::Perl::Critic] critic_config = t/etc/perlcritic.rc [Test::Pod::Coverage::Configurable] [Test::Pod::LinkCheck] [Test::Portability] ; authordep Test::TrailingSpace [Test::TrailingSpace] filename_regex = \.(?:p[lm]|pod)\z [Test::Kwalitee] skiptest = use_strict [Test::CPAN::Changes] [Test::UnusedVars] [Test::MixedScripts] ; Ideally stopwords would be embedded in the POD but with Pod::Weaver we cannot ensure they are placed before correctly [Test::PodSpelling] stopword = superset stopword = masse [Test::ReportPrereqs] :version = 0.022 version_extractor = Module::Metadata verify_prereqs = 1 [@Git] allow_dirty = dist.ini push_to = origin master:master tag_format = %v commit_msg = %v%n%n%c [Git::Contributors] :version = 0.019 remove = robrwo [RewriteVersion] [NextRelease] [BumpVersionAfterRelease] [Git::Commit / Commit_Changes] ; commit Changes (for new dev) allow_dirty_match = ^lib/ commit_msg = Commit Changes and bump $VERSION Net-CIDR-Set-0.19/Changes0000644000175000017500000000373415044372357012605 0ustar rrrrRevision history for Net-CIDR-Set 0.19 2025-08-05 13:11:19+01:00 Europe/London [Documentation] - Fixed typos in documentation RT#168697 (thanks Thomas Eckardt). - Removed the separate INSTALL file. - Fixed the CONTRIBUTORS setion of the README. - Added CONTRIBUTING.md file. 0.18 2025-08-03 11:45:07+01:00 Europe/London [Documentation] - Fixed broken Pod::Weaver configuration. 0.17 2025-08-03 11:39:29+01:00 Europe/London [Incompatabilities] - This module now requires Perl v5.14 or later. [Documentation] - README is now generated by Dist::Zilla::Plugin::UsefulReadme. - Added a SUPPORT section and merged BUGS into it. - Fixed typos. [Tests] - Add more author tests. 0.16 2025-06-03 13:54:58+01:00 Europe/London [Bug Fixes] - Imports are removed from the namespace. - Removed unused variable. [Documentation] - Modernised POD. - Added a security policy. - Updated README from POD. - Fixed tense in Changes for v0.15. [Other] - Removed unnecessary files from the repo and distribution. - Fixed issues with MANIFEST.SKIP. 0.15 2025-05-27 16:33:00+01:00 Europe/London [Documentation] - Added missing version and timestamp to Changes for v0.14. [Other] - Re-released due to possible bad signature. - Fixed MANIFEST. 0.14 2025-05-27 16:16:23+01:00 Europe/London [Security] - CVE-2025-40911: Disallow IPv4 addresses with a leading 0 in the quads, e.g. "010.0.0.1". [Documentation] - Updated the current maintainer to Robert Rothenberg . - Reversed the order of the Changes file to most-recent first. - Updated copyright year. [Other] - Fixed minor typos in the MANIFEST.SKIP. - Switch to Makefile.PL for building. - Sign the distribution. 0.13 2014-02-24 - Applied Brian Gottreu's fix for https://rt.cpan.org/Public/Bug/Display.html?id=49632 0.12 2009-05-29 - Move to GitHub 0.11 2009-01-29 - Remove broken cidrcalc 0.10 2009-01-29 - Initial release Net-CIDR-Set-0.19/weaver.ini0000644000175000017500000000055415044372357013301 0ustar rrrr[@CorePrep] [-SingleEncoding] ;; [-Transformer] ;; transformer = List [Name] [Version] [Region / prelude] [Generic / SYNOPSIS] [Generic / DESCRIPTION] [Collect / ATTRIBUTES] command = attr [Collect / METHODS] command = method [Leftovers] [Region / postlude] [SourceGitHub] [Bugs] header = SUPPORT [Authors] [Contributors] [Legal] [-AppendPrepend] Net-CIDR-Set-0.19/SECURITY.md0000644000175000017500000001035715044372357013102 0ustar rrrr# Security Policy for the Net-CIDR-Set distribution. Report security issues via the project [Security Advisories](https://github.com/robrwo/perl-Net-CIDR-Set/security/advisories). This is the Security Policy for Net-CIDR-Set. The latest version of the Security Policy can be found in the [git repository for Net-CIDR-Set](https://github.com/robrwo/perl-Net-CIDR-Set). This text is based on the CPAN Security Group's Guidelines for Adding a Security Policy to Perl Distributions (version 1.3.0) https://security.metacpan.org/docs/guides/security-policy-for-authors.html # How to Report a Security Vulnerability Security vulnerabilities can be reported to the current Net-CIDR-Set maintainers via the project [Security Advisories](https://github.com/robrwo/perl-Net-CIDR-Set/security/advisories). Please include as many details as possible, including code samples or test cases, so that we can reproduce the issue. Check that your report does not expose any sensitive data, such as passwords, tokens, or personal information. If you would like any help with triaging the issue, or if the issue is being actively exploited, please copy the report to the CPAN Security Group (CPANSec) at . Please *do not* use the public issue reporting system on RT or GitHub issues for reporting security vulnerabilities. Please do not disclose the security vulnerability in public forums until past any proposed date for public disclosure, or it has been made public by the maintainers or CPANSec. That includes patches or pull requests. For more information, see [Report a Security Issue](https://security.metacpan.org/docs/report.html) on the CPANSec website. ## Response to Reports The maintainer(s) aim to acknowledge your security report as soon as possible. However, this project is maintained by a single person in their spare time, and they cannot guarantee a rapid response. If you have not received a response from them within 2 weeks, then please send a reminder to them and copy the report to CPANSec at . Please note that the initial response to your report will be an acknowledgement, with a possible query for more information. It will not necessarily include any fixes for the issue. The project maintainer(s) may forward this issue to the security contacts for other projects where we believe it is relevant. This may include embedded libraries, system libraries, prerequisite modules or downstream software that uses this software. They may also forward this issue to CPANSec. # Which Software This Policy Applies To Any security vulnerabilities in Net-CIDR-Set are covered by this policy. Security vulnerabilities in versions of any libraries that are included in Net-CIDR-Set are also covered by this policy. Security vulnerabilities are considered anything that allows users to execute unauthorised code, access unauthorised resources, or to have an adverse impact on accessibility or performance of a system. Security vulnerabilities in upstream software (prerequisite modules or system libraries, or in Perl), are not covered by this policy unless they affect Net-CIDR-Set, or Net-CIDR-Set can be used to exploit vulnerabilities in them. Security vulnerabilities in downstream software (any software that uses Net-CIDR-Set, or plugins to it that are not included with the Net-CIDR-Set distribution) are not covered by this policy. ## Supported Versions of Net-CIDR-Set The maintainer(s) will only commit to releasing security fixes for the latest version of Net-CIDR-Set. Note that the Net-CIDR-Set project only supports major versions of Perl released in the past 10 years, even though Net-CIDR-Set will run on older versions of Perl. If a security fix requires us to increase the minimum version of Perl that is supported, then we may do so. # Installation and Usage Issues The distribution metadata specifies minimum versions of prerequisites that are required for Net-CIDR-Set to work. However, some of these prerequisites may have security vulnerabilities, and you should ensure that you are using up-to-date versions of these prerequisites. Where security vulnerabilities are known, the metadata may indicate newer versions as recommended. ## Usage Please see the software documentation for further information. Net-CIDR-Set-0.19/cpanfile0000644000175000017500000000330415044372357013007 0ustar rrrr# This file is generated by Dist::Zilla::Plugin::CPANFile v6.032 # Do not edit this file directly. To change prereqs, edit the `dist.ini` file. requires "Carp" => "0"; requires "namespace::autoclean" => "0"; requires "overload" => "0"; requires "perl" => "v5.14.0"; requires "strict" => "0"; requires "warnings" => "0"; on 'build' => sub { requires "ExtUtils::MakeMaker" => "7.22"; requires "Module::Metadata" => "1.000015"; }; on 'test' => sub { requires "Data::Dumper" => "0"; requires "File::Spec" => "0"; requires "Module::Metadata" => "1.000015"; requires "Test::More" => "0"; }; on 'test' => sub { recommends "CPAN::Meta" => "2.120900"; }; on 'configure' => sub { requires "ExtUtils::MakeMaker" => "0"; }; on 'develop' => sub { requires "Dist::Zilla::Plugin::UsefulReadme" => "v0.2.0"; requires "Pod::Coverage::TrustPod" => "0"; requires "Pod::Markdown::Github" => "0"; requires "Software::Security::Policy::Individual" => "0.10"; requires "Test2::Tools::Basic" => "1.302200"; requires "Test::CPAN::Changes" => "0.19"; requires "Test::CleanNamespaces" => "0.15"; requires "Test::DistManifest" => "0"; requires "Test::EOF" => "0"; requires "Test::EOL" => "0"; requires "Test::Kwalitee" => "1.21"; requires "Test::MinimumVersion" => "0"; requires "Test::MixedScripts" => "v0.3.0"; requires "Test::More" => "0.88"; requires "Test::NoTabs" => "0"; requires "Test::Perl::Critic" => "0"; requires "Test::Pod" => "1.41"; requires "Test::Pod::Coverage" => "1.08"; requires "Test::Pod::LinkCheck" => "0"; requires "Test::Portability::Files" => "0"; requires "Test::Spelling" => "0.17"; requires "Test::TrailingSpace" => "0.0203"; requires "Test::Vars" => "0.015"; }; Net-CIDR-Set-0.19/README.md0000644000175000017500000001012115044372357012555 0ustar rrrr# NAME Net::CIDR::Set - Manipulate sets of IP addresses # SYNOPSIS ```perl use Net::CIDR::Set; my $priv = Net::CIDR::Set->new( '10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16' ); for my $ip ( @addr ) { if ( $priv->contains( $ip ) ) { print "$ip is private\n"; } } ``` # DESCRIPTION `Net::CIDR::Set` represents sets of IP addresses and allows standard set operations (union, intersection, membership test etc) to be performed on them. In spite of the name it can work with sets consisting of arbitrary ranges of IP addresses - not just CIDR blocks. Both IPv4 and IPv6 addresses are handled - but they may not be mixed in the same set. You may explicitly set the personality of a set: ```perl my $ip4set = Net::CIDR::Set->new({ type => 'ipv4 }, '10.0.0.0/8'); ``` Normally this isn't necessary - the set will guess its personality from the first data that is added to it. # RECENT CHANGES Changes for version 0.19 (2025-08-05) - Documentation - Fixed typos in documentation RT#168697 (thanks Thomas Eckardt). - Removed the separate INSTALL file. - Fixed the CONTRIBUTORS setion of the README. - Added CONTRIBUTING.md file. See the `Changes` file for more details. # REQUIREMENTS This module lists the following modules as runtime dependencies: - [Carp](https://metacpan.org/pod/Carp) - [namespace::autoclean](https://metacpan.org/pod/namespace%3A%3Aautoclean) - [overload](https://metacpan.org/pod/overload) - [perl](https://metacpan.org/pod/perl) version v5.14.0 or later - [strict](https://metacpan.org/pod/strict) - [warnings](https://metacpan.org/pod/warnings) See the `cpanfile` file for the full list of prerequisites. # INSTALLATION The latest version of this module (along with any dependencies) can be installed from [CPAN](https://www.cpan.org) with the `cpan` tool that is included with Perl: ``` cpan Net::CIDR::Set ``` You can also extract the distribution archive and install this module (along with any dependencies): ``` cpan . ``` You can also install this module manually using the following commands: ``` perl Makefile.PL make make test make install ``` If you are working with the source repository, then it may not have a `Makefile.PL` file. But you can use the [Dist::Zilla](https://dzil.org/) tool in anger to build and install this module: ``` dzil build dzil test dzil install --install-command="cpan ." ``` For more information, see [How to install CPAN modules](https://www.cpan.org/modules/INSTALL.html). # SUPPORT Only the latest version of this module will be supported. This module requires Perl v5.14 or later. Future releases may only support Perl versions released in the last ten (10) years. Please report any bugs or feature requests on the bugtracker website [https://rt.cpan.org/Public/Dist/Display.html?Name=Net-CIDR-Set](https://rt.cpan.org/Public/Dist/Display.html?Name=Net-CIDR-Set) 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. ## Reporting Security Vulnerabilities If the bug you are reporting has security implications which make it inappropriate to send to a public issue tracker, then see `SECURITY.md` for instructions how to report security vulnerabilities. # SOURCE The development version is on github at [https://github.com/robrwo/perl-Net-CIDR-Set](https://github.com/robrwo/perl-Net-CIDR-Set) and may be cloned from [git://github.com/robrwo/perl-Net-CIDR-Set.git](git://github.com/robrwo/perl-Net-CIDR-Set.git) # AUTHOR Andy Armstrong The current maintainer is Robert Rothenberg . The encode and decode routines were stolen en masse from Douglas Wilson's [Net::CIDR::Lite](https://metacpan.org/pod/Net%3A%3ACIDR%3A%3ALite). # CONTRIBUTORS - Thomas Eckardt - Brian Gottreu - Robert Rothenberg - Stig Palmquist # COPYRIGHT AND LICENSE This software is copyright (c) 2009, 2014, 2025 by Message Systems, Inc. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Net-CIDR-Set-0.19/META.yml0000644000175000017500000000262315044372357012557 0ustar rrrr--- abstract: 'Manipulate sets of IP addresses' author: - 'Andy Armstrong ' build_requires: Data::Dumper: '0' ExtUtils::MakeMaker: '7.22' File::Spec: '0' Module::Metadata: '1.000015' Test::More: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.032, CPAN::Meta::Converter version 2.150010' keywords: - CIDR - INET - LPM - Longest - Prefix - Match license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Net-CIDR-Set provides: Net::CIDR::Set: file: lib/Net/CIDR/Set.pm version: '0.19' Net::CIDR::Set::IPv4: file: lib/Net/CIDR/Set/IPv4.pm version: '0.19' Net::CIDR::Set::IPv6: file: lib/Net/CIDR/Set/IPv6.pm version: '0.19' requires: Carp: '0' namespace::autoclean: '0' overload: '0' perl: v5.14.0 strict: '0' warnings: '0' resources: Authority: cpan:RRWO bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Net-CIDR-Set repository: git://github.com/robrwo/perl-Net-CIDR-Set.git version: '0.19' x_contributors: - 'Thomas Eckardt ' - 'Brian Gottreu ' - 'Robert Rothenberg ' - 'Stig Palmquist ' x_generated_by_perl: v5.34.3 x_serialization_backend: 'YAML::Tiny version 1.76' x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later' Net-CIDR-Set-0.19/Makefile.PL0000644000175000017500000000274715044372357013267 0ustar rrrr# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.032. use strict; use warnings; use 5.014000; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "Manipulate sets of IP addresses", "AUTHOR" => "Andy Armstrong ", "BUILD_REQUIRES" => { "ExtUtils::MakeMaker" => "7.22", "Module::Metadata" => "1.000015" }, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "Net-CIDR-Set", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.014000", "NAME" => "Net::CIDR::Set", "PREREQ_PM" => { "Carp" => 0, "namespace::autoclean" => 0, "overload" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "Data::Dumper" => 0, "File::Spec" => 0, "Module::Metadata" => "1.000015", "Test::More" => 0 }, "VERSION" => "0.19", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Carp" => 0, "Data::Dumper" => 0, "ExtUtils::MakeMaker" => "7.22", "File::Spec" => 0, "Module::Metadata" => "1.000015", "Test::More" => 0, "namespace::autoclean" => 0, "overload" => 0, "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); Net-CIDR-Set-0.19/LICENSE0000644000175000017500000004637515044372357012327 0ustar rrrrThis software is copyright (c) 2009, 2014, 2025 by Message Systems, Inc. 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) 2009, 2014, 2025 by Message Systems, Inc. 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. 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, see . 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 Moe Ghoul, President of Vice That's all there is to it! --- The Perl Artistic License 1.0 --- This software is Copyright (c) 2009, 2014, 2025 by Message Systems, Inc. This is free software, licensed under: The Perl 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 as specified below. "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 uunet.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) give non-standard executables non-standard names, and clearly document 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. You may embed this Package's interpreter within an executable of yours (by linking); this shall be construed as a mere form of aggregation, provided that the complete Standard Version of the interpreter is so embedded. 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 whoever generated them, and may be sold commercially, and may be aggregated with this Package. If such scripts or library files are aggregated with this Package via the so-called "undump" or "unexec" methods of producing a binary executable image, then distribution of such an image shall neither be construed as a distribution of this Package nor shall it fall under the restrictions of Paragraphs 3 and 4, provided that you do not represent such an executable image as a Standard Version of this Package. 7. C subroutines (or comparably compiled subroutines in other languages) supplied by you and linked into this Package in order to emulate subroutines and variables of the language defined by this Package shall not be considered part of this Package, but are the equivalent of input as in Paragraph 6, provided these subroutines do not change the language in any way that would cause it to fail the regression tests for the language. 8. Aggregation of this Package with a commercial distribution is always permitted provided that the use of this Package is embedded; that is, when no overt attempt is made to make this Package's interfaces visible to the end user of the commercial distribution. Such use shall not be construed as a distribution of this Package. 9. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End