Jump to content
  • 0

Where is the Anti WPE and RPE


hexor9

Question


  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  106
  • Reputation:   0
  • Joined:  11/16/11
  • Last Seen:  

Where is the script for that socket.h and socket.c

Link to comment
Share on other sites

6 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  106
  • Reputation:   0
  • Joined:  11/16/11
  • Last Seen:  

bump

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  32
  • Topics Per Day:  0.01
  • Content Count:  178
  • Reputation:   16
  • Joined:  06/25/12
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  106
  • Reputation:   0
  • Joined:  11/16/11
  • Last Seen:  

Anyone is this is for rathena?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  175
  • Reputation:   7
  • Joined:  09/13/12
  • Last Seen:  

i think he said it in his post that it is from eathena

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  45
  • Reputation:   1
  • Joined:  10/18/12
  • Last Seen:  

is this safe sir. From people who already Tried it. Glad to hear any's reply.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  84
  • Topics Per Day:  0.02
  • Content Count:  550
  • Reputation:   9
  • Joined:  11/06/12
  • Last Seen:  

this works for me when i am using r16797 but after upgrading to 17702 it doesnt work anymore

Link to comment
Share on other sites

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.

×
×
  • Create New...