...yay! Net::CIDR does not like when both IPv4 and IPv6 are combined

This commit is contained in:
Zane C. B-H 2019-02-26 03:47:54 -06:00
parent 359daebdd5
commit 7c479576bf
1 changed files with 23 additions and 14 deletions

View File

@ -310,20 +310,29 @@ sub search{
}
# checks the forient port against each CIDR
if (
$cidr_require &&
(
(
( $foreign_host ne '*' ) &&
( eval{ Net::CIDR::cidrlookup( $foreign_host, @{ $self->{cidrs} } ) })
) ||
(
( $local_host ne '*' ) &&
( eval{ Net::CIDR::cidrlookup( $local_host, @{ $self->{cidrs} } ) } )
)
)
) {
$cidr_meet=1;
my @cidrs=@{ $self->{cidrs} };
if ( $cidr_require ){
# check each one by its self... Net::CIDR will error if you tell it to search for in IPv4 and IPv6 space at the same time
my @cidrs=@{ $self->{cidrs} };
my $cidr=pop( @cidrs );
while (
( defined( $cidr ) ) &&
( ! $cidr_meet )
){
if (
(
( $foreign_host ne '*' ) &&
( eval{ Net::CIDR::cidrlookup( $foreign_host, $cidr ) })
) || (
( $local_host ne '*' ) &&
( eval{ Net::CIDR::cidrlookup( $local_host, $cidr ) } )
)
){
$cidr_meet=1;
}
$cidr=pop( @cidrs );
}
}
# handle it if port checking is required