#==========================================# # Author: Marius Feraru aka AltBlue # # E-Mail: altblue@tuiasi.ro # # URL : http://www.cs.tuiasi.ro/altblue/ # # http://bofh.mednet.ro/altblue/ # #==========================================# # v0.1 package abhosts_access; ##### # Access validation #### sub main'validate { my $to_validate = $_[0]; my $host_access; # Banned? unless($#main::hosts_deny == -1) { return -1 if ab_validate($to_validate,@main::hosts_deny); } unless($#main::hosts_allow == -1) { $host_access = ab_validate($to_validate,,@main::hosts_allow); } else { $host_access = 1; } return $host_access; } #### Internals, don't use'em unless you know what you are doing. sub ab_validate { my ($source,@ad) = @_; foreach (@ad) { if(/^(\d{1,3}\.){3}\d{1,3}$/) { # IP return 1 if ($source =~ /^$_$/); } elsif(/^(\d{1,3}\.)+$/) { # IP net return 1 if ($source =~ /^$_/); } elsif(/^(\.\w+)+$/) { # Domain return 1 if ($source =~ /$_$/); } elsif(/^(\w+\.)+\w+$/) { # Host return 1 if ($source =~ /^$_$/); } } return 0; } 1; ##### Do not remove me! I'm the most important thing here ;->~