• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

GlobalEvent Full working DDoS protection*

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Reaction score
106
Location
Brazil

Distro: TFS 0.3.x
--------
Author:
bearpaw.png

--------
Require: Lua socket (Install here: http://otland.net/f163/lua-modules-otserv-socket-luasql-74836/)
--------
Version: 1.0

Hello, before anithinf i had to say, this script only REDUCE da,ages by DDoS attack dont protect you! This script check your connection, if another website dont response this sscript will kick all players to dont made players die!
Lest install, go to globalevents and add this tag:
PHP:
<globalevent name="ddos" interval="120" event="script" value="noDDoS.lua"/>
See it: intervla='120'
Here is a good question, if this script runs every 120 seconds each 120 seconds this script will check if an website (in case google) is online, if your connection need 3 seconds to load google this script will freeze your server BY 3 seconds, if you put interval = 10 mins, if you get DDoS attack this script will not work better because DDoS attack take around 1~3 mins to kill many players because lag.

Lest go to script:
Lua:
------ DDoS protection
------ By Mock
------ Require Lua socket
local conf = {
      check_website1 = 'http://www.google.com/', ---- First website
      check_website2 = 'http://pt.wikipedia.org/', ---- Second website
      ifoff = { --- If this 2 websites was offline
            kickall = true, --- Kick all players?
            save = true, --- Save server?
            closeserver = true, --- Exit server?
      }
}
--[[
This script every X seconds will check if google is online,
if google is off it will check wikipedia, if wikipedia is
off too is because your net is verry overloaded (DDoS attack)
or your connection is down. If all this is off this script
will kick all players, save server and close server.
]]
function onThink(interval, lastExecution)
    assert(socket,'Please install socket!')
    assert(socket.http,'Please install socket.http')
    local re,info,kind = pcall(socket.http.request,conf.check_website1)
    if not info or re == false then
       print('::Google is off?\a')
       if conf.check_website2 and conf.check_website2 ~= '' and conf.check_website2:len() > 6 then
          local re,info,kind = pcall(socket.http.request,conf.check_website2)
          if not info or re == false then
             print('::We are under attack or you connection is offline!\a\a')
             if conf.ifoff.kickall == true then
                for i,b in pairs(getPlayersOnline()) do
                    doRemoveCreature(b)
                end
             end
             if conf.ifoff.save == true then
             saveServer()
             end
             if conf.ifoff.closeserver == true then
             os.sleep(2)
             os.exit()
             end
          end
       end
    end
        return TRUE
end

Now look it, website1 and website2, ig google is offline it's because or your net is down or your connection is overloaded and your server will keep running but players will die for monsters :huh:. So this script check if google is online, if google is off script will: kick all players, save server, close server to prevent damages. But if google is offline and your net no in config you can change the second website to check!
You can change, goole to youtube, facebook, yahoo, or another website with HIG uptime around 99.9%~ and fast loading.​
 
Last edited:
Very good scripted and explained, and very short compared with other versions. Thanks!

It freezes server by 3 seconds, perhaps send status message to all players before the freeze start "Anti DDoS measure check, please wait..."

What we need now, is a auto restarter script that checks the two websites, if they get fast responses 10 times in a row (DDoS attack is off) server starts again. :p

Or in the case of a regular /closeserver
then make it /openserver once ddos is off.
 
It does not protect against ddos, it's just saving players :D
 
Yes look at the name
Full working DDoS protection*
 
Message would be a bad idea, it would be annoying to see a message every 2 minutes

edit: thanks, I will be sure to use this
 
It does not have to be a broadcast ,it can be a small sentence in Server Log. :p
 
Very good job Mock.

I believe that instead of removing the player, something like disable ALL the death penalty.
 
Bug

i have error in console and use TFS 3.6_SVN

[08/04/2010 10:30:36] [Error - GlobalEvent Interface]
[08/04/2010 10:30:36] data/globalevents/scripts/noDDoS.lua:eek:nThink
[08/04/2010 10:30:36] Description:
[08/04/2010 10:30:36] data/globalevents/scripts/noDDoS.lua:21: Please install socket!
[08/04/2010 10:30:36] stack traceback:
[08/04/2010 10:30:36] [C]: in function 'assert'
[08/04/2010 10:30:36] data/globalevents/scripts/noDDoS.lua:21: in function <data/globalevents/scripts/noDDoS.lua:20>
[08/04/2010 10:30:36] [Error - GlobalEvents::think] Couldn't execute event: ddos
 
CAn you write it more clear? I just need to put socket.lua in data/lib folder and Thats all or what?
 
@legolas23
not socket.lua
you need install lua socket using lua modules.
 
Back
Top