Here is a sample flood proc which triggers for only consecutive joins of unresolved idents. I'm interested to make this an universal consecutive detection type proc. So that the same proc is used for different types of consecutive join patterns. Guide me to make it more advanced, faster, dynamic and also with out using timers.
Code: Select all
# Consecutive Unresolved Host Flood x(joins):y(secs)
# ~blah@example.net, ~swooozy@ex.net.com , ~whoreee@me.tk.in
set uh 2:2
proc unresolved:flood {n u h c} {
global fldmr uh urhf curhf
# uh = x:y ; urhf = unresolved host flood ; curh = consecutive urhf
if {(![botisop $c]) || ([matchattr $h of|of])} {return}
if {![info exists fldmr($c)]} {set fldmr($c) 0}
# This is to check if the channel is already locked (+MR)
scan $u %\[^@\]@%s ident host
set urh [string match "~*" "$ident"]
if {($urh == 0)||([string match "Guest?????" "$n"])} {
# if the idents are resolved or if the nick is guest, set curhf var to 0
# curhf is used to incr the main flood join times, if {curfh >= y(secs)}
set curhf($c) 0
} else {
if {![info exists urhf($c)]} {set urhf($c) ""}
if {$urh == $urhf($c)} {
# if urh == temp urhf, this the actual consecutive check procedure
# if urh != temp urhf, then it will "set urhf($c) $urh"
incr curhf($c)
utimer [lindex [split $uh :] 1] [list curhf:dec $c]
if {$curhf($c) >= [lindex [split $uh :] 0]} {
if {$fldmr($c) == "0"} {
putquick "MODE $c +MR-k unresolved.host.flood" -next
utimer 60 [list flood:unlock $c]
set fldmr($c) 1
return 0
}
}
} else {
set urhf($c) $urh
set curhf($c) 1
utimer [lindex [split $uh :] 1] [list curhf:dec $c]
}
}
}
proc curhf:dec {c} {
global curhf
incr curhf($c) -1
if {$curhf($c) < 0} {set curhf($c) 0}
return 0
}
proc flood:unlock {chan} {
global fldmr
set cmode [getchanmode $chan]
set fldmr($chan) 0
if {[string match "*R*M*" "$cmode"]} {putserv "MODE $chan -MR" ; return 0}
if {[string match "*M*" "$cmode"]} {putserv "MODE $chan -M" ; return 0}
if {[string match "*R*" "$cmode"]} {putserv "MODE $chan -R" ; return 0}
return 0
}
foreach t [utimers] {
if {[lindex $t 1] == "flood:unlock"} {killutimer [lindex $t end]}
if {[lindex $t 1] == "curhf:dec"} {killutimer [lindex $t end]}
}
set chans [channels]
set chans [split [string tolower $chans]]
foreach c $chans {
set fldmr($c) 0
set urhf($c) ""
set curhf($c) 0
}
Wanna make it universal proc (consecutive match pattern) (i.e)
proc flood:proc {description $chan x_times in_y_secs} {...}
These are some sample logs: (description)
% alphanumeric host flood
% unresolved ident/host flood
% alphanumeric nick flood
[25/12 02:53:58] • (JOINS) Nova29 (~pHRDhIBn@36.Red-80-39-227.dynamicIP.rima-tde.net)
[25/12 02:53:59] • (JOINS) Nora29 ( ~XqUIhtgs@tvn95-1-82-229-101-13.fbx.proxad.net)
[25/12 02:53:59] • Skipper sets mode: +MR-k alphanumeric.host.flood
---
[25/12 03:27:31] • (JOINS) tary921 (~j4n867074@12.144.115.136)
[25/12 03:27:31] • (JOINS) fjil0r (~r62s6332@209.161.218.85 )
[25/12 03:27:31] • (JOINS) uuvn378- (~h23c04614@208.164.114.85)
[25/12 03:27:31] • Skipper sets mode: +MR-k unresolved.host.flood
[25/12 03:27:31] • (JOINS) eoys318 ( ~c1u88uu1n@12.144.115.136)
[25/12 03:27:32] • (JOINS) mmoj505 (~m4186388p@61.244.116.229)
[25/12 03:27:31] • (JOINS) xdanyie ( ~eg7988gt4@12.144.115.136)
---
[25/12 03:35:21] • (JOINS) Pa|nT (~Nazim@as13-143.qualitynet.net)
[25/12 03:35:22] • (JOINS) pinky4 (pinky4@ip70-190-9-16.ph.ph.cox.net )
[25/12 03:35:23] • Skipper sets mode: +MR-k alphanumeric.host.flood
---
[25/12 07:15:19] • (JOINS) Pando-987 (~xgron-@af14-173.qualitynet.net)
[25/12 07:15:19] • (JOINS) pi-nky42 (pinky4@12.144.116.200 )
[25/12 07:15:20] • Skipper sets mode: +MR-k alphanumeric.nick.flood