aboutsummaryrefslogtreecommitdiffstats
path: root/examples/historical/mbd/mbd.pm
diff options
context:
space:
mode:
authorKristian Lyngstol <kristian@bohemians.org>2016-02-26 10:59:08 +0100
committerKristian Lyngstol <kristian@bohemians.org>2016-02-26 10:59:08 +0100
commit9da864a8da29082369cdd2dd91a735b03577a117 (patch)
tree543d881f3746ddd4805dd0da449783eb42a8a92c /examples/historical/mbd/mbd.pm
parent9ecc4690b2546ac117204207bec21ee1f6d585cf (diff)
Archive old/unused things
Diffstat (limited to 'examples/historical/mbd/mbd.pm')
-rw-r--r--examples/historical/mbd/mbd.pm50
1 files changed, 50 insertions, 0 deletions
diff --git a/examples/historical/mbd/mbd.pm b/examples/historical/mbd/mbd.pm
new file mode 100644
index 0000000..b844e5b
--- /dev/null
+++ b/examples/historical/mbd/mbd.pm
@@ -0,0 +1,50 @@
+#! /usr/bin/perl
+use strict;
+use warnings;
+use Socket;
+use Net::CIDR;
+use Net::RawIP;
+require './access_list.pl';
+require './nets.pl';
+
+package mbd;
+
+sub expand_range {
+ my $range = shift;
+
+ if ($range =~ /^(\d+)\.\.(\d+)$/) {
+ return $1..$2;
+ } else {
+ return $range;
+ }
+}
+
+sub match_ranges {
+ my ($elem, $ranges) = @_;
+
+ for my $range (@$ranges) {
+ if ($range =~ /^(\d+)\.\.(\d+)$/) {
+ return 1 if ($elem >= $1 && $elem <= $2);
+ } else {
+ return 1 if ($elem == $range);
+ }
+ }
+
+ return 0;
+}
+
+sub find_all_ports {
+ # Find what ports we need to listen on
+ my %port_hash = ();
+ for my $e (@Config::access_list) {
+ for my $r (@{$e->{'ports'}}) {
+ for my $p (expand_range($r)) {
+ $port_hash{$p} = 1;
+ }
+ }
+ }
+ my @ports = sort { $a <=> $b } keys %port_hash;
+ return @ports;
+}
+
+1;