Русское сообщество по скриптингу

Connection Protect for HL1 Engine

Все вопросы по работе и настройке Metamod и его плагинов.
Правила форума
1. Запрещено материться и оскорблять других участников форума.
2. Запрещен флуд, оффтоп, дабл постинг во всех разделах форума, кроме раздела "Болтовня".
3. Запрещено взламывать сайт/форум или наносить любой вред проекту.
4. Запрещено рекламировать другие ресурсы.
5. Запрещено создавать темы без информативного названия. Название темы должно отображать ее смысл.

В данном разделе форума разрешено создавать темы, касающие только вопросов по Metamod и его плагинам.

Connection Protect for HL1 Engine

Сообщение xakintosh » 30 июл 2012, 14:01

Hello i'am trying to learn little more about HL1 coding but it's really hard without some basic examples and tutorials.

My first project is based on thread for flood that i see Вы должны зарегистрироваться, чтобы видеть ссылки.. I start searching for common projects and found one-two-three but all for SourceMOD. Then i go MAD :) and decide to try to reverse it in metamod code. But nothing happen, becouse there are functions that the plugin need but are not really there and cannot build the project. ( I think so... )
Original plugin for SM is Вы должны зарегистрироваться, чтобы видеть ссылки.

This is my code for now. Please help me to fix & run it.
Код: Выделить всё
#include "amxxmodule.h"
#include "protect_amxx.h"
#include "netadr.h"
// ===============================================================================================================
#define fClearTrieTime         12.4
#define iConnectionBanCount      6
#define iIPLength            17
// new Handle:g_hTrie;
// ===============================================================================================================
void OnMetaAttach() { printf("\n   Enter on Meta\n\n"); } // g_hTrie = CreateTrie();
void OnMetaDetach() { printf("\n   Exit on Meta\n\n"); }
// ===============================================================================================================
BOOL ClientConnect(edict_t *pEntity, const char *pszAddress, char szRejectReason[128]) {
   // ==================================
   int iPlayer = ENTINDEX(pEntity);

   char sIP[IPLEN+1], *p;
   const char *playerIP = netadr_t->ip[IPLEN+1]
   
   // ==================================
   if (IsFakeClient(client)) {
      return true; // Why would we want to even check these clients?
   }
   decl String:sIP[iIPLength];
   if (!GetClientIP(client, sIP, sizeof(sIP))) {
      return true; // We don't want to reject them if we can't get their IP... Although this should never happen.
   }
   // ==================================
    if (!GetTrieValue(g_hTrie, sIP, iConnectionCount))
   {
      new Handle:hPack = INVALID_HANDLE;
      CreateDataTimer(fClearTrieTime, ClearValueFromTrie, hPack, TIMER_DATA_HNDL_CLOSE);
      WritePackString(hPack, sIP);
      ResetPack(hPack);
      
      SetTrieValue(g_hTrie, sIP, 0);
      return true; // We don't want to call the below code if this trap works.
   }
   
   if (iConnectionCount == iConnectionBanCount)
   {
      PrintToChatAll("\x04[CFP]\x03 Banning %N (%s) for flooding connections to the server.", client, sIP);
      LogToGame("[CFP] Banning %N (%s) for flooding connections to the server.", client, sIP);
      strcopy(rejectmsg, maxlen, "Banned for Connection Flooding.");
      BanClient(client, 0, BANFLAG_IP, "Connection Flooding.", "Banned for Connection Flooding.", "sm_connectflood_protection");
      ServerCommand("sm_banip \"%s\" 0 \"Connection Flooding.\"", sIP);
      return false;
   }
   // ==================================
   SetTrieValue(g_hTrie, sIP, (iConnectionCount + 1));
    RETURN_META_VALUE(MRES_IGNORED, true);
   // ==================================
}


And my protect_amxx.h
Код: Выделить всё
#ifndef _INCLUDE_PROTECT_AMXX_H
#define _INCLUDE_PROTECT_AMXX_H

// SOME CUSTOM DEFFINITIONS!

#endif //_INCLUDE_PROTECT_AMXX_H
Аватара пользователя
xakintosh
 
Сообщения: 17
Зарегистрирован: 31 янв 2010, 17:03
Откуда: Bulgaria
Благодарил (а): 2 раз.
Поблагодарили: 0 раз.
Опыт программирования: Больше трех лет
Языки программирования: Counter-Strike 1.6
DotA
BFBC2
SWTOR
TERA
BNS
Diablo II
Mafia II

Re: Connection Protect for HL1 Engine

Сообщение 6a6kin » 30 июл 2012, 14:27

This plugin will protect only from real players, that trying to flood your servers. If anyone will use flood program, that flood by connect packets, this function will not called. If u need to protect from software like this, u need hook calls of real engine functions by patching memory. For example meta plugin like this, see Вы должны зарегистрироваться, чтобы видеть ссылки..

If u only need to protect from real connections, u can look at all checks in plugin above and try to use it in your plugin.

But your code isn't metamod plugin. Example of metamod plugins here — Вы должны зарегистрироваться, чтобы видеть ссылки. , here — Вы должны зарегистрироваться, чтобы видеть ссылки. — some information.
На заказ не пишу.
Аватара пользователя
6a6kin
Скриптер
 
Сообщения: 332
Зарегистрирован: 09 мар 2010, 16:40
Благодарил (а): 38 раз.
Поблагодарили: 278 раз.

Re: Connection Protect for HL1 Engine

Сообщение xakintosh » 31 июл 2012, 20:35

Thank you for the info that provide me.
I'am learning about the HLDSK and i was thinking that ConnectClient function will save me from flooding with packets.

I was testing some time ago a program called Exploits 1.7 there i test every function invidual with different protocol (47,48,hltv) and i see something that is strange to me.
Strange thing was not crash but server slots spam i think. Maybe with Counting IP and blocking the same ip will fix this.

Once more Thanks For giving me your link.
Аватара пользователя
xakintosh
 
Сообщения: 17
Зарегистрирован: 31 янв 2010, 17:03
Откуда: Bulgaria
Благодарил (а): 2 раз.
Поблагодарили: 0 раз.
Опыт программирования: Больше трех лет
Языки программирования: Counter-Strike 1.6
DotA
BFBC2
SWTOR
TERA
BNS
Diablo II
Mafia II


Вернуться в Вопросы по Metamod и его плагинам

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 5

cron