using node.js, the net module for building a tcp server which can hande http requests.
I would like to prevent dos attacks so what I have done is somthing like this:
if (status.numOfCurrentRequests + 1 >= MAX_NUM_OF_CONNECTIONS) {
socket.end();
return;
}
I was wondering if it is better to use :
socket.destroy();
from the API :
socket.destroy() # Ensures that no more I/O activity happens on this socket. Only necessary in case of errors (parse error or so).
what are the differences and benefits?
Typical Counter Measures Deployed to Mitigate These Types of Attacks: Limit the maximum number of open connections from a single IP. Impose a minimum transfer speed. Impose a maximum time a connection can stay open, which means set a timeout for the connection.
A: HTTP, DNS, and TCP/IP requests are common protocols used for DDoS attacks. DDoS attacks can be disruptive, so take a proactive approach and build an Incident Response plan to respond quickly.
For this, it is essential to have multi-level protection strategies that use intrusion prevention and threat management systems. These systems can use anti-spam, content filtering, VPN, firewalls, load balancing, and security layers to spot and block attacks before they overwhelm your network.
A DOS attack really shouldn't be handled by your HTTP server. Once a request has reached it the attacker has 'won' by taking up a connection (no matter how short). Even if they are short they can just slam it with thousands/sec and prevent anyone else from connecting. Also, they might not attempt to 'connect' via TCP and just flood the server with all sorts of requests.
Block/detect DOS attacks at a lower level or via a firewall, which I'm sure many software and hardware versions support some basic types of DOS detection and prevention.
from the API if it helps anyone, should be used smartly :
server.pause(msecs)
Stop accepting connections for the given number of milliseconds (default is one second). This could be useful for throttling new connections against DoS attacks or other oversubscription.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With