|
@@ -118,6 +118,7 @@ static const char Content_Length[17] =
|
|
|
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x4c, 0x65, 0x6e, 0x67,0x74, 0x68, 0x3a, 0x20, };
|
|
|
|
|
|
const char HTTP_304_NOT_MODIFIED[] = "HTTP/1.1 304 Not Modified\r\n\r\n";
|
|
|
+const char HTTP_403_NOT_WHITE_LIST[] = "HTTP/1.1 403 Forbidden\r\n\r\n";
|
|
|
const char HTTP_200_OK[] = "HTTP/1.1 200 OK\r\n\r\n";
|
|
|
/* utf-8 marker to support MS Excel */
|
|
|
const char UTF8_BOM[] = {0xEF, 0xBB, 0xBF, 0x00};
|
|
@@ -139,6 +140,8 @@ uint8_t nameLen = 0, idLen = 0;
|
|
|
uint8_t user_id; // Id of currently logged-in user
|
|
|
struct fs_file file = {0, 0};
|
|
|
|
|
|
+static bool flagWhiteList = false;
|
|
|
+
|
|
|
/**
|
|
|
* @brief closes tcp connection
|
|
|
* @param pcb: pointer to a tcp_pcb struct
|
|
@@ -153,7 +156,35 @@ static void close_conn(struct tcp_pcb *pcb, struct http_state *hs)
|
|
|
mem_free(hs);
|
|
|
tcp_close(pcb);
|
|
|
}
|
|
|
+#ifdef HARDWARE_BT6708
|
|
|
+bool white_list_check(uint32_t check_remote_addr)
|
|
|
+{
|
|
|
+ bool flag = true;
|
|
|
+ uint32_t mask_white_list;
|
|
|
+ uint32_t ip_white_list;
|
|
|
+ char str[20];
|
|
|
+ uint8_t len = 0;
|
|
|
+
|
|
|
+ for(uint8_t i = 0; i < MAX_WHITE_LIST; i ++){
|
|
|
+ memset(str, 0, 20);
|
|
|
+ GetWhiteListSTR(str, &len, i);
|
|
|
+ GetWhiteListMask(&mask_white_list, i);
|
|
|
+ GetWhiteListIP(&ip_white_list, i);
|
|
|
+ if(strlen(str) != 0){
|
|
|
+
|
|
|
+ if((check_remote_addr & mask_white_list) == (ip_white_list & mask_white_list)){
|
|
|
+ flag = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ flag = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ return flag;
|
|
|
+}
|
|
|
+#endif
|
|
|
/**
|
|
|
* @brief callback function for handling TCP HTTP traffic
|
|
|
* @param arg: pointer to an argument structure to be passed to callback function
|
|
@@ -168,7 +199,6 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t er
|
|
|
struct http_state *hs;
|
|
|
struct fs_file file = {0, 0};
|
|
|
char buf[150];
|
|
|
-
|
|
|
hs = arg;
|
|
|
|
|
|
if (err == ERR_OK && p != NULL)
|
|
@@ -177,6 +207,9 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t er
|
|
|
|
|
|
if (hs->file == NULL)
|
|
|
{
|
|
|
+#ifdef HARDWARE_BT6708
|
|
|
+ flagWhiteList = white_list_check(pcb->remote_ip.addr);
|
|
|
+#endif
|
|
|
data = p->payload;
|
|
|
receivedBufLen = p->tot_len;
|
|
|
memcpy(receiveBuf, p->payload , receivedBufLen);
|
|
@@ -1103,7 +1136,22 @@ int HTTP_ConfirmWebPwd(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *l
|
|
|
|
|
|
/* Get first 50 bytes of string */
|
|
|
strncpy(tempStr, bufIn, 49);
|
|
|
-
|
|
|
+#ifdef HARDWARE_BT6708
|
|
|
+ if(!flagWhiteList){
|
|
|
+ if(cnt_err_psw <= 4)
|
|
|
+ cnt_err_psw ++;
|
|
|
+ DBG printf("cnt_err_psw %d", cnt_err_psw);
|
|
|
+ if(cnt_err_psw == 4)
|
|
|
+ xTimerStart(RepeatLoginTimer, 0);
|
|
|
+ strcpy(bufOut, HTTP_403_NOT_WHITE_LIST);
|
|
|
+ if(cnt_err_psw < 4)
|
|
|
+ strcat(bufOut,"<!DOCTYPE html><html><head><meta charset=\"utf-8\"><meta http-equiv=\"refresh\" content=\"3; url=/login.html\" /></head><center><h2>Доступ запрешен! Ваш IP-адрес находится вне диапазона доверительных хостов</h2></center></html>");
|
|
|
+ else
|
|
|
+ strcat(bufOut,"<!DOCTYPE html><html><head><meta charset=\"utf-8\"><meta http-equiv=\"refresh\" content=\"3; url=/login.html\" /></head><center><h2>Вход заблокирован!</h2></center></head><center><h2>Повторите попытку через 1 минуту</h2></center></html>");
|
|
|
+ *lenBufOut = strlen(bufOut);
|
|
|
+ return SEND_REQUIRED_YES;
|
|
|
+ }
|
|
|
+#endif
|
|
|
/* Add " " to the string in order GetParamValue() can be able to parse the param */
|
|
|
strcat(tempStr, " ");
|
|
|
GetParamValue(tempStr, "login=", login, &valueLen);
|
|
@@ -1578,9 +1626,10 @@ char* AuthenticatedFalseRoutine(uint16_t* sendLen)
|
|
|
}
|
|
|
else {
|
|
|
/* Redirect to login page */
|
|
|
- fs_open("/login.html", &file);
|
|
|
+ /* fs_open("/login.html", &file);
|
|
|
*sendLen = file.len;
|
|
|
- return file.data;
|
|
|
+ return file.data;*/
|
|
|
+ return sendBuf;
|
|
|
}
|
|
|
|
|
|
|