From: dms Date: Thu, 8 Feb 2001 13:52:19 +0000 (+0000) Subject: chan limit check code should now be disabled/re-enabled in relation to netsplits... X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=3c042d9173714f2e7ef7d484672f3bfaa1702478;p=infobot.git chan limit check code should now be disabled/re-enabled in relation to netsplits. discovered by asuffield git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@360 c11ca15a-4712-0410-83d8-924469b57eb5 --- diff --git a/src/IRC/IrcHooks.pl b/src/IRC/IrcHooks.pl index 597fb3a..9eec53b 100644 --- a/src/IRC/IrcHooks.pl +++ b/src/IRC/IrcHooks.pl @@ -406,7 +406,7 @@ sub on_join { } if ($netsplit and !$netsplittime) { - &status("ok.... re-running chanlimitCheck in 60."); + &DEBUG("on_join: ok.... re-running chanlimitCheck in 60."); $conn->schedule(60, sub { &chanlimitCheck(); $netsplittime = undef; @@ -448,21 +448,7 @@ sub on_join { $channels{$chan}{'o'}{$ident}); ### chanlimit check. - my $l = $channels{$chan}{'l'}; - if (defined $l and &IsChanConf("chanlimitcheck")) { - my $plus = &getChanConfDefault("chanlimitcheckPlus", 5, $chan); - my $nowl = scalar(keys %{ $channels{$chan}{''} }); - - if ($plus <= 3) { - &WARN("clc: stupid to have plus at $plus, fix it!"); - } - - ### check if we have ops. - if ($nowl > $l - 3 and $plus > 3) { - &WARN("clc: nowl($nowl) > l($l) - 3"); - &rawout("MODE $chan +l ".($nowl+$plus) ); - } - } + &chanLimitVerify($chan); # used to determine sync time. if ($who =~ /^$ident$/i) { @@ -725,10 +711,15 @@ sub on_quit { foreach (keys %channels) { # fixes inconsistent chanstats bug #1. - next unless (&IsNickInChan($nick,$_)); + if (!&IsNickInChan($nick,$_)) { + &DEBUG("on_quit: nick $nick was not in chan $_."); + next; + } $chanstats{$_}{'SignOff'}++; } + &DeleteUserInfo($nick, keys %channels); + if (exists $nuh{lc $nick}) { delete $nuh{lc $nick}; } else { @@ -740,6 +731,11 @@ sub on_quit { if ($reason=~/^($mask{host})\s($mask{host})$/) { # netsplit. $reason = "NETSPLIT: $1 <=> $2"; + if (&ChanConfList("chanlimitcheck") and !scalar keys %netsplit) { + &DEBUG("on_quit: netsplit detected; disabling chan limit."); + &rawout("MODE $chan -l"); + } + $netsplit{lc $nick} = time(); if (!exists $netsplitservers{$1}{$2}) { &status("netsplit detected between $1 and $2."); @@ -1121,4 +1117,29 @@ sub hookMsg { return; } +sub chanLimitVerify { + my($chan) = @_; + my $l = $channels{$chan}{'l'}; + + # only change it if it's not set. + if (defined $l and &IsChanConf("chanlimitcheck")) { + my $plus = &getChanConfDefault("chanlimitcheckPlus", 5, $chan); + my $nowl = scalar(keys %{ $channels{$chan}{''} }); + my $delta = $nowl - $l; + $delta =~ s/^\-//; + + if ($plus <= 3) { + &WARN("clc: stupid to have plus at $plus, fix it!"); + } + + ### todo: check if we have ops. + ### todo: if not, check if nickserv/chanserv is avail. + ### todo: unify code with chanlimitcheck() + if ($delta > 3) { + &WARN("clc: nowl($nowl) > l($l) - 3"); + &rawout("MODE $chan +l ".($nowl+$plus) ); + } + } +} + 1; diff --git a/src/IRC/Schedulers.pl b/src/IRC/Schedulers.pl index 591d529..e6ae976 100644 --- a/src/IRC/Schedulers.pl +++ b/src/IRC/Schedulers.pl @@ -307,9 +307,14 @@ sub chanlimitCheck { if (!exists $channels{$_}{'o'}{$ident}) { &ERROR("chanlimitcheck: dont have ops on $_."); + ### TODO: check chanserv? next; } + if (!defined $limit) { + &DEBUG("setting limit for first time or from netsplit for $_"); + } + &rawout("MODE $_ +l $newlimit"); } } @@ -334,17 +339,22 @@ sub netsplitCheck { } # %netsplit hash checker. + my $count = scalar keys %netsplit; foreach (keys %netsplit) { if (&IsNickInAnyChan($_)) { &DEBUG("netsplitC: $_ is in some chan; removing from netsplit list."); delete $netsplit{$_}; } - next unless (time() - $netsplit{$_} > 60*60*2); # 2 hours. - next if (&IsNickInAnyChan($_)); + next unless (time() - $netsplit{$_} > 60*10); - &DEBUG("netsplitC: $_ didn't come back from netsplit in 2 hours; removing from netsplit list."); + &DEBUG("netsplitC: $_ didn't come back from netsplit; removing from netsplit list."); delete $netsplit{$_}; } + + if ($count and !scalar keys %netsplit) { + &DEBUG("ok, netsplit is hopefully gone. reinstating chanlimit check."); + &chanlimitCheck(); + } } sub floodLoop {