summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorLibravatarDoug Freed <dwfreed@mtu.edu>2015-08-06 09:14:57 +0400
committerLibravatarDoug Freed <dwfreed@mtu.edu>2015-08-06 09:14:57 +0400
commit266be47956ae2ad397c52f26d00b88b5dc713da6 (patch)
tree210a0a6dd881782d29c2b265b42070dd02ba21f6 /modules
parent138ea2798570a3ee9f3821f31de7e4acd2c42d03 (diff)
Restrictions are now regexes
Diffstat (limited to 'modules')
-rw-r--r--modules/util.pl29
1 files changed, 14 insertions, 15 deletions
diff --git a/modules/util.pl b/modules/util.pl
index b3b612d..f9895a0 100644
--- a/modules/util.pl
+++ b/modules/util.pl
@@ -269,30 +269,29 @@ sub getNickIP
sub notRestricted {
my ($module, $nick, $restriction) = @_;
$nick = lc $nick;
- my $host = $::sn{$nick}{host};
+ my $host = lc $::sn{$nick}{host};
my $account = lc $::sn{$nick}{account};
- my $ret = 1;
- if (defined($::restrictions->{nicks}->{nick}->{$nick})) {
- if (defined($::restrictions->{nicks}->{nick}->{$nick}->{$restriction})) {
- $ret= 0;
+ foreach my $regex (keys %{$::restrictions->{nicks}->{nick}}) {
+ if ($nick =~ /^$regex$/i && defined($::restrictions->{nicks}->{nick}->{$regex}->{$restriction})) {
+ dprint("blah", "Restriction $restriction found for $nick (nick $regex)", "restrictions");
+ return 0;
}
}
if ((defined($host)) && (defined($account))) {
- if (defined($::restrictions->{accounts}->{account}->{$account})) {
- if (defined($::restrictions->{accounts}->{account}->{$account}->{$restriction})) {
- $ret= 0;
+ foreach my $regex (keys %{$::restrictions->{accounts}->{account}}) {
+ if ($account =~ /^$regex$/i && defined($::restrictions->{accounts}->{account}->{$regex}->{$restriction})) {
+ dprint("blah", "Restriction $restriction found for $nick (account $regex)", "restrictions");
+ return 0;
}
}
- if (defined($::restrictions->{hosts}->{host}->{$host})) {
- if (defined($::restrictions->{hosts}->{host}->{$host}->{$restriction})) {
- $ret= 0;
+ foreach my $regex (keys %{$::restrictions->{hosts}->{host}}) {
+ if ($host =~ /^$regex$/i && defined($::restrictions->{hosts}->{host}->{$regex}->{$restriction})) {
+ dprint("blah", "Restriction $restriction found for $nick (host $regex)", "restrictions");
+ return 0;
}
}
}
- if ($ret == 0) {
- dprint("blah", "Restriction $restriction found for $nick", "restrictions");;
- }
- return $ret;
+ return 1;
}
return 1;