Anti-Mass-Join

By simo on May 16, 2017

Most modern updated IRCD's have all kinds of features to prevent mass joins some dont tho and those that have usually only lock channel if mass joins detected not removing mass joiners therefor this code might be some sort of solution for that part

some networks ( like dalnet ) have notting at all to counter mass joins

this will get rid of mass joins swiftly and set bans to prevent rejoins and set temporare channel lock

( it wont trigger on net split )

credits go to Neo Nemesis i modified his code a bit

DesertFish, Cappuccino.

on *:JOIN:#: {
if (%Netsplit-Detected. [ $+ [ $chan ] $+ . $+ [ $network ] ]) { return }
  if ($nick(#,$me,@&~%)) { 
    set -u4 %mj1 $addtok(%mj1,$nick,44) 
    set -u4 $+(%,ipflood.,#) $addtok($($+(%,ipflood.,#),2),$mask($fulladdress,4),32)  
    if ($floodchk(jflood, 3, $network $chan) > 3) { 
      .timerbans. [ $+ [ # ] ] -m 1 10 bans $safechan($chan)  
      if (!$Timer(mjoinz $+ #)) { MODE $chan +MR | .Timer $+ mjoinz $+ $chan 1 20 MODE $chan -MR  |  set -u3 %mj2. [ $+ [   $network ] $+ . $+ [  $chan ] ] 1 }
      while (%mj2. [ $+ [   $network ] $+ . $+ [  $chan ] ] <= $numtok(%mj1,44)) {
        if ($gettok(%mj1,%mj2. [ $+ [   $network ] $+ . $+ [  $chan ] ],44) ison $chan) {
          if (%mj2. [ $+ [   $network ] $+ . $+ [  $chan ] ] <= 4) {  kick $chan $gettok(%mj1,%mj2. [ $+ [   $network ] $+ . $+ [  $chan ] ],44) MASS JOIN KICKER -[one]- }
          elseif (%mj2. [ $+ [   $network ] $+ . $+ [  $chan ] ] > 4) {  kick $safechan($chan) $gettok(%mj1,%mj2. [ $+ [   $network ] $+ . $+ [  $chan ] ],44) MASS JOIN KICKER  -[two]- }  
        }
        inc %mj2. [ $+ [   $network ] $+ . $+ [  $chan ] ]
      }
    }
  }
}

ON !^*:QUIT: {
  var %netsplit2 1
  while ($comchan($nick,%netsplit2)) {
    var %netsplitchan $v1
    if (*.* iswm $1-2) ) && (!%Netsplit-Detected. [ $+ [ %netsplitchan ] $+ . $+ [ $network ] ])  {
      echo  %netsplitchan  $timestamp  12,00 Netsplit Detected between 05,00 $1 14,00 <> 05,00 $2  
      set -z %Netsplit-Detected. [ $+ [ %netsplitchan ] $+ . $+ [ $network ] ]  60
    }
    inc %netsplit2
  }
  if (%Netsplit-Detected. [ $+ [ %netsplitchan ] $+ . $+ [ $network ] ])  {  echo  %netsplitchan $timestamp  $chr(160)  $+ $color(quit) Quits : $chr(160)  $+ $color(quit)  $nick $chr(160)   $+ $color(quit)  $address   $+ $color(quit)  ( $+ $1- $+ )    }
}

alias safechan return $!decode( $encode($1-, m) ,m)

alias bans {
  var %loop-a = 1
  while ($gettok($($+(%,ipflood.,$1),2),%loop-a,32)) {
    %bb = %bb $gettok($($+(%,ipflood.,$1),2),%loop-a,32)
    if ($modespl == $numtok(%bb,32)) { mode $1 $+(+,$str(b,$gettok(%bb,0,32))) %bb | %bb = "" }
    inc %loop-a
  }
  if (%bb) { mode $1 $+(+,$str(b,$gettok(%bb,0,32))) %bb | %bb = "" }
  $+(.timerx,$1) 1 0 unset $+(%,*,flood.,$1)
}

Alias floodchk {
  var %h, %s = $$2, %ticksmax = $calc($ticks - %s * 1000)
  %h = $1. $+ $iif($replace($3-, $chr(32), .), $ifmatch, $cid)
  tokenize 32 $hget(floodchk, %h) $ticks
  while ($1 < %ticksmax) tokenize 32 $2-
  if ($0 > 70) tokenize 32 $gettok($1-, -70-, 32)
  hadd -mu $+ %s floodchk %h $1-
  return $numtok($1-, 32)
}

Alias floodchk.secs {
  var %h = $1. $+ $iif($replace($2-, $chr(32), .), $ifmatch, $cid), %t = $hget(floodchk, %h)
  return $calc($gettok(%t, -1, 32) - $gettok(%t, 1, 32))
}

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.