diff --git a/INDEV b/INDEV index ff612b0e..27d2aac9 100644 --- a/INDEV +++ b/INDEV @@ -3437,3 +3437,5 @@ CHANGES: fixed an issue where QUITs were sent on ban enforcement for users not yet propagated. added connection events 'found_ident' and 'found_hostname' for Ban. Ban now enforces bans on a connection as soon as the host/ident are looked up. + Ban classes were removed because some ban types apply to multiple object types. + Klines can now be applied directly to connections, so the kill occurs during registration when possible. diff --git a/modules/Ban/Ban.module/Ban.json b/modules/Ban/Ban.module/Ban.json index 61472226..a4577d6c 100644 --- a/modules/Ban/Ban.module/Ban.json +++ b/modules/Ban/Ban.module/Ban.json @@ -12,5 +12,5 @@ "description" : "provides an interface for user and server banning", "name" : "Ban", "package" : "M::Ban", - "version" : "10.3" + "version" : "10.4" } diff --git a/modules/Ban/Ban.module/Ban.pm b/modules/Ban/Ban.module/Ban.pm index 28fdcaf3..171ddc25 100644 --- a/modules/Ban/Ban.module/Ban.pm +++ b/modules/Ban/Ban.module/Ban.pm @@ -435,7 +435,7 @@ sub enforce_all_on_user { my $user = shift; foreach my $ban (get_all_bans()) { my $type = $ban_types{ $ban->{type} }; - next unless $type->{class} eq 'user'; + next unless $type->{user_code}; return 1 if enforce_ban_on_user($ban, $user); } return; @@ -446,7 +446,7 @@ sub enforce_all_on_conn { my $conn = shift; foreach my $ban (get_all_bans()) { my $type = $ban_types{ $ban->{type} }; - next unless $type->{class} eq 'conn'; + next unless $type->{conn_code}; return 1 if enforce_ban_on_conn($ban, $conn); } return; @@ -459,11 +459,11 @@ sub enforce_ban { my %ban = @_; my $type = $ban_types{ $ban{type} } or return; - # user ban - if ($type->{class} eq 'user') { return enforce_ban_on_users(%ban) } - if ($type->{class} eq 'conn') { return enforce_ban_on_conns(%ban) } + my @a; + push @a, enforce_ban_on_users(%ban) if $type->{user_code}; + push @a, enforce_ban_on_conns(%ban) if $type->{conn_code}; - return; + return @a; } # enforce a ban on all connections diff --git a/modules/Ban/Ban.module/TS6.module/TS6.json b/modules/Ban/Ban.module/TS6.module/TS6.json index 96942c52..c77791b2 100644 --- a/modules/Ban/Ban.module/TS6.module/TS6.json +++ b/modules/Ban/Ban.module/TS6.module/TS6.json @@ -11,5 +11,5 @@ "description" : "TS6 ban propagation", "name" : "Ban::TS6", "package" : "M::Ban::TS6", - "version" : "4.1" + "version" : "4.2" } diff --git a/modules/Ban/Ban.module/TS6.module/TS6.pm b/modules/Ban/Ban.module/TS6.module/TS6.pm index 68a02bf0..624d2432 100644 --- a/modules/Ban/Ban.module/TS6.module/TS6.pm +++ b/modules/Ban/Ban.module/TS6.module/TS6.pm @@ -246,7 +246,7 @@ sub out_bandel { # CAP_UNKLN: : UNKLINE if ($ban{type} eq 'kline' && $to_server->has_cap('UNKLN')) { return sprintf ':%s UNKLINE * %s %s', - ts6_id($from); + ts6_id($from), $ban{ts6_duration}, $ban{match_user}, $ban{match_host}; diff --git a/modules/Ban/Dline.module/Dline.json b/modules/Ban/Dline.module/Dline.json index d85c892b..84817c20 100644 --- a/modules/Ban/Dline.module/Dline.json +++ b/modules/Ban/Dline.module/Dline.json @@ -9,5 +9,5 @@ "description" : "ban connections from server by IP", "name" : "Ban::Dline", "package" : "M::Ban::Dline", - "version" : "0.9" + "version" : "1" } diff --git a/modules/Ban/Dline.module/Dline.pm b/modules/Ban/Dline.module/Dline.pm index 0e24abb7..563980c1 100644 --- a/modules/Ban/Dline.module/Dline.pm +++ b/modules/Ban/Dline.module/Dline.pm @@ -27,7 +27,6 @@ sub init { add_cmd => 'dline', # add command del_cmd => 'undline', # delete command reason => 'D-Lined', # reason prefix - class => 'conn', # bans apply to conn_code => \&conn_matches, # connection matcher match_code => \&_match, # match checker ); diff --git a/modules/Ban/Kline.module/Kline.json b/modules/Ban/Kline.module/Kline.json index 3c590a89..07c757c4 100644 --- a/modules/Ban/Kline.module/Kline.json +++ b/modules/Ban/Kline.module/Kline.json @@ -9,5 +9,5 @@ "description" : "ban users from server by hostmask", "name" : "Ban::Kline", "package" : "M::Ban::Kline", - "version" : "1.3" + "version" : "1.4" } diff --git a/modules/Ban/Kline.module/Kline.pm b/modules/Ban/Kline.module/Kline.pm index 37b9a593..fcf8dafb 100644 --- a/modules/Ban/Kline.module/Kline.pm +++ b/modules/Ban/Kline.module/Kline.pm @@ -19,6 +19,8 @@ use warnings; use strict; use 5.010; +use utils qw(irc_match); + our ($api, $mod, $pool); sub init { @@ -27,8 +29,8 @@ sub init { add_cmd => 'kline', # add command del_cmd => 'unkline', # delete command reason => 'K-Lined', # reason prefix - class => 'user', # bans apply to - user_code => \&user_matches, # user matcher + user_code => \&user_or_conn_matches, # user matcher + conn_code => \&user_or_conn_matches, # connection matcher match_code => \&_match, # match checker ); } @@ -49,10 +51,12 @@ sub _match { return $result; } -sub user_matches { - my ($user, $ban) = @_; - return 1 if utils::irc_match($user->{ident}.'@'.$user->{host}, $ban->{match}); - return 1 if utils::irc_match($user->{ident}.'@'.$user->{ip}, $ban->{match}); +sub user_or_conn_matches { + my ($user_conn, $ban) = @_; + my ($ident, $host, $ip) = @$user_conn{ qw(ident host ip) }; + return unless length $ident; + return 1 if irc_match("$ident\@$host", $ban->{match}); + return 1 if irc_match("$ident\@$ip", $ban->{match}); return; }