Version 18.40.1

This commit is contained in:
Antonio Cañas Vargas 2019-02-13 17:26:19 +01:00
parent 3c4dc97d5b
commit fc137e8f1c
2 changed files with 25 additions and 19 deletions

View File

@ -386,10 +386,11 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf ps2pdf source.ps destination.pdf
*/ */
#define Log_PLATFORM_VERSION "SWAD 18.40 (2019-02-13)" #define Log_PLATFORM_VERSION "SWAD 18.40.1 (2019-02-13)"
#define CSS_FILE "swad18.33.css" #define CSS_FILE "swad18.33.css"
#define JS_FILE "swad18.32.1.js" #define JS_FILE "swad18.32.1.js"
/* /*
Version 18.40.1: Feb 13, 2019 Code refactorization in firewall. (239201 lines)
Version 18.40: Feb 13, 2019 New table for banned IPs to mitigate DoS attacks. (239198 lines) Version 18.40: Feb 13, 2019 New table for banned IPs to mitigate DoS attacks. (239198 lines)
2 changes necessary in database: 2 changes necessary in database:
RENAME TABLE firewall TO firewall_log; RENAME TABLE firewall TO firewall_log;

View File

@ -58,6 +58,8 @@ extern struct Globals Gbl;
static void FW_BanIP (void); static void FW_BanIP (void);
static void FW_WriteHTML (const char *Title,const char *H1);
/*****************************************************************************/ /*****************************************************************************/
/************************** Log access into firewall *************************/ /************************** Log access into firewall *************************/
/*****************************************************************************/ /*****************************************************************************/
@ -108,15 +110,8 @@ void FW_CheckFirewallAndExitIfBanned (void)
{ {
/* Return status 403 Forbidden */ /* Return status 403 Forbidden */
fprintf (stdout,"Content-Type: text/html; charset=windows-1252\n" fprintf (stdout,"Content-Type: text/html; charset=windows-1252\n"
"Status: 403\r\n\r\n" "Status: 403\r\n\r\n");
"<html>" FW_WriteHTML ("Forbidden","You are temporarily banned");
"<head>"
"<title>Forbidden</title>"
"</head>"
"<body>"
"<h1>You are banned temporarily</h1>"
"</body>"
"</html>\n");
/* Close database connection and exit */ /* Close database connection and exit */
DB_CloseDBConnection (); DB_CloseDBConnection ();
@ -152,16 +147,9 @@ void FW_CheckFirewallAndExitIfTooManyRequests (void)
/* Return status 429 Too Many Requests */ /* Return status 429 Too Many Requests */
fprintf (stdout,"Content-Type: text/html; charset=windows-1252\n" fprintf (stdout,"Content-Type: text/html; charset=windows-1252\n"
"Retry-After: %lu\n" "Retry-After: %lu\n"
"Status: 429\r\n\r\n" "Status: 429\r\n\r\n",
"<html>"
"<head>"
"<title>Too Many Requests</title>"
"</head>"
"<body>"
"<h1>Please stop that</h1>"
"</body>"
"</html>\n",
(unsigned long) Fw_TIME_BANNED); (unsigned long) Fw_TIME_BANNED);
FW_WriteHTML ("Too Many Requests","Please stop that");
/* Close database connection and exit */ /* Close database connection and exit */
DB_CloseDBConnection (); DB_CloseDBConnection ();
@ -183,3 +171,20 @@ static void FW_BanIP (void)
" ('%s',NOW(),FROM_UNIXTIME(UNIX_TIMESTAMP()+%lu))", " ('%s',NOW(),FROM_UNIXTIME(UNIX_TIMESTAMP()+%lu))",
Gbl.IP,(unsigned long) Fw_TIME_BANNED); Gbl.IP,(unsigned long) Fw_TIME_BANNED);
} }
/*****************************************************************************/
/********************************* Ban an IP *********************************/
/*****************************************************************************/
static void FW_WriteHTML (const char *Title,const char *H1)
{
fprintf (stdout,"<html>"
"<head>"
"<title>%s</title>"
"</head>"
"<body>"
"<h1>%s</h1>"
"</body>"
"</html>\n",
Title,H1);
}