All pastes #240356 Raw Edit

Unnamed

public text v1 · immutable
·published 2006-11-05 18:50 UTC
rendered paste body
on *:DNS:{
  if ($raddress) {
    if ($raddress isnum) { traceip $raddress }
    else { 
      var %tot = $dns(0)
      var %i = 1
      while (%i <= %tot) {
        traceip -m $dns(%i).ip
        inc %i
      }
    }
  }
  else {
    traceip $dns(0).ip
  }
}

alias traceip {
  if ($1) {
    if ($1 == -m) {
      if (!$2) { echo $color(info) -a * /traceip: insufficient parameters }
      else {
        %ip = $2
        if (!$sock(traceip $+ $2)) { sockopen traceip $+ %ip www.dnsstuff.com 80 }
      }
    }
    else {
      %ip = $1
      if (!$sock(traceip $+ $1)) { sockopen traceip $+ %ip www.dnsstuff.com 80 }
    }
  }
}

on *:SOCKOPEN:traceip*:{
  if ($sockerr > 0) {
    sockclose $sockname
    echo $color(info) -at * An error has accured.
    if ($sockerr == 3) {                                                     
      if (!$sock($sockname)) { sockopen traceip $+ %ip www.dnsstuff.com 80 }
    }
  }
  else {
    sockwrite -n $sockname GET /tools/whois.ch?ip= $+ %ip HTTP/1.1
    sockwrite -n $sockname Host: www.dnsstuff.com
    sockwrite -n $sockname Connection: keep-alive
    sockwrite $sockname $crlf 
  }
}

on *:SOCKCLOSE:traceip*:{
  if (!%ip) { * An error has accured. }
}

on *:SOCKREAD:traceip*:{
  sockread %trace
  tokenize 32 %trace
  if (Country: isin %trace) {
    echo $color(other) -at %ip is in $2-
    sockclose $sockname
  }
  unset %trace
  .timerruns 1 1 unset %ip
}

menu nicklist {
  Country $chr(91) $+ $mid($address($$1,2),5,$len($address($$1,2))) $+ $chr(93):dns $mid($address($$1,2),5,$len($address($$1,2)))
}

menu query {
  Country $chr(91) $+ $gettok($query($$1).addr,2,64) $+ $chr(93):dns $gettok($query($$1).addr,2,64)