;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DNSEXEC ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;info: ; ; by wiebe @ QuakeNet ; version 1.1 (written and tested on mIRC 6.15) ; ; ; last edit: Fri Jun 11 2004 ; ; ;What does this script do? ; ; script does a dns lookup and returns the result(s) to an alias ; ; ;How to use this script? ; ; /dnsexec [-ch] [params] ; ; ; /dnsexec [params] ; ; sends to alias: ; [params] -nick [more hosts/ips] ; ; ; /dnsexec [params] ; ; sends to alias: ; [params] [more hosts/ips] ; ; ; the switches are for the /dns command itself: ; ; the -c switch clears all currently queued DNS requests, except for the one currently in progress. ; ; the -h switch forces /dns to treat the parameter as a hostname ; ; WARNING: DO NOT USE HALT IN AN ALIAS, USE RETURN! ; halt also halts the calling alias/event, return only stops the current alias ; and gives control back to the calling alias/event ; using halt in alias'es that are called from this script can cause it not to work 100% ; ; 2 example scripts included at end ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS DNSEXEC ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; /dnsexec [-ch] [params..] alias dnsexec { ; switches are used, $3 is there, add to hash table, /dns if ($left($1,1) == -) && ($3) { hadd -m $+(dnsexec.,$cid) $2- .!dns $1-2 } ; no switches used, $2 is there, add to hash table, /dns elseif ($2) { hadd -m $+(dnsexec.,$cid) $1- .!dns $1 } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DNS EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; on *:DNS:{ ; ip addr or nick is in the hash table if ($hget($+(dnsexec.,$cid),$dns(0).ip)) || ($hget($+(dnsexec.,$cid),$dns(0).addr)) || ($hget($+(dnsexec.,$cid),$dns(0).nick)) { ; set vars var %x = 1, %ip, %addr ; loop to get all results and save them in vars while ($dns(%x)) { var %addr = $addtok(%addr,$dns(%x).addr,32), %ip = $addtok(%ip,$dns(%x).ip,32) inc %x } ; if no result is returned, if (!%addr) { var %addr = unresolved } | if (!%ip) { var %ip = unresolved } ; ip in hash table, send ip addr to the alias, remove from hash table if ($hget($+(dnsexec.,$cid),$dns(0).ip)) { $hget($+(dnsexec.,$cid),$dns(0).ip) $dns(0).ip %addr hdel $+(dnsexec.,$cid) $dns(0).ip } ; addr in hash table, send addr ip to the alias, remove from hash table if ($hget($+(dnsexec.,$cid),$dns(0).addr)) { $hget($+(dnsexec.,$cid),$dns(0).addr) $dns(0).addr %ip hdel $+(dnsexec.,$cid) $dns(0).addr } ; nick in hash table, send ip addr and nick to the alias, remove from hash table if ($hget($+(dnsexec.,$cid),$dns(0).nick)) { $hget($+(dnsexec.,$cid),$dns(0).nick) -nick $dns(0).nick $iif($dns(0).ip != $raddress,$dns(0).ip %addr,$dns(0).addr %ip) hdel $+(dnsexec.,$cid) $dns(0).nick } ; check if hash table is empty, free the hash table if ($hget($+(dnsexec.,$cid),0).item == 0) { hfree $+(dnsexec.,$cid) } } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EXAMPLES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; !dns script ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TEXT EVENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; on *:text:!dns *:#channel:{ if ($2 == -h) { dnsexec -h $3 dnspub $chan } else { dnsexec $2 dnspub $chan } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS DNSPUB ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; alias -l dnspub { if ($2 == -nick) { msg $1 dns $iif($6,results,result) for $3 ( $+ $4 $+ ) $iif($6,are,is) $+ : $5- } else { msg $1 dns $iif($4,results,result) for $2 $iif($4,are,is) $+ : $3- } } ; custom dns alias, shows all results ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS DNSPUB ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; alias dns { if (!$1-) { !dns | return } if ($left($1,1) == -) && ($len($1) isnum 2-3) && ($2) && (!$remove($1,-,c,h)) { var %s = - if (c isin $1) { var %s = %s $+ c } | if (h isin $1) { var %s = %s $+ h } tokenize 32 $2- } dnsexec $iif(%s != -,%s) $1 dns_callback } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIAS DNSPUB ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; alias -l dns_callback { if ($1 == -nick) { var %s2 = $2, %s3 = $3 tokenize 32 $4- echo $color(other) -ste * dns result for %s2 ( $+ %s3 $+ ) is: $* } else { var %s1 = $1 tokenize 32 $2- echo $color(other) -ste * dns result for %s1 is: $* } }