Raised This Month: $32 Target: $400
 8% 

Connection Protect for HL1 Engine


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xakintosh
I run no-steam servers!
Join Date: Feb 2010
Location: Edge of nowhere
Old 07-25-2012 , 13:37   Connection Protect for HL1 Engine
Reply With Quote #1

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 here. 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 here

This is my code for now. Please help me to fix & run it.
Code:
#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);
	// ==================================
}
__________________
As soon as possible.

Last edited by xakintosh; 07-29-2012 at 09:55.
xakintosh is offline
Send a message via Yahoo to xakintosh Send a message via Skype™ to xakintosh
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-25-2012 , 14:35   Re: Connection Protect for HL1 Engine
Reply With Quote #2

I think that an efficient fix to this issue would be to run a steam server.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 07-25-2012 , 22:23   Re: Connection Protect for HL1 Engine
Reply With Quote #3

where is this header file protect_amxx.h ?
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
xakintosh
I run no-steam servers!
Join Date: Feb 2010
Location: Edge of nowhere
Old 07-26-2012 , 05:05   Re: Connection Protect for HL1 Engine
Reply With Quote #4

Here it is.

Code:
#ifndef _INCLUDE_PROTECT_AMXX_H
#define _INCLUDE_PROTECT_AMXX_H

// SOME CUSTOM DEFFINITIONS!

#endif //_INCLUDE_PROTECT_AMXX_H
__________________
As soon as possible.
xakintosh is offline
Send a message via Yahoo to xakintosh Send a message via Skype™ to xakintosh
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 08-02-2012 , 06:01   Re: Connection Protect for HL1 Engine
Reply With Quote #5

this is the amxx code, un-test:

Code:
#include <amxmodx> #include <fakemeta> #define PLUGIN_NAME "Connnection Protection" #define PLUGIN_VERSION  "0.1" #define fClearTrieTime      12.4 #define iConnectionBanCount  6 new Trie:ghTrie; public plugin_init( ) {     register_plugin( PLUGIN_NAME , PLUGIN_VERSION , "LittleKu-Lv" );         register_cvar( "amx_cfp_version" , PLUGIN_VERSION , FCVAR_SPONLY | FCVAR_SERVER );         register_forward( FM_ClientConnect , "fwClientConnectPost" , true );         ghTrie = TrieCreate(); } public fwClientConnectPost( id , const szName[] , const szAddress[] , const szRejectReason[ 128 ] ) {     if ( pev( id , pev_flags ) & FL_FAKECLIENT )     {         return FMRES_IGNORED;     }         if ( szAddress[ 0 ] == 0 )     {         return FMRES_IGNORED;     }         static iConnectionCount;     static params[ 32 ];         if ( !TrieGetCell( ghTrie , szAddress , iConnectionCount ) )     {         copy( params , 31 , szAddress );         set_task( fClearTrieTime , "ClearValueFromTrie" , 0 , params , 32 );                 TrieSetCell( ghTrie , szAddress, 0 );         return FMRES_IGNORED;     }         if ( iConnectionCount == iConnectionBanCount )     {         static iUserId;         iUserId = get_user_userid( id );         server_cmd( "kick #%d;addip 0 %s;writeip" , iUserId , szAddress );         return FMRES_IGNORED;     }         TrieSetCell( ghTrie , szAddress , ( iConnectionCount + 1 ) );     return FMRES_IGNORED; } public ClearValueFromTrie( params[] ) {     static szAddress[ 32 ];         copy( szAddress, 31, params );         TrieDeleteKey( ghTrie , szAddress );         return PLUGIN_CONTINUE; } public plugin_end() {     TrieClear( ghTrie ); }
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
GordonFreeman (RU)
Veteran Member
Join Date: Jan 2010
Location: Uzbekistan
Old 08-03-2012 , 06:09   Re: Connection Protect for HL1 Engine
Reply With Quote #6

there is already plugin made by 6a6kin, you can find it on his SVN: https://github.com/6a6kin/FloodBlocker/
K.K.Lv, fake players doesnt appear on client_connect, u can catch them on ClientUserInfoChanged, but without IP.
Use metamod plugin from SVN.

6a6kin is awesome.
__________________
The functional way is the right way
GordonFreeman (RU) is offline
xakintosh
I run no-steam servers!
Join Date: Feb 2010
Location: Edge of nowhere
Old 08-03-2012 , 06:20   Re: Connection Protect for HL1 Engine
Reply With Quote #7

I talk with 6a6kin on russian amxx forum and i got it few days back.
I also success to compile it and i'am using it now.
Thanks to 6a6kin! He's AWESOME!!!!

But still i need "Connnection Protection" for metamod plugin, if is possible. I just don't have time now to take a close look in hlsdk and review my options.
__________________
As soon as possible.

Last edited by xakintosh; 08-03-2012 at 06:23.
xakintosh is offline
Send a message via Yahoo to xakintosh Send a message via Skype™ to xakintosh
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 08-03-2012 , 12:25   Re: Connection Protect for HL1 Engine
Reply With Quote #8

nice link GordonFreeman,and thanks for your tips
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
alexinno
Senior Member
Join Date: Mar 2007
Location: C:\
Old 08-08-2012 , 05:58   Re: Connection Protect for HL1 Engine
Reply With Quote #9

Quote:
Originally Posted by GordonFreeman (RU) View Post
there is already plugin made by 6a6kin, you can find it on his SVN: https://github.com/6a6kin/FloodBlocker/
K.K.Lv, fake players doesnt appear on client_connect, u can catch them on ClientUserInfoChanged, but without IP.
Use metamod plugin from SVN.

6a6kin is awesome.
i don't understand how to compile that plugin
__________________

[IMG]http://img188.**************/img188/5787/banner2rcw.png[/IMG]
alexinno is offline
xakintosh
I run no-steam servers!
Join Date: Feb 2010
Location: Edge of nowhere
Old 08-08-2012 , 06:01   Re: Connection Protect for HL1 Engine
Reply With Quote #10

Start reading about compiling windows or linux modules for metamod.
I search alot and find everything, try yourself.
__________________
As soon as possible.
xakintosh is offline
Send a message via Yahoo to xakintosh Send a message via Skype™ to xakintosh
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:52.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode