blob: c28136e81f2d178ce52724689d64725fdca5cbda (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package stream;
use strict;
use warnings;
BEGIN {
use Exporter();
our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
@ISA = qw(Exporter);
$VERSION = 1.00;
@EXPORT = qw(&is_ip_local);
}
sub is_ip_local($$$) {
my $clip = shift;
my $v4net = shift;
my $v6net = shift;
return 0 unless defined($clip);
my $is_local = 0;
if ($clip =~ m/\:/){
if (NetAddr::IP->new($clip)->within($v6net)){
$is_local = 1;
}
} else {
if (NetAddr::IP->new($clip)->within($v4net)){
$is_local = 1;
}
}
return $is_local;
}
1;
|