|
@ -249,20 +249,22 @@ class Web { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void onUpdate(AsyncWebServerRequest *request) { |
|
|
void getPage(AsyncWebServerRequest *request, uint8_t mask, const uint8_t *zippedHtml, uint32_t len) { |
|
|
DPRINTLN(DBG_VERBOSE, F("onUpdate")); |
|
|
if (CHECK_MASK(mConfig->sys.protectionMask, mask)) |
|
|
|
|
|
|
|
|
if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_UPDATE)) |
|
|
|
|
|
checkProtection(request); |
|
|
checkProtection(request); |
|
|
|
|
|
|
|
|
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), update_html, update_html_len); |
|
|
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), zippedHtml, len); |
|
|
response->addHeader(F("Content-Encoding"), "gzip"); |
|
|
response->addHeader(F("Content-Encoding"), "gzip"); |
|
|
if(request->hasParam("v")) { |
|
|
response->addHeader(F("content-type"), "text/html; charset=UTF-8"); |
|
|
|
|
|
if(request->hasParam("v")) |
|
|
response->addHeader(F("Cache-Control"), F("max-age=604800")); |
|
|
response->addHeader(F("Cache-Control"), F("max-age=604800")); |
|
|
} |
|
|
|
|
|
request->send(response); |
|
|
request->send(response); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void onUpdate(AsyncWebServerRequest *request) { |
|
|
|
|
|
getPage(request, PROT_MASK_UPDATE, update_html, update_html_len); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void showUpdate(AsyncWebServerRequest *request) { |
|
|
void showUpdate(AsyncWebServerRequest *request) { |
|
|
bool reboot = (!Update.hasError()); |
|
|
bool reboot = (!Update.hasError()); |
|
|
|
|
|
|
|
@ -307,17 +309,7 @@ class Web { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void onIndex(AsyncWebServerRequest *request) { |
|
|
void onIndex(AsyncWebServerRequest *request) { |
|
|
DPRINTLN(DBG_VERBOSE, F("onIndex")); |
|
|
getPage(request, PROT_MASK_INDEX, index_html, index_html_len); |
|
|
|
|
|
|
|
|
if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_INDEX)) |
|
|
|
|
|
checkProtection(request); |
|
|
|
|
|
|
|
|
|
|
|
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), index_html, index_html_len); |
|
|
|
|
|
response->addHeader(F("Content-Encoding"), "gzip"); |
|
|
|
|
|
if(request->hasParam("v")) { |
|
|
|
|
|
response->addHeader(F("Cache-Control"), F("max-age=604800")); |
|
|
|
|
|
} |
|
|
|
|
|
request->send(response); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void onLogin(AsyncWebServerRequest *request) { |
|
|
void onLogin(AsyncWebServerRequest *request) { |
|
@ -378,9 +370,8 @@ class Web { |
|
|
|
|
|
|
|
|
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/javascript"), api_js, api_js_len); |
|
|
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/javascript"), api_js, api_js_len); |
|
|
response->addHeader(F("Content-Encoding"), "gzip"); |
|
|
response->addHeader(F("Content-Encoding"), "gzip"); |
|
|
if(request->hasParam("v")) { |
|
|
if(request->hasParam("v")) |
|
|
response->addHeader(F("Cache-Control"), F("max-age=604800")); |
|
|
response->addHeader(F("Cache-Control"), F("max-age=604800")); |
|
|
} |
|
|
|
|
|
request->send(response); |
|
|
request->send(response); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -439,17 +430,7 @@ class Web { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void onSetup(AsyncWebServerRequest *request) { |
|
|
void onSetup(AsyncWebServerRequest *request) { |
|
|
DPRINTLN(DBG_VERBOSE, F("onSetup")); |
|
|
getPage(request, PROT_MASK_SETUP, setup_html, setup_html_len); |
|
|
|
|
|
|
|
|
if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_SETUP)) |
|
|
|
|
|
checkProtection(request); |
|
|
|
|
|
|
|
|
|
|
|
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), setup_html, setup_html_len); |
|
|
|
|
|
response->addHeader(F("Content-Encoding"), "gzip"); |
|
|
|
|
|
if(request->hasParam("v")) { |
|
|
|
|
|
response->addHeader(F("Cache-Control"), F("max-age=604800")); |
|
|
|
|
|
} |
|
|
|
|
|
request->send(response); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void showSave(AsyncWebServerRequest *request) { |
|
|
void showSave(AsyncWebServerRequest *request) { |
|
@ -616,19 +597,7 @@ class Web { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void onLive(AsyncWebServerRequest *request) { |
|
|
void onLive(AsyncWebServerRequest *request) { |
|
|
DPRINTLN(DBG_VERBOSE, F("onLive")); |
|
|
getPage(request, PROT_MASK_LIVE, visualization_html, visualization_html_len); |
|
|
|
|
|
|
|
|
if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_LIVE)) |
|
|
|
|
|
checkProtection(request); |
|
|
|
|
|
|
|
|
|
|
|
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), visualization_html, visualization_html_len); |
|
|
|
|
|
response->addHeader(F("Content-Encoding"), "gzip"); |
|
|
|
|
|
response->addHeader(F("content-type"), "text/html; charset=UTF-8"); |
|
|
|
|
|
if(request->hasParam("v")) { |
|
|
|
|
|
response->addHeader(F("Cache-Control"), F("max-age=604800")); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
request->send(response); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void onAbout(AsyncWebServerRequest *request) { |
|
|
void onAbout(AsyncWebServerRequest *request) { |
|
@ -649,31 +618,11 @@ class Web { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void onSerial(AsyncWebServerRequest *request) { |
|
|
void onSerial(AsyncWebServerRequest *request) { |
|
|
DPRINTLN(DBG_VERBOSE, F("onSerial")); |
|
|
getPage(request, PROT_MASK_SERIAL, serial_html, serial_html_len); |
|
|
|
|
|
|
|
|
if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_SERIAL)) |
|
|
|
|
|
checkProtection(request); |
|
|
|
|
|
|
|
|
|
|
|
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), serial_html, serial_html_len); |
|
|
|
|
|
response->addHeader(F("Content-Encoding"), "gzip"); |
|
|
|
|
|
if(request->hasParam("v")) { |
|
|
|
|
|
response->addHeader(F("Cache-Control"), F("max-age=604800")); |
|
|
|
|
|
} |
|
|
|
|
|
request->send(response); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void onSystem(AsyncWebServerRequest *request) { |
|
|
void onSystem(AsyncWebServerRequest *request) { |
|
|
DPRINTLN(DBG_VERBOSE, F("onSystem")); |
|
|
getPage(request, PROT_MASK_SYSTEM, system_html, system_html_len); |
|
|
|
|
|
|
|
|
if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_SYSTEM)) |
|
|
|
|
|
checkProtection(request); |
|
|
|
|
|
|
|
|
|
|
|
AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len); |
|
|
|
|
|
response->addHeader(F("Content-Encoding"), "gzip"); |
|
|
|
|
|
if(request->hasParam("v")) { |
|
|
|
|
|
response->addHeader(F("Cache-Control"), F("max-age=604800")); |
|
|
|
|
|
} |
|
|
|
|
|
request->send(response); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|