Ir para conteúdo

Flatron

Membro
  • Registro em

  • Última visita

Histórico de Curtidas

  1. Gostei
    Flatron deu reputação a KekezitoLHP em Proteção contra ataques DoS   
    Bom esse codigo não protege você de ataques DoS, ele simplesmente salvar tudo se internet cai, codigo simples mais ajuda um pouco, "sei que é ruim pra ca*****, seu ot cai e os jogadores fala eu tinha x lvl, tinha x item e você fica em duvida acaba dado as coisas pra não perde jogador"
     
    P: Mas como ver isso ?
    R: Ele ve se o site do www.google.com esta respondendo, se estiver, não entra em ação o código, se não estiver respondendo, o código entra em ação e nenhum player perde nada
     
    P: Se meu otserv cai por um bug ou eu fecho vai salva ?
    R: NÃO, so funciona com FALTA DE INTERNET, explicação melhor seu ot travo, o distro vai no google.com não abriu ele SALVA 
     
    P:Como ele salva sem internet?
    R: o otserv não precisa de internet pra funciona apenas pra você se loga de um outro computador, um caso é abri o otserv com o ip 127.0.0.1, ele entra, salva etc.
     
    P: O QUE É DoS
    R: https://pt.wikipedia.org/wiki/DOS
     
    P: To live de nukes ?
    R NÃO, ele apenas uma solução pra ajuda a não ter muitos danos com rollback "volta no tempo"
     
    ELE NÃO FUNCIONA PRA DDoS, mais se seu caso for falta de internet ele salva 
     
     
    RECOMENDADO: Use uma source de teste, teste tudo e muito bem, antes de coloca distro dentro do servidor oficial,LEMBRADO É DENTRO DAS SOURCE NÃO NA PASTA DATA
    Chega de blablabla e vamos la 
     
     
    Em game.cpp, procure 
    #include "talkaction.h" #include "spells.h" #include "configmanager.h" em baixo adicione:
    #include "tools.h" Procure :
    Game::Game() { em baixo adicione:
    #ifdef __UCB_DDOS_PROTECTION__ connectionTestFalseValidUntil = std::time(NULL) + 2*60; //Ignore verification in first 2 minutes connectionTestTrueValidUntil = connectionTestFalseValidUntil; connectionTestOk = true; #endif e na ultima linha adicione:
    #ifdef __UCB_DDOS_PROTECTION__ bool 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 Em game.h, procure 
    void internalCreatureChangeVisible(Creature* creature, bool visible); void changeLight(const Creature* creature); #ifdef __SKULLSYSTEM__ void changeSkull(Player* player, Skulls_t newSkull); #endif em baixo adicione:
    #ifdef __UCB_DDOS_PROTECTION__ bool isOutSideWorldResponding(); #endif Procure :
    uint32_t inFightTicks; uint32_t exhaustionTicks; uint32_t fightExhaustionTicks; Adicione:
    #ifdef __UCB_DDOS_PROTECTION__ bool connectionTestOk; uint32_t connectionTestTrueValidUntil; uint32_t connectionTestFalseValidUntil; #endif Em tools.cpp
     
    Adicione após a ultima linha:
    #ifdef __UCB_DDOS_PROTECTION__ bool isWorldReachable(){ int32_t ret; #if defined __WINDOWS__ ret = system("ping -n 1 -w 500 google.com > NUL"); #else ret = system("ping -q -c 1 -w 1 google.com > /dev/null"); #endif return (ret == 0); } #endif Em tools.h
     
    Adicione após a ultima linha:
    #ifdef __UCB_DDOS_PROTECTION__ bool isWorldReachable(); #endif Em player.cpp
     
    troca:
    if(skillLoss){ Por:
    #ifdef __UCB_DDOS_PROTECTION__ if(skillLoss && g_game.isOutSideWorldResponding()){ #else if(skillLoss){ #endif Troca
    experience -= getLostExperience(); Por:
    #ifdef __UCB_DDOS_PROTECTION__ if( g_game.isOutSideWorldResponding() ){ experience -= getLostExperience(); } #else experience -= getLostExperience(); #endif Agora vai em parametros e adicione no final
    -D__UCB_DDOS_PROTECTION__

Informação Importante

Confirmação de Termo