Skip to content

Instantly share code, notes, and snippets.

@phil21
Created January 6, 2016 02:29
Show Gist options
  • Save phil21/0b7335b86386cf23a02c to your computer and use it in GitHub Desktop.
Save phil21/0b7335b86386cf23a02c to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -w
# Whitelists and administrators admin IP with various settings
use strict;
use Getopt::Long;
# Defaults (0 for unlimited)
my $def_softo = '24h'; # Removes the IP when it has last been seen n hours ago
my $def_hardto = '1y'; # Removes the IP when a specified time period has passed ignoring the soft timeout value (max age)
# The way of the array.. This bitch is raw ready and raring to go. Mathethatically efficiency baby!
my @a = [ 0, #s, seconds (integer is multiplication factor of seconds over an average time period
60, #m, minutes
3600, #h, hours
43200, #d, days ( this one off)
13119200,#m, months (this one is slight off..)
157430400#y, years (this one off)
]
# Another way to do it...
my %h = {
's' => 0,
'm' = 60,
'h' => 3600,
'y' => 43200,
'm' => 24229200,
'y' => 157430400,
};
if m/(\^d+)([h,m,s,d,y])/ {
# We got digits in our shiz
if ($2 eq "s") {
my $seconds = $1;
}
if ($2 eq "m") {
my $seconds = $1 * 60;
}
if ($2 eq "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment