hexor9 Posted April 29, 2013 Posted April 29, 2013 Where is the script for that socket.h and socket.c Quote
chowking Posted May 6, 2013 Posted May 6, 2013 (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 May 6, 2013 by chowking Quote
orange Posted May 29, 2013 Posted May 29, 2013 i think he said it in his post that it is from eathena Quote
dice4real Posted July 20, 2013 Posted July 20, 2013 is this safe sir. From people who already Tried it. Glad to hear any's reply. Quote
Erba Posted February 25, 2014 Posted February 25, 2014 this works for me when i am using r16797 but after upgrading to 17702 it doesnt work anymore Quote
Question
hexor9
Where is the script for that socket.h and socket.c
6 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.