From 266be47956ae2ad397c52f26d00b88b5dc713da6 Mon Sep 17 00:00:00 2001 From: Doug Freed Date: Thu, 6 Aug 2015 09:14:57 +0400 Subject: Restrictions are now regexes --- modules/util.pl | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'modules/util.pl') 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; -- cgit v1.2.3