|
@@ -19,6 +19,7 @@
|
|
|
#include "log.h"
|
|
|
#include "hal.h"
|
|
|
#include "radius_user.h"
|
|
|
+#include "sntp.h"
|
|
|
|
|
|
#ifdef PRINTF_STDLIB
|
|
|
#include <stdio.h>
|
|
@@ -792,16 +793,30 @@ void HTTP_SetSettings(char *buf, uint16_t lenBuf)
|
|
|
SetROTypeActStr(value, 1);
|
|
|
memset(value, 0, len);
|
|
|
|
|
|
-
|
|
|
+ GetParamValue(buf, "utc=", value, &valueLen);
|
|
|
+ SetSntpTimeZoneStr(value);
|
|
|
+ memset(value, 0, len);
|
|
|
+
|
|
|
|
|
|
GetParamValue(buf, "ntp=", value, &valueLen);
|
|
|
|
|
|
if (strncmp(value, "1", 1) == 0)
|
|
|
{
|
|
|
+ bool old_sntp = false;
|
|
|
+ bool enable_old_sntp = sSettings.sSNTP.sntpEnable;
|
|
|
memset(str, 0, len);
|
|
|
GetParamValue(buf, "ntpservip=", str, &valueLen);
|
|
|
- SetSntpServerIpStr(str);
|
|
|
+ if(strncmp(str, sSettings.sSNTP.ip, valueLen))
|
|
|
+ old_sntp = true;
|
|
|
+ SetSntpServerIpStr(str);
|
|
|
SetSntpStateStr(value);
|
|
|
+ if(sSettings.sSNTP.sntpEnable != enable_old_sntp)
|
|
|
+ old_sntp = true;
|
|
|
+ if(old_sntp){
|
|
|
+ SNTP_Init();
|
|
|
+
|
|
|
+ SNTP_Poll();
|
|
|
+ }
|
|
|
memset(value, 0, len);
|
|
|
memset(str, 0, len);
|
|
|
}
|
|
@@ -818,10 +833,6 @@ void HTTP_SetSettings(char *buf, uint16_t lenBuf)
|
|
|
memset(value, 0, len);
|
|
|
memset(str, 0, len);
|
|
|
}
|
|
|
-
|
|
|
- GetParamValue(buf, "utc=", value, &valueLen);
|
|
|
- SetSntpTimeZoneStr(value);
|
|
|
- memset(value, 0, len);
|
|
|
|
|
|
|
|
|
if (GetStateWebReinit() == true)
|
|
@@ -1655,7 +1666,7 @@ static int my_set_session(ssl_context *ssl)
|
|
|
return(0);
|
|
|
}
|
|
|
|
|
|
-void ssl_server_read(void)
|
|
|
+int ssl_server_read(void)
|
|
|
{
|
|
|
int ret;
|
|
|
|
|
@@ -1666,7 +1677,7 @@ void ssl_server_read(void)
|
|
|
|
|
|
|
|
|
ret = ssl_read(&ssl, (unsigned char*)receiveBuf, receivedBufLen);
|
|
|
- printf("receive %s \r\n", receiveBuf);
|
|
|
+
|
|
|
|
|
|
if(ret == POLARSSL_ERR_NET_WANT_READ || ret == POLARSSL_ERR_NET_WANT_WRITE)
|
|
|
continue;
|
|
@@ -1684,14 +1695,15 @@ void ssl_server_read(void)
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
- printf("\n\r ssl_read returned %d\n", ret);
|
|
|
+
|
|
|
break;
|
|
|
}
|
|
|
- break;
|
|
|
+ return ret;
|
|
|
+
|
|
|
}
|
|
|
receivedBufLen = ret;
|
|
|
|
|
|
- printf("\n\r Successfully read %d bytes from client \n\r",receivedBufLen);
|
|
|
+
|
|
|
}while(0);
|
|
|
}
|
|
|
|
|
@@ -1823,8 +1835,8 @@ void ssl_server(void *pvParameters)
|
|
|
|
|
|
|
|
|
|
|
|
- ssl_server_read();
|
|
|
-
|
|
|
+ if(ssl_server_read() <= 0)
|
|
|
+ goto accept;
|
|
|
|
|
|
|
|
|
|
|
@@ -1854,22 +1866,26 @@ void ssl_server(void *pvParameters)
|
|
|
|
|
|
uint8_t user_id;
|
|
|
|
|
|
-
|
|
|
- seclevel = 0xFF;
|
|
|
- for (user_id = 0; user_id < MAX_WEB_USERS; user_id++) {
|
|
|
- HTTP_GetUserCookie(user_id, CookieBuf, &idLen);
|
|
|
- if (strncmp(id, CookieBuf, idLen) == 0 ) {
|
|
|
- GetUserLevelInt(user_id, &seclevel);
|
|
|
- Authenticated = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- Authenticated = false;
|
|
|
- seclevel = 0xFF;
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+ seclevel = 0xFF;
|
|
|
+ for (user_id = 0; user_id < MAX_WEB_USERS; user_id++) {
|
|
|
+ HTTP_GetUserCookie(user_id, CookieBuf, &idLen);
|
|
|
+ if (strncmp(id, CookieBuf, idLen) == 0 ) {
|
|
|
+ GetUserLevelInt(user_id, &seclevel);
|
|
|
+ Authenticated = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ Authenticated = false;
|
|
|
+ seclevel = 0xFF;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
if ( Authenticated == false && sSettings.sRADIUS.Auth_enable == false)
|
|
|
- {
|
|
|
- HTTP_LOGIN(sendBuf, &sendBufLoadLen);
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ HTTP_LOGIN(sendBuf, &sendBufLoadLen);
|
|
|
ssl_sendframes(&ssl, sendBuf, sendBufLoadLen);
|
|
|
}
|
|
|
else if ( Authenticated == false )
|