ZNZNCOOP

trace

May 16th, 2014
295
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local tArgs = { ... }
  2. if #tArgs == 0 then
  3.     print( "Usage: trace <ip> [<gateip>]" )
  4.     return
  5. end
  6. target=tArgs[1]
  7. if not open() then return end
  8. if not getIP(tArgs[2]) then return end
  9.  
  10. hop=0
  11. while true do
  12.   send(target,'ping',hop)
  13.   mess,addr=receive(3)
  14.   mess=mess or 'No answer' addr=addr or ''
  15.   if mess=='TTL ower' then  mess='- Ok' end
  16.   write(hop..' '..addr) print(' ',mess)
  17.   if mess=='- Ok' then
  18.     hop=hop+1
  19.     if hop>30 then break end
  20.   else
  21.     break
  22.   end
  23.   sleep(1)
  24. end
RAW Paste Data