mirror of
https://github.com/pvvx/RTL00_WEB.git
synced 2025-07-31 20:31:05 +00:00
update
This commit is contained in:
parent
fa343db334
commit
2e503268fa
18 changed files with 191 additions and 81 deletions
|
|
@ -31,13 +31,14 @@ LOCAL void fATPN(int argc, char *argv[]){
|
|||
}
|
||||
else {
|
||||
strncpy(wifi_st_cfg.ssid, argv[1], NDIS_802_11_LENGTH_SSID);
|
||||
int pswlen;
|
||||
if(argc > 2) {
|
||||
pswlen = strlen(wifi_st_cfg.password);
|
||||
strncpy(wifi_st_cfg.password, argv[2], NDIS_802_11_LENGTH_SSID);
|
||||
int i = strlen(wifi_st_cfg.password);
|
||||
if(i > 7) {
|
||||
if(pswlen > 7) {
|
||||
wifi_st_cfg.security_type = RTW_SECURITY_WPA2_AES_PSK;
|
||||
}
|
||||
else if(!i) {
|
||||
else if(!pswlen) {
|
||||
wifi_st_cfg.security_type = RTW_SECURITY_OPEN;
|
||||
}
|
||||
else {
|
||||
|
|
@ -46,18 +47,25 @@ LOCAL void fATPN(int argc, char *argv[]){
|
|||
}
|
||||
}
|
||||
else {
|
||||
// default
|
||||
wifi_st_cfg.password[0] = 0;
|
||||
wifi_st_cfg.security_type = RTW_SECURITY_OPEN;
|
||||
}
|
||||
if(argc > 3) {
|
||||
wifi_ap_cfg.security_type = translate_rtw_security(atoi(argv[3]));
|
||||
if(pswlen > 7) {
|
||||
wifi_st_cfg.security_type = translate_val_to_rtw_security(atoi(argv[3]));
|
||||
}
|
||||
else {
|
||||
printf("password len < 8!\n");
|
||||
wifi_st_cfg.security_type = RTW_SECURITY_OPEN;
|
||||
}
|
||||
}
|
||||
if(argc > 4) {
|
||||
wifi_st_cfg.autoreconnect = atoi(argv[3]);
|
||||
wifi_st_cfg.autoreconnect = atoi(argv[4]);
|
||||
}
|
||||
else wifi_st_cfg.autoreconnect = 0;
|
||||
if(argc > 5) {
|
||||
wifi_st_cfg.reconnect_pause = atoi(argv[3]);
|
||||
wifi_st_cfg.reconnect_pause = atoi(argv[5]);
|
||||
}
|
||||
else wifi_st_cfg.reconnect_pause = 5;
|
||||
show_wifi_st_cfg();
|
||||
|
|
@ -93,8 +101,7 @@ LOCAL void fATPA(int argc, char *argv[]){
|
|||
wifi_ap_cfg.security_type = RTW_SECURITY_OPEN;
|
||||
}
|
||||
if(argc > 3) {
|
||||
if(argv[3][0]=='0') wifi_st_cfg.security_type = RTW_SECURITY_OPEN;
|
||||
else wifi_st_cfg.security_type = RTW_SECURITY_WEP_PSK;
|
||||
wifi_ap_cfg.security_type = (argv[3][0] == '0')? RTW_SECURITY_OPEN : RTW_SECURITY_WPA2_AES_PSK;
|
||||
}
|
||||
if(argc > 4) {
|
||||
wifi_ap_cfg.channel = atoi(argv[4]);
|
||||
|
|
|
|||
|
|
@ -11,12 +11,20 @@
|
|||
#include "task.h"
|
||||
#include "diag.h"
|
||||
#include "netbios/netbios.h"
|
||||
#include "sntp/sntp.h"
|
||||
#include "user/sys_cfg.h"
|
||||
#include "web/web_srv.h"
|
||||
#include "webfs/webfs.h"
|
||||
|
||||
struct SystemCfg syscfg = {
|
||||
.cfg.w = SYS_CFG_DEBUG_ENA | SYS_CFG_NETBIOS_ENA,
|
||||
.cfg.w = SYS_CFG_DEBUG_ENA
|
||||
#if defined(USE_NETBIOS) && USE_NETBIOS
|
||||
| SYS_CFG_NETBIOS_ENA
|
||||
#endif
|
||||
#if defined(USE_SNTP) && USE_SNTP
|
||||
| SYS_CFG_SNTP_ENA
|
||||
#endif
|
||||
,
|
||||
#if defined(USE_WEB)
|
||||
.web_port = USE_WEB,
|
||||
#else
|
||||
|
|
@ -63,9 +71,12 @@ void user_init_thrd(void) {
|
|||
|
||||
/* Load cfg, init WiFi + LwIP init, WiFi start if wifi_cfg.mode != RTW_MODE_NONE */
|
||||
wifi_init();
|
||||
|
||||
#if defined(USE_NETBIOS)
|
||||
if(syscfg.cfg.b.netbios_ena) netbios_init();
|
||||
|
||||
#endif
|
||||
#if defined(USE_SNTP)
|
||||
if(syscfg.cfg.b.sntp_ena) sntp_init();
|
||||
#endif
|
||||
// webstuff_init(); // httpd_init();
|
||||
webserver_init(syscfg.web_port);
|
||||
|
||||
|
|
|
|||
48
project/src/web/web_auth.c
Normal file
48
project/src/web/web_auth.c
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* web_auth.c
|
||||
*
|
||||
* Created on: 23/04/2017.
|
||||
* Author: pvvx
|
||||
*/
|
||||
#include "autoconf.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "diag.h"
|
||||
#include "web_utils.h"
|
||||
#include "wifi_api.h"
|
||||
#include "web_srv.h"
|
||||
#include "rtl8195a/rtl_libc.h"
|
||||
#include "esp_comp.h"
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------------------
|
||||
* pbuf[77] = Username and password are combined into a string "username:password"
|
||||
* Return: Authorization Level
|
||||
* 0 - Not Authorized */
|
||||
|
||||
uint8 UserAuthorization(uint8 *pbuf, size_t declen)
|
||||
{
|
||||
uint8 * psw = rtl_strchr(pbuf, ':');
|
||||
if(psw != NULL) {
|
||||
#if USE_WEB_AUTH_LEVEL
|
||||
if(rtl_strcmp(pbuf, "rtl871x:webfs_write") == 0) {
|
||||
return WEB_AUTH_LEVEL_WEBFS;
|
||||
}
|
||||
if(rtl_strcmp(pbuf, "rtl871x:ota_write") == 0) {
|
||||
return WEB_AUTH_LEVEL_OTA;
|
||||
}
|
||||
if(rtl_strcmp(pbuf, "rtl871x:supervisor") == 0) {
|
||||
return WEB_AUTH_LEVEL_SUPERVISOR;
|
||||
}
|
||||
#endif
|
||||
*psw++ = 0;
|
||||
if(rom_xstrcmp(wifi_ap_cfg.ssid, pbuf)
|
||||
&& rom_xstrcmp( wifi_ap_cfg.password, psw)) {
|
||||
return WEB_AUTH_LEVEL_USER;
|
||||
}
|
||||
if(rom_xstrcmp(wifi_st_cfg.ssid, pbuf)
|
||||
&& rom_xstrcmp( wifi_st_cfg.password, psw)) {
|
||||
return WEB_AUTH_LEVEL_USER1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -24,11 +24,11 @@
|
|||
#include "esp_comp.h"
|
||||
|
||||
#ifdef USE_NETBIOS
|
||||
#include "netbios.h"
|
||||
#include "netbios/netbios.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_SNTP
|
||||
#include "sntp.h"
|
||||
#include "sntp/sntp.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_CAPTDNS
|
||||
|
|
@ -534,13 +534,13 @@ void ICACHE_FLASH_ATTR web_int_callback(TCP_SERV_CONN *ts_conn, uint8 *cstr)
|
|||
else ifcmp("auth") tcp_put((wifi_ap_cfg.security_type == RTW_SECURITY_OPEN) ? '0' : '1');
|
||||
else ifcmp("hssid") tcp_put((wifi_ap_cfg.ssid_hidden & 1) + '0');
|
||||
else ifcmp("bint") tcp_puts("%u", wifi_ap_cfg.beacon_interval);
|
||||
else ifcmp("mac") tcp_puts(MACSTR, MAC2STR(xnetif[wlan_ap_netifn].hwaddr));
|
||||
else ifcmp("hostname") tcp_strcpy(lwip_host_name[wlan_ap_netifn]);
|
||||
else ifcmp("mac") tcp_puts(MACSTR, MAC2STR(xnetif[WLAN_AP_NETIF_NUM].hwaddr));
|
||||
else ifcmp("hostname") tcp_strcpy(lwip_host_name[WLAN_AP_NETIF_NUM]);
|
||||
else ifcmp("dhcp") tcp_puts("%u", wifi_ap_dhcp.mode);
|
||||
else ifcmp("ip") tcp_puts(IPSTR, IP2STR(&wifi_ap_dhcp.ip));
|
||||
else ifcmp("gw") tcp_puts(IPSTR, IP2STR(&wifi_ap_dhcp.gw));
|
||||
else ifcmp("msk") tcp_puts(IPSTR, IP2STR(&wifi_ap_dhcp.mask));
|
||||
else ifcmp("cip") tcp_puts(IPSTR, IP2STR(&xnetif[wlan_st_netifn].ip_addr.addr));
|
||||
else ifcmp("cip") tcp_puts(IPSTR, IP2STR(&xnetif[WLAN_ST_NETIF_NUM].ip_addr.addr));
|
||||
|
||||
// else ifcmp("mac") strtomac(pvar, wifi_ap_cfg.macaddr);
|
||||
// else ifcmp("sip") tcp_puts(IPSTR, IP2STR(&wifi_ap_dhcp.start_ip));
|
||||
|
|
@ -574,13 +574,13 @@ void ICACHE_FLASH_ATTR web_int_callback(TCP_SERV_CONN *ts_conn, uint8 *cstr)
|
|||
os_memcpy((char *)&web_conn->msgbuf[web_conn->msgbuflen], wifi_st_cfg.password, len);
|
||||
web_conn->msgbuflen += len;
|
||||
}
|
||||
else ifcmp("mac") tcp_puts(MACSTR, MAC2STR(xnetif[wlan_st_netifn].hwaddr));
|
||||
else ifcmp("mac") tcp_puts(MACSTR, MAC2STR(xnetif[WLAN_ST_NETIF_NUM].hwaddr));
|
||||
else ifcmp("bssid") tcp_puts(MACSTR, MAC2STR(wifi_st_cfg.bssid));
|
||||
else ifcmp("sbss") tcp_puts("%u", wifi_st_cfg.flg);
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
else ifcmp("hostname") tcp_strcpy(lwip_host_name[wlan_st_netifn]);
|
||||
else ifcmp("hostname") tcp_strcpy(lwip_host_name[WLAN_ST_NETIF_NUM]);
|
||||
#endif
|
||||
else ifcmp("auth") tcp_puts("%u", wifi_st_cfg.security_type);
|
||||
else ifcmp("auth") tcp_puts("%u", translate_rtw_security_to_val(wifi_st_cfg.security_type));
|
||||
else ifcmp("dhcp") tcp_puts("%u", wifi_st_dhcp.mode);
|
||||
else ifcmp("ip") tcp_puts(IPSTR, IP2STR(&wifi_st_dhcp.ip));
|
||||
else ifcmp("gw") tcp_puts(IPSTR, IP2STR(&wifi_st_dhcp.gw));
|
||||
|
|
@ -673,7 +673,7 @@ void ICACHE_FLASH_ATTR web_int_callback(TCP_SERV_CONN *ts_conn, uint8 *cstr)
|
|||
#ifdef USE_SNTP
|
||||
else ifcmp("sntp_") {
|
||||
cstr += 5;
|
||||
ifcmp("time") tcp_puts("%u", get_sntp_time());
|
||||
ifcmp("time") tcp_puts("%u", sntp_gen_system_time(0)); // get_sntp_time
|
||||
else tcp_put('?');
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@
|
|||
#include "esp_comp.h"
|
||||
|
||||
#ifdef USE_NETBIOS
|
||||
#include "netbios.h"
|
||||
#include "netbios/netbios.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_SNTP
|
||||
#include "sntp.h"
|
||||
#include "sntp/sntp.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_LWIP_PING
|
||||
|
|
@ -133,7 +133,7 @@ void ICACHE_FLASH_ATTR web_int_vars(TCP_SERV_CONN *ts_conn, uint8 *pcmd, uint8 *
|
|||
else os_printf(" - none!\n");
|
||||
#endif
|
||||
}
|
||||
else ifcmp("pinclr") syscfg.cfg.b.pin_clear_cfg_enable = (val)? 1 : 0;
|
||||
else ifcmp("pinclr") syscfg.cfg.b.pin_clear_cfg_enable = (val)? 1 : 0;
|
||||
else ifcmp("debug") {
|
||||
syscfg.cfg.b.debug_print_enable = val;
|
||||
print_off = (!val) & 1; // rtl_print on/off
|
||||
|
|
@ -152,8 +152,8 @@ void ICACHE_FLASH_ATTR web_int_vars(TCP_SERV_CONN *ts_conn, uint8 *pcmd, uint8 *
|
|||
#ifdef USE_SNTP
|
||||
else ifcmp("sntp") {
|
||||
syscfg.cfg.b.sntp_ena = (val)? 1 : 0;
|
||||
if(syscfg.cfg.b.sntp_ena) sntp_inits();
|
||||
else sntp_close();
|
||||
if(syscfg.cfg.b.sntp_ena) sntp_init();
|
||||
else sntp_stop();
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_CAPTDNS
|
||||
|
|
@ -198,7 +198,7 @@ void ICACHE_FLASH_ATTR web_int_vars(TCP_SERV_CONN *ts_conn, uint8 *pcmd, uint8 *
|
|||
else os_memset(wifi_ap_cfg.ssid, 0, sizeof(wifi_ap_cfg.ssid));
|
||||
os_memcpy(wifi_ap_cfg.ssid, pvar, len);
|
||||
#ifdef USE_NETBIOS
|
||||
netbios_set_name(wifi_ap_cfg.ssid);
|
||||
// netbios_set_name(wlan_ap_netifn, wifi_ap_cfg.ssid);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
@ -212,7 +212,7 @@ void ICACHE_FLASH_ATTR web_int_vars(TCP_SERV_CONN *ts_conn, uint8 *pcmd, uint8 *
|
|||
}
|
||||
else ifcmp("chl") wifi_ap_cfg.channel = val;
|
||||
else ifcmp("mcns") wifi_ap_cfg.max_sta = val;
|
||||
else ifcmp("auth") wifi_ap_cfg.security_type = (val)? RTW_SECURITY_WEP_PSK : RTW_SECURITY_OPEN;
|
||||
else ifcmp("auth") wifi_ap_cfg.security_type = (val != 0);
|
||||
else ifcmp("hssid") wifi_ap_cfg.ssid_hidden = val;
|
||||
else ifcmp("bint") wifi_ap_cfg.beacon_interval = val;
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
|
|
@ -259,7 +259,7 @@ void ICACHE_FLASH_ATTR web_int_vars(TCP_SERV_CONN *ts_conn, uint8 *pcmd, uint8 *
|
|||
else os_memset(wifi_st_cfg.password, 0, sizeof(wifi_st_cfg.password));
|
||||
os_memcpy(wifi_st_cfg.password, pvar, len);
|
||||
}
|
||||
else ifcmp("auth") wifi_st_cfg.security_type = val;
|
||||
else ifcmp("auth") wifi_st_cfg.security_type = translate_val_to_rtw_security(val);
|
||||
else ifcmp("bssid") strtomac(pvar, wifi_st_cfg.bssid);
|
||||
else ifcmp("sbss") wifi_st_cfg.flg = val;
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ const char HTTPresponse_200_head[] ICACHE_RODATA_ATTR = "OK";
|
|||
const char HTTPresponse_302_head[] ICACHE_RODATA_ATTR = "Found";
|
||||
const char HTTPresponse_304_head[] ICACHE_RODATA_ATTR = "Not Modified";
|
||||
const char HTTPresponse_400_head[] ICACHE_RODATA_ATTR = "Bad Request";
|
||||
const char HTTPresponse_401_head[] ICACHE_RODATA_ATTR = "Unauthorized\r\nWWW-Authenticate: Basic realm=\"Protected\"";
|
||||
const char HTTPresponse_401_head[] ICACHE_RODATA_ATTR = "Unauthorized\r\nWWW-Authenticate: Basic realm=\"Protected%u\"";
|
||||
const char HTTPresponse_404_head[] ICACHE_RODATA_ATTR = "Not found";
|
||||
const char HTTPresponse_411_head[] ICACHE_RODATA_ATTR = "Length Required";
|
||||
const char HTTPresponse_413_head[] ICACHE_RODATA_ATTR = "Request Entity Too Large";
|
||||
|
|
@ -304,7 +304,7 @@ LOCAL WEB_SRV_CONN * ICACHE_FLASH_ATTR ReNew_web_conn(TCP_SERV_CONN *ts_conn)
|
|||
// /ssl/crypto/ssl_crypto_misc.c:
|
||||
// EXP_FUNC int STDCALL base64_decode(const uint8 *in, int len, uint8_t *out, int *outlen);
|
||||
// Username and password are combined into a string "username:password"
|
||||
LOCAL bool ICACHE_FLASH_ATTR CheckAuthorization(uint8* base64str)
|
||||
LOCAL uint8 ICACHE_FLASH_ATTR CheckAuthorization(uint8* base64str)
|
||||
{
|
||||
uint8 *pcmp = base64str;
|
||||
int len = 0;
|
||||
|
|
@ -315,23 +315,41 @@ LOCAL bool ICACHE_FLASH_ATTR CheckAuthorization(uint8* base64str)
|
|||
if((len >= 4)&&(len <= 128)
|
||||
&&(base64decode(base64str, len, pbuf, &declen))) {
|
||||
pbuf[declen]='\0';
|
||||
uint8 ppsw[32+64+1];
|
||||
cmpcpystr(ppsw, wifi_ap_cfg.ssid, '\0','\0', 32);
|
||||
len = rtl_strlen((char*)ppsw);
|
||||
ppsw[len++] = ':';
|
||||
cmpcpystr(&ppsw[len], wifi_ap_cfg.password, '\0','\0', 64);
|
||||
#if DEBUGSOO > 1
|
||||
os_printf("'%s' ", pbuf);
|
||||
#endif
|
||||
#if DEBUGSOO > 2
|
||||
os_printf("<%s>[%u] ", ppsw, declen);
|
||||
#endif
|
||||
if(os_strncmp(pbuf, (char *)ppsw , declen) == 0) return true;
|
||||
return UserAuthorization(pbuf, declen);
|
||||
};
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
//=============================================================================
|
||||
|
||||
#define web_parse_cookie(CurHTTP, ts_conn) web_parse_vars(ts_conn, (CurHTTP)->pcookie, (CurHTTP)->cookie_len, '\0', ';')
|
||||
#define web_parse_uri_vars(CurHTTP, ts_conn) web_parse_vars(ts_conn, (CurHTTP)->puri, (CurHTTP)->uri_len, '?', '&')
|
||||
#define web_parse_content(CurHTTP, ts_conn) web_parse_vars(ts_conn, (CurHTTP)->pcontent, (CurHTTP)->content_len, '\0', '&')
|
||||
LOCAL void ICACHE_FLASH_ATTR web_parse_vars(TCP_SERV_CONN *ts_conn, uint8 *vars, uint32 vars_len, uint8 start_char, uint8 end_char)
|
||||
{
|
||||
if(vars == NULL || vars_len == 0) return;
|
||||
uint8 *pcmp;
|
||||
if(start_char) {
|
||||
pcmp = cmpcpystr(NULL, vars, '\0', start_char, vars_len); // find start_char if available
|
||||
start_char = '\0';
|
||||
} else pcmp = vars - 1;
|
||||
while(pcmp != NULL) {
|
||||
uint16 len = vars_len - (pcmp - vars);
|
||||
uint8 *pcmd = pcmp;
|
||||
pcmp = cmpcpystr(pcmp, pcmp + 1, start_char, '=', len); // skip spaces before variable name
|
||||
if(pcmp == NULL) break;
|
||||
urldecode(pcmd, pcmd, len, len);
|
||||
len = vars_len - (pcmp - vars);
|
||||
uint8 *pvar = pcmp;
|
||||
pcmp = cmpcpystr(pcmp, pcmp + 1, '\0', end_char, len);
|
||||
if(pcmd[0] != '\0') {
|
||||
urldecode(pvar, pvar, len, len);
|
||||
web_int_vars(ts_conn, pcmd, pvar);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
//=============================================================================
|
||||
LOCAL void ICACHE_FLASH_ATTR
|
||||
web_parse_cookie(HTTP_CONN *CurHTTP, TCP_SERV_CONN *ts_conn)
|
||||
|
|
@ -394,6 +412,7 @@ web_parse_content(HTTP_CONN *CurHTTP, TCP_SERV_CONN *ts_conn)
|
|||
}
|
||||
} while(pcmp != NULL);
|
||||
}
|
||||
*/
|
||||
//=============================================================================
|
||||
// Разбор имени файла и перевод в вид относительного URI.
|
||||
// (выкидывание HTTP://Host)
|
||||
|
|
@ -411,7 +430,7 @@ web_parse_fname(HTTP_CONN *CurHTTP, TCP_SERV_CONN *ts_conn)
|
|||
uint8 cbuf[FileNameSize+16];
|
||||
uint8 *pcbuf = cbuf;
|
||||
urldecode(pcbuf, CurHTTP->puri, sizeof(cbuf) - 1, CurHTTP->uri_len);
|
||||
if((os_strncmp((char *)pcbuf, "HTTP://", 7) == 0)||(os_strncmp((char *)pcbuf, "http://", 7) == 0)) {
|
||||
if(rom_xstrcmp((char *)pcbuf, "HTTP://")||(rom_xstrcmp((char *)pcbuf, "http://"))) {
|
||||
pcbuf += 7;
|
||||
uint8 *pcmp = os_strchr((char *)pcbuf, '/');
|
||||
if(pcmp != NULL) pcbuf = pcmp;
|
||||
|
|
@ -422,6 +441,9 @@ web_parse_fname(HTTP_CONN *CurHTTP, TCP_SERV_CONN *ts_conn)
|
|||
uint8 *pcmp = web_strnstr(CurHTTP->pFilename, ProtectedFilesName, os_strlen(CurHTTP->pFilename));
|
||||
if(pcmp != NULL) {
|
||||
WEB_SRV_CONN *web_conn = (WEB_SRV_CONN *)ts_conn->linkd;
|
||||
#if USE_WEB_AUTH_LEVEL
|
||||
web_conn->auth_realm = WEB_AUTH_LEVEL_USER;
|
||||
#endif
|
||||
SetSCB(SCB_AUTH);
|
||||
}
|
||||
};
|
||||
|
|
@ -598,7 +620,17 @@ parse_header(HTTP_CONN *CurHTTP, TCP_SERV_CONN *ts_conn)
|
|||
if(os_strncmp(pstr, "Basic", 5) == 0) { // The authorization method and a space i.e. "Basic" is then put before the encoded string.
|
||||
pstr += 5;
|
||||
while(*pstr == ' ') pstr++;
|
||||
if(CheckAuthorization(pstr)) ClrSCB(SCB_AUTH);
|
||||
#if USE_WEB_AUTH_LEVEL
|
||||
web_conn->auth_level = CheckAuthorization(pstr);
|
||||
#if DEBUGSOO > 1
|
||||
os_printf("%u?%u ", web_conn->auth_level, web_conn->auth_realm);
|
||||
#endif
|
||||
if(web_conn->auth_level >= web_conn->auth_realm)
|
||||
ClrSCB(SCB_AUTH);
|
||||
#else
|
||||
if(CheckAuthorization(pstr))
|
||||
ClrSCB(SCB_AUTH);
|
||||
#endif
|
||||
else {
|
||||
CurHTTP->httpStatus = 401; // 401 Unauthorized
|
||||
return false;
|
||||
|
|
@ -821,6 +853,9 @@ LOCAL bool ICACHE_FLASH_ATTR webserver_open_file(HTTP_CONN *CurHTTP, TCP_SERV_CO
|
|||
return true;
|
||||
}
|
||||
else if(rom_xstrcmp(pstr, fsupload_fname)) {
|
||||
#if USE_WEB_AUTH_LEVEL
|
||||
web_conn->auth_realm = WEB_AUTH_LEVEL_WEBFS;
|
||||
#endif
|
||||
SetSCB(SCB_AUTH);
|
||||
web_inc_fp(web_conn, WEBFS_UPLOAD_HANDLE);
|
||||
web_conn->content_len = sizeHTTPfsupload;
|
||||
|
|
@ -1075,7 +1110,8 @@ web_print_headers(HTTP_CONN *CurHTTP, TCP_SERV_CONN *ts_conn)
|
|||
CurResp++;
|
||||
};
|
||||
tcp_puts_fd("HTTP/1.1 %u ", CurResp->status);
|
||||
tcp_strcpy(CurResp->headers);
|
||||
if(CurResp->status == 401) tcp_puts_fd(CurResp->headers, web_conn->auth_realm);
|
||||
else tcp_strcpy(CurResp->headers);
|
||||
tcp_strcpy_fd("\r\nServer: " WEB_NAME_VERSION "\r\nConnection: close\r\n");
|
||||
if(CheckSCB(SCB_REDIR)) {
|
||||
tcp_puts_fd("Location: %s\r\n\r\n", CurHTTP->pFilename);
|
||||
|
|
@ -1990,7 +2026,7 @@ err_t ICACHE_FLASH_ATTR webserver_init(uint16 portn)
|
|||
if (p != NULL) {
|
||||
// изменим конфиг на наше усмотрение:
|
||||
if(syscfg.cfg.b.web_time_wait_delete) p->flag.pcb_time_wait_free = 1; // пусть убивает, для теста и проксей
|
||||
p->max_conn = 256; // сработает по heap_size
|
||||
p->max_conn = 99; // сработает по heap_size
|
||||
#if DEBUGSOO > 3
|
||||
os_printf("Max connection %d, time waits %d & %d, min heap size %d\n",
|
||||
p->max_conn, p->time_wait_rec, p->time_wait_cls, p->min_heap);
|
||||
|
|
|
|||
|
|
@ -46,10 +46,7 @@ int ICACHE_RAM_ATTR rom_xstrcpy(char * pd, const char * ps)
|
|||
}
|
||||
#else
|
||||
int len = 0;
|
||||
while(*ps) {
|
||||
*pd++ = *ps++;
|
||||
len++;
|
||||
}
|
||||
while((*pd++ = *ps++) != 0) len++;
|
||||
return len;
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue