aboutsummaryrefslogtreecommitdiffstats
path: root/web/streamlib/stream.pm
diff options
context:
space:
mode:
authorJoachim Tingvold <joachim@tingvold.com>2014-04-06 03:11:04 +0200
committerJoachim Tingvold <joachim@tingvold.com>2014-04-06 03:11:04 +0200
commit2a0c0a3dbbdf7fa5040953c0b0d88ad6f62c011e (patch)
tree92c7cbf54272466b46f64e5dc8d1ddb429858836 /web/streamlib/stream.pm
parentfe0be5960aac1f9bb600dbf853d862a9f4e60de8 (diff)
Initial commit. Source; TG13-goodiebag.
Diffstat (limited to 'web/streamlib/stream.pm')
-rw-r--r--web/streamlib/stream.pm36
1 files changed, 36 insertions, 0 deletions
diff --git a/web/streamlib/stream.pm b/web/streamlib/stream.pm
new file mode 100644
index 0000000..c28136e
--- /dev/null
+++ b/web/streamlib/stream.pm
@@ -0,0 +1,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;