• 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!

No internet No death

Kungenn

Veteran OT User
Joined
Jun 10, 2007
Messages
1,623
Reaction score
282
Location
USA California
Okay so I were searching around forums yesterday cause we had ping attacks on our server and I found something interesting that might not just be good for ping attacks but for all the time.


I can find the codes again if this sounds interesting and post them here and perhaps someone can make them flawless :)

Anyway so what it does is simply if a player dies the server check if it can connect to a certain website, (this could a option in config.cfg perhaps checksite = "www.google.com") and if it can connect the player dies and lose skill blabla just like a normal death.

BUT if it can't connect to the website given the player that dies simply ends up in the temple with same skills & level & items.

This would prevent people from losing levels if its the server internet that disconnects..

I think this is a really good thing and imo even cip should use it :)



I'll find the codes and post them soon.

Thanks for reading! (;



COPIED FROM Proglin
Problem: your server is constantly under DDoS / Flood / Nuke attack and players are dying.

One possible solution: when player dies try to reach a computer outside to see if your server connection is ok.

Comments: I have developed this solution because my server in constantly under DDoS attack. I used SVN revision from begining of December, but you can use this code as base to your personal necessity.


Modifications:

@ game.cpp

After:
C++:

#include "talkaction.h"
#include "spells.h"
#include "configmanager.h"

Add:
C++:

#include "tools.h"

After:
C++:

Game::Game()
{

Add:
C++:

#ifdef __UCB_DDOS_PROTECTION__
connectionTestFalseValidUntil = std::time(NULL) + 2*60; //Ignore verification in first 2 minutes
connectionTestTrueValidUntil = connectionTestFalseValidUntil;
connectionTestOk = true;
#endif


At botton add:
C++:

#ifdef __UCB_DDOS_PROTECTION__
bool Game::isOutSideWorldResponding(){
OTSYS_THREAD_LOCK_CLASS lockClass(gameLock, "Game::isOutSideWorldResponding()");
uint32_t now = std::time(NULL);
if( !connectionTestOk ){
if( now > connectionTestFalseValidUntil ){
//Redo test
connectionTestOk = isWorldReachable();
connectionTestFalseValidUntil = now + 60; //False result is valid for 60 seconds
}
} else {
if( now > connectionTestTrueValidUntil ){
//Redo test
connectionTestOk = isWorldReachable();
connectionTestTrueValidUntil = now + 10; //Ok result is valid for 10 secongs
}
}
return connectionTestOk;
}
#endif


@ game.h

After:
C++:

void internalCreatureChangeVisible(Creature* creature, bool visible);
void changeLight(const Creature* creature);

#ifdef __SKULLSYSTEM__
void changeSkull(Player* player, Skulls_t newSkull);
#endif


Add:
C++:

#ifdef __UCB_DDOS_PROTECTION__
bool isOutSideWorldResponding();
#endif


After:
C++:

uint32_t inFightTicks;
uint32_t exhaustionTicks;
uint32_t fightExhaustionTicks;


Add:
C++:

#ifdef __UCB_DDOS_PROTECTION__
bool connectionTestOk;
uint32_t connectionTestTrueValidUntil;
uint32_t connectionTestFalseValidUntil;
#endif


@ tools.cpp

Add at bottom:
C++:


#ifdef __UCB_DDOS_PROTECTION__
bool isWorldReachable(){
int32_t ret;
#if defined __WINDOWS__
ret = system("<span class="highlight">ping</span> -n 1 -w 500 google.com > NUL");
#else
ret = system("<span class="highlight">ping</span> -q -c 1 -w 1 google.com > /dev/null");
#endif
return (ret == 0);
}
#endif


@ tools.h

Add at bottom:

C++:

#ifdef __UCB_DDOS_PROTECTION__
bool isWorldReachable();
#endif


@ player.cpp

Change this line:
C++:

if(skillLoss){

To:
C++:


#ifdef __UCB_DDOS_PROTECTION__
if(skillLoss && g_game.isOutSideWorldResponding()){
#else
if(skillLoss){
#endif


Chage this other line:
C++:

experience -= getLostExperience();

To:
C++:


#ifdef __UCB_DDOS_PROTECTION__
if( g_game.isOutSideWorldResponding() ){
experience -= getLostExperience();
}
#else
experience -= getLostExperience();
#endif




Now rebuild all and test :p (remeber to use flag: -D__UCB_DDOS_PROTECTION__

Note: you can change the part "google.com" for anyone that you think is better. For test if this is ok, change this part to a site that you know that is not responding and kill youself in server. If it works ok you will go to temple with full life.

Have new year

Later I could improve this code.

Have FUN

-- This code is free to use and modify. Original credits will be fine --
 
Last edited:
I agree, it could easily be abused.
If you disconnected your internet connection from your computer then it sounds like it wouldnt work to me.

"AFF GETTING PK'D AGAIN"
<disconnects net>
<returns in temple>
"NOOBS!"
 
NO, lol
Its a SERVER side... Lol if the SERVER gets disconnected from the inet not if the player gets disconnect..

Lets say someone ping attacks the server, the server lose its connection to internet all the players freeze, monsters will still be able to attack and all that are hunting will die.

IF the server can't connect to the website given it simply will let the players spawn in temple again with skills/loot/level

However if the player unplug his internet cable he will still lose skills cause when he dies the server tries to connect to lets say google.com

ok it worked then player dies and lose skills blabla
 
@Kungenn same code i saw hehe :p
i mean the one i saw while looking arround b4 now i am studying.
oh and ty for searching and finding this code ^^
 
How this work is that:
You add this to your server - the server check if you loose your internett
(not by checking if player status on every character ingame lost internett)
But it check www.google.com, and if the server (hosting computer) suddenlly cant connect to www.google.com it means you have lost your internett, then it will make sure that during that internett kick, players that got kicked ingame and most likely got killed since they was hunting, that they don't loose anything on it.
 
Last edited:
This doesn't work for me though
Code:
 C:\Documents and Settings\Vicke\Skrivbord\forgotten Sources\forgottenserver\trunk\game.cpp In member function `bool Game::isOutSideWorldResponding()': 

4820 C:\Documents and Settings\Vicke\Skrivbord\forgotten Sources\forgottenserver\trunk\game.cpp `gameLock' was not declared in this scope 

 C:\Documents and Settings\Vicke\Skrivbord\forgotten Sources\Project\Makefile.win [Build Error]  [../forgottenserver/trunk/game.o] Error 1
 
Back
Top