[mIRC] Request: Ban an IP file

A quick and short script written to zline IPs in a specified file. The IPs must be listed in the file as one IP per line, e.g.:

1.3.4.5
1.2.3.4
1.4.5.6
5.6.3.2
6.7.8.6
etc…

Follow the instructions to use.

; To use:
;1) Type /ipban.reset
;2) Ensure you specify the right file/directory in set %ipban.ipfile "nodes.csv"
;3) Type /ipban
;4) Wait until script completes, can take a while depending on size of file.

alias -l ipban_next {
  if (%ipban.pos <= %ipban.total) {
    zline $+(*@,$read(%ipban.ipfile,%ipban.pos)) 1d Tor Exit Servers are not permitted on this network
    inc %ipban.pos
    ipban
  }
  else {
    echo -atc info *** Zlined %ipban.total IPs from %ipban.ipfile
    .unset %ipban.*
  }
}
alias ipban {
  set %ipban.ipfile "nodes.csv"
  if ($isfile(%ipban.ipfile) == $false) { echo -atc info *** IP Ban Error: %ipban.ipfile does not exist | return }
  set %ipban.total $lines(%ipban.ipfile)
  if (%ipban.pos == $null) { set %ipban.pos 1 }
  .timer -m 1 5 ipban_next
}
alias ipban.reset .unset %ipban.*

Let me bring to attention my use of timers over a while loop for budding scripters.

The reason is for large IP files, a while loop will freeze your script. For this reason a timer was used with a 5 millisecond delay, ensuring fast zlines but without freezing the script.

I will edit this script to auto carry out /ipban.reset upon execution, but, as of now, this isn’t required as it does its job (plus I’m short on time again!!!).

Note: to edit the zline time and message:

zline $+(*@,$read(%ipban.ipfile,%ipban.pos)) 1d Tor Exit Servers are not permitted on this network

Change:
“1d” to something you want
“Tor Exit Servers are not permitted on this network” to something you want


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.