hexor9 Posted April 29, 2013 Group: Members Topic Count: 30 Topics Per Day: 0.01 Content Count: 106 Reputation: 0 Joined: 11/16/11 Last Seen: October 16, 2016 Share Posted April 29, 2013 Where is the script for that socket.h and socket.c Quote Link to comment Share on other sites More sharing options...
hexor9 Posted April 30, 2013 Group: Members Topic Count: 30 Topics Per Day: 0.01 Content Count: 106 Reputation: 0 Joined: 11/16/11 Last Seen: October 16, 2016 Author Share Posted April 30, 2013 bump Quote Link to comment Share on other sites More sharing options...
chowking Posted May 6, 2013 Group: Members Topic Count: 32 Topics Per Day: 0.01 Content Count: 178 Reputation: 17 Joined: 06/25/12 Last Seen: September 22, 2022 Share 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 Link to comment Share on other sites More sharing options...
hexor9 Posted May 6, 2013 Group: Members Topic Count: 30 Topics Per Day: 0.01 Content Count: 106 Reputation: 0 Joined: 11/16/11 Last Seen: October 16, 2016 Author Share Posted May 6, 2013 Anyone is this is for rathena? Quote Link to comment Share on other sites More sharing options...
orange Posted May 29, 2013 Group: Members Topic Count: 39 Topics Per Day: 0.01 Content Count: 175 Reputation: 7 Joined: 09/13/12 Last Seen: May 14, 2021 Share Posted May 29, 2013 i think he said it in his post that it is from eathena Quote Link to comment Share on other sites More sharing options...
dice4real Posted July 20, 2013 Group: Members Topic Count: 1 Topics Per Day: 0.00 Content Count: 45 Reputation: 1 Joined: 10/18/12 Last Seen: October 29, 2024 Share Posted July 20, 2013 is this safe sir. From people who already Tried it. Glad to hear any's reply. Quote Link to comment Share on other sites More sharing options...
Erba Posted February 25, 2014 Group: Members Topic Count: 84 Topics Per Day: 0.02 Content Count: 550 Reputation: 9 Joined: 11/06/12 Last Seen: August 14, 2014 Share Posted February 25, 2014 this works for me when i am using r16797 but after upgrading to 17702 it doesnt work anymore Quote Link to comment Share on other sites More sharing options...
Question
hexor9
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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.