defender
get_real_ip
¶
Retrieves the real IP address from the request object.
Parameters
Name | Type | Description |
---|---|---|
request |
any | The request object containing the headers and socket information. |
Returns: The real IP address as a string.
blacklist_ip
¶
Add an IP address to blacklist
Parameters:
- ip_addr - The IP to blacklist
- duration - Time in millis of the blacklist
Returns: ``
blacklist_ip_list
¶
Retrieves a list of blacklisted IP addresses along with their corresponding dates.
Returns: An array of objects containing the IP address and date of each blacklisted IP.
applySettings
¶
Changes Defender's settings
Returns: ``
const Defender
¶
Middleware function that acts as a defender against suspicious requests. It checks for blacklisted IP addresses and suspicious URL fragments. If an IP address is blacklisted, it returns a 403 response. If a suspicious URL fragment is found, it handles the request accordingly.
Parameters
Name | Type | Description |
---|---|---|
request |
any | The incoming request object. |
response |
any | The outgoing response object. |
next |
any | The next middleware function in the chain. |
Returns: ``
add_suspicious_activity
¶
add a new suspicious activity to the log
if it returns true
, it means that ip reached threshold
Returns: ``