Import Upstream version 1.0.35
This commit is contained in:
parent
b28bb7b29b
commit
a04a7bcd67
44 changed files with 4173 additions and 2323 deletions
|
|
@ -639,6 +639,9 @@ void setup_outgoing_connection(outgoing_t *outgoing) {
|
|||
new connection
|
||||
*/
|
||||
bool handle_new_meta_connection(int sock) {
|
||||
static const int max_accept_burst = 10;
|
||||
static int last_accept_burst;
|
||||
static int last_accept_time;
|
||||
connection_t *c;
|
||||
sockaddr_t sa;
|
||||
int fd;
|
||||
|
|
@ -651,6 +654,22 @@ bool handle_new_meta_connection(int sock) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if(last_accept_time == now) {
|
||||
last_accept_burst++;
|
||||
|
||||
if(last_accept_burst >= max_accept_burst) {
|
||||
if(last_accept_burst == max_accept_burst) {
|
||||
ifdebug(CONNECTIONS) logger(LOG_WARNING, "Throttling incoming connections");
|
||||
}
|
||||
|
||||
tarpit(fd);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
last_accept_burst = 0;
|
||||
last_accept_time = now;
|
||||
}
|
||||
|
||||
sockaddrunmap(&sa);
|
||||
|
||||
c = new_connection();
|
||||
|
|
@ -672,7 +691,6 @@ bool handle_new_meta_connection(int sock) {
|
|||
connection_add(c);
|
||||
|
||||
c->allow_request = ID;
|
||||
send_id(c);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue