summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormniip2015-09-14 14:11:01 +0300
committermniip2015-09-15 19:59:17 +0300
commit118ae15568e69f5619219d0809ff16076f7ff44c (patch)
treea24f0e1b8eed310f90183549c83d5b92ff11baea
parentb505cefa89b03ad5caccae2da052251fb6c19d72 (diff)
downloadscripts.irssi.org-118ae15568e69f5619219d0809ff16076f7ff44c.tar.bz2
isbanned.pl: add support for trailing characters in CIDR bans
-rw-r--r--_data/scripts.yaml4
-rw-r--r--scripts/isbanned.pl40
2 files changed, 27 insertions, 17 deletions
diff --git a/_data/scripts.yaml b/_data/scripts.yaml
index a240888..1f0b115 100644
--- a/_data/scripts.yaml
+++ b/_data/scripts.yaml
@@ -1993,9 +1993,9 @@
description: 'freenode-specific script that checks whether someone is banned on some channel'
filename: isbanned.pl
license: 'Public domain'
- modified: '2015-06-12 21:43:19'
+ modified: '2015-09-14 14:11:01'
name: isbanned
- version: 0.6.4
+ version: 0.7.0
-
authors: 'Uli Baumann'
contact: f-zappa@irc-muenster.de
diff --git a/scripts/isbanned.pl b/scripts/isbanned.pl
index 0dc1755..aa3304c 100644
--- a/scripts/isbanned.pl
+++ b/scripts/isbanned.pl
@@ -13,9 +13,9 @@ use vars qw($VERSION %IRSSI);
authors => "mniip",
contact => "mniip \@ freenode",
license => "Public domain",
- modified => "2015-01-16"
+ modified => "2015-09-14"
);
-$VERSION = "0.6.4";
+$VERSION = "0.7.0";
# Commands:
# /isbanned <channel> <user>
@@ -60,6 +60,9 @@ $VERSION = "0.6.4";
#
# 0.6.4 (2015.03.22)
# Fix translation from python: fix bans containing the letter Z not matching
+#
+# 0.7.0 (2015.09.14)
+# Support trailing characters in CIDR bans.
my $active = 0;
my $user;
@@ -277,24 +280,31 @@ sub analyze
if(!$found)
{
my ($ip, $width) = split /\//, $bhost, 2;
- if(defined $width && $width =~ /^[0-9]+$/)
+ if(defined $width)
{
- my $is_v4 = !($ip =~ /:/);
- $width = ($is_v4 ? 32 : 128) - $width;
- $width = 0 if $width < 0;
- $ip = parse_ip($ip);
- for my $h(@$host)
+ $width =~ s/^([0-9]*).*/$1/g;
+ $width = int("0" . $width);
+ if($width > 0)
{
- if(!($h =~ /:/) == $is_v4)
+ my $is_v4 = !($ip =~ /:/);
+ $width = ($is_v4 ? 32 : 128) - $width;
+ $width = 0 if $width < 0;
+ $ip = parse_ip($ip);
+ for my $h(@$host)
{
- eval
+ if(!($h =~ /:/) == $is_v4)
{
- my $h = parse_ip($h, 1);
- if(($ip >> $width) == ($h >> $width))
+ my $last;
+ eval
{
- add_ban(@$b);
- last;
- }
+ my $h = parse_ip($h, 1);
+ if(($ip >> $width) == ($h >> $width))
+ {
+ add_ban(@$b);
+ $last = 1;
+ }
+ };
+ last if $last;
}
}
}