beeki

Untitled

Jul 3rd, 2014
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.69 KB | None | 0 0
  1. ------ DDoS protection
  2. ------ By Mock
  3. ------ Require O.T.A.L
  4. ------ [url]http://otal.awardspace.info/[/url]
  5. local conf = {
  6.       check_website1 = 'http://www.google.com/', ---- First website
  7.       check_website2 = 'http://pt.wikipedia.org/', ---- Second website
  8.       ifoff = { --- If this 2 websites was offline
  9.             kickall = true, --- Kick all players?
  10.             save = true, --- Save server?
  11.             closeserver = true, --- Exit server?
  12.       }
  13. }
  14. --[[
  15. This script every X seconds will check if google is online,
  16. if google is off it will check wikipedia, if wikipedia is
  17. off too is because your net is verry overloaded (DDoS attack)
  18. or your connection is down. If all this is off this script
  19. will kick all players, save server and close server.
  20. ]]
  21. function onThink(interval, lastExecution)
  22.     local re,info,kind = pcall(socket.http.request,conf.check_website1)
  23.     if not info or re == false then
  24.        print('::Google is off?a')
  25.        if conf.check_website2 and conf.check_website2 ~= '' and conf.check_website2:len() > 6 then
  26.           local re,info,kind = pcall(socket.http.request,conf.check_website2)
  27.           if not info or re == false then
  28.              print('::We are under attack or you connection is offline!aa')
  29.              if conf.ifoff.kickall == true then
  30.                 for i,b in pairs(getOnlinePlayers()) do
  31.                     doRemoveCreature(b)
  32.                 end
  33.              end
  34.              if conf.ifoff.save == true then
  35.              saveServer()
  36.              end
  37.              if conf.ifoff.closeserver == true then
  38.              os.sleep(2)
  39.              os.exit()
  40.              end
  41.           end
  42.        end
  43.     end
  44.         return TRUE
  45. end
Advertisement
Add Comment
Please, Sign In to add comment