Jump to content
  • 0

Where is the Anti WPE and RPE


Question

6 answers to this question

Recommended Posts

Posted (edited)

is this it? you might wanna try to update the code since this is from eathena, idk if it will work here on rathena

 

code is not mine so credits to whoever released/contributed this

Index: src/common/socket.c
===================================================================
--- src/common/socket.c	(revision 14799)
+++ src/common/socket.c	(working copy)
@@ -196,6 +196,8 @@
 time_t last_tick;
 time_t stall_time = 60;
 
+uint32 max_packet_spam = 20; // max. allowed TCP packets per second
+
 uint32 addr_[16];   // ip addresses of local host (host byte order)
 int naddr_ = 0;   // # of ip addresses
 
@@ -324,6 +326,21 @@
 
 	session[fd]->rdata_size += len;
 	session[fd]->rdata_tick = last_tick;
+
+	// packet flood detection
+	if( DIFF_TICK(last_tick, session[fd]->last_reset) >= 1 )
+	{
+		if( !session[fd]->flag.server && session[fd]->packet_counter > max_packet_spam)
+		{
+			ShowWarning("Client %s is spamming packets too fast!\n", ip2str(session[fd]->client_addr, NULL));
+			//set_eof(fd); // uncomment to also kick this spammer
+		}
+
+		session[fd]->packet_counter = 0;
+		session[fd]->last_reset = last_tick;
+	}
+	session[fd]->packet_counter++;
+
 	return 0;
 }
 
Index: src/common/socket.h
===================================================================
--- src/common/socket.h	(revision 14799)
+++ src/common/socket.h	(working copy)
@@ -93,6 +93,10 @@
 	SendFunc func_send;
 	ParseFunc func_parse;
 
+	// packet flood detection
+	uint32 packet_counter; // counts received packets per iteration
+	time_t last_reset; // time when the counter was last reset
+
 	void* session_data; // stores application-specific data related to the session
 };
 
Edited by chowking

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...