mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-28 05:36:37 +00:00
Improved http file access logging
This commit is contained in:
parent
9f11cf15f6
commit
f2f540db7a
@ -215,7 +215,8 @@ void webHandleHaspConfig();
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool httpIsAuthenticated(const __FlashStringHelper* fstr_page)
|
|
||||||
|
bool httpIsAuthenticated()
|
||||||
{
|
{
|
||||||
if(http_config.password[0] != '\0') { // Request HTTP auth if httpPassword is set
|
if(http_config.password[0] != '\0') { // Request HTTP auth if httpPassword is set
|
||||||
if(!webServer.authenticate(http_config.user, http_config.password)) {
|
if(!webServer.authenticate(http_config.user, http_config.password)) {
|
||||||
@ -223,6 +224,12 @@ bool httpIsAuthenticated(const __FlashStringHelper* fstr_page)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool httpIsAuthenticated(const __FlashStringHelper* fstr_page)
|
||||||
|
{
|
||||||
|
if(!httpIsAuthenticated()) return false;
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
||||||
LOG_TRACE(TAG_HTTP, F("Sending %S page to client connected from: %s"), fstr_page,
|
LOG_TRACE(TAG_HTTP, F("Sending %S page to client connected from: %s"), fstr_page,
|
||||||
@ -884,7 +891,8 @@ void webHandleFirmwareUpload()
|
|||||||
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
|
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
|
||||||
bool handleFileRead(String path)
|
bool handleFileRead(String path)
|
||||||
{
|
{
|
||||||
if(!httpIsAuthenticated(F("fileread"))) return false;
|
// if(!httpIsAuthenticated(F("fileread"))) return false;
|
||||||
|
if(!httpIsAuthenticated()) return false;
|
||||||
|
|
||||||
path = webServer.urlDecode(path).substring(0, 31);
|
path = webServer.urlDecode(path).substring(0, 31);
|
||||||
if(path.endsWith("/")) {
|
if(path.endsWith("/")) {
|
||||||
@ -916,9 +924,9 @@ bool handleFileRead(String path)
|
|||||||
webServer.send_P(200, PSTR("text/html"), (const char*)EDIT_HTM_GZ_START, size);
|
webServer.send_P(200, PSTR("text/html"), (const char*)EDIT_HTM_GZ_START, size);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleFileUpload()
|
void handleFileUpload()
|
||||||
@ -1040,7 +1048,7 @@ void handleFileList()
|
|||||||
}
|
}
|
||||||
|
|
||||||
String path = webServer.arg(F("dir"));
|
String path = webServer.arg(F("dir"));
|
||||||
LOG_TRACE(TAG_HTTP, F("handleFileList: %s"), path.c_str());
|
// LOG_TRACE(TAG_HTTP, F("handleFileList: %s"), path.c_str());
|
||||||
path.clear();
|
path.clear();
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
@ -1821,11 +1829,15 @@ void webHandleHaspConfig()
|
|||||||
void httpHandleNotFound()
|
void httpHandleNotFound()
|
||||||
{ // webServer 404
|
{ // webServer 404
|
||||||
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
|
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
|
||||||
if(handleFileRead(webServer.uri())) return;
|
if(handleFileRead(webServer.uri())) {
|
||||||
|
LOG_TRACE(TAG_HTTP, F("Sending %d %s to client connected from: %s"), 200, webServer.uri().c_str(),
|
||||||
|
webServer.client().remoteIP().toString().c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
||||||
LOG_TRACE(TAG_HTTP, F("Sending 404 to client connected from: %s"),
|
LOG_TRACE(TAG_HTTP, F("Sending %d %s to client connected from: %s"), 404, webServer.uri().c_str(),
|
||||||
webServer.client().remoteIP().toString().c_str());
|
webServer.client().remoteIP().toString().c_str());
|
||||||
#else
|
#else
|
||||||
// LOG_TRACE(TAG_HTTP,F("Sending 404 to client connected from: %s"), String(webServer.client().remoteIP()).c_str());
|
// LOG_TRACE(TAG_HTTP,F("Sending 404 to client connected from: %s"), String(webServer.client().remoteIP()).c_str());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user