From 62f26ff5de84bdbdae014ad2ecf3ea606013b8cf Mon Sep 17 00:00:00 2001 From: hanwckf Date: Thu, 31 Aug 2023 01:36:12 +0800 Subject: [PATCH] uboot: redirect "/cgi-bin/luci" to index.html --- uboot-mtk-20220606/failsafe/failsafe.c | 16 ++++++++++++---- uboot-mtk-20220606/failsafe/fsdata/404.html | 4 ++-- uboot-mtk-20220606/failsafe/fsdata/bl2.html | 4 ++-- uboot-mtk-20220606/failsafe/fsdata/fail.html | 4 ++-- uboot-mtk-20220606/failsafe/fsdata/flashing.html | 2 +- uboot-mtk-20220606/failsafe/fsdata/gpt.html | 4 ++-- uboot-mtk-20220606/failsafe/fsdata/index.html | 4 ++-- uboot-mtk-20220606/failsafe/fsdata/uboot.html | 4 ++-- 8 files changed, 25 insertions(+), 17 deletions(-) diff --git a/uboot-mtk-20220606/failsafe/failsafe.c b/uboot-mtk-20220606/failsafe/failsafe.c index 294cb6513..14e504de8 100644 --- a/uboot-mtk-20220606/failsafe/failsafe.c +++ b/uboot-mtk-20220606/failsafe/failsafe.c @@ -144,6 +144,14 @@ static void not_found_handler(enum httpd_uri_handler_status status, } } +static void index_handler(enum httpd_uri_handler_status status, + struct httpd_request *request, + struct httpd_response *response) +{ + if (status == HTTP_CB_NEW) + output_plain_file(response, "index.html"); +} + static void html_handler(enum httpd_uri_handler_status status, struct httpd_request *request, struct httpd_response *response) @@ -151,9 +159,7 @@ static void html_handler(enum httpd_uri_handler_status status, if (status != HTTP_CB_NEW) return; - if (!strcmp(request->urih->uri, "/")) - output_plain_file(response, "index.html"); - else if (output_plain_file(response, request->urih->uri + 1)) + if (output_plain_file(response, request->urih->uri + 1)) not_found_handler(status, request, response); } @@ -436,7 +442,9 @@ int start_web_failsafe(void) return -1; } - httpd_register_uri_handler(inst, "/", &html_handler, NULL); + httpd_register_uri_handler(inst, "/", &index_handler, NULL); + httpd_register_uri_handler(inst, "/cgi-bin/luci", &index_handler, NULL); + httpd_register_uri_handler(inst, "/cgi-bin/luci/", &index_handler, NULL); #ifdef CONFIG_MT7981_BOOTMENU_EMMC httpd_register_uri_handler(inst, "/gpt.html", &html_handler, NULL); #endif diff --git a/uboot-mtk-20220606/failsafe/fsdata/404.html b/uboot-mtk-20220606/failsafe/fsdata/404.html index 99a841d88..f4df44b3e 100755 --- a/uboot-mtk-20220606/failsafe/fsdata/404.html +++ b/uboot-mtk-20220606/failsafe/fsdata/404.html @@ -5,8 +5,8 @@ Page not found - - + +
diff --git a/uboot-mtk-20220606/failsafe/fsdata/bl2.html b/uboot-mtk-20220606/failsafe/fsdata/bl2.html index db43aa265..0eb4c5a81 100755 --- a/uboot-mtk-20220606/failsafe/fsdata/bl2.html +++ b/uboot-mtk-20220606/failsafe/fsdata/bl2.html @@ -3,8 +3,8 @@ U-Boot update - - + +
diff --git a/uboot-mtk-20220606/failsafe/fsdata/fail.html b/uboot-mtk-20220606/failsafe/fsdata/fail.html index 93e804f57..0eacdc219 100755 --- a/uboot-mtk-20220606/failsafe/fsdata/fail.html +++ b/uboot-mtk-20220606/failsafe/fsdata/fail.html @@ -3,8 +3,8 @@ Update failed - - + +
diff --git a/uboot-mtk-20220606/failsafe/fsdata/flashing.html b/uboot-mtk-20220606/failsafe/fsdata/flashing.html index de4321ab6..0d5a7bcf9 100755 --- a/uboot-mtk-20220606/failsafe/fsdata/flashing.html +++ b/uboot-mtk-20220606/failsafe/fsdata/flashing.html @@ -5,7 +5,7 @@ Update in progress - + + +
diff --git a/uboot-mtk-20220606/failsafe/fsdata/index.html b/uboot-mtk-20220606/failsafe/fsdata/index.html index d52280fa0..62e334c31 100755 --- a/uboot-mtk-20220606/failsafe/fsdata/index.html +++ b/uboot-mtk-20220606/failsafe/fsdata/index.html @@ -3,8 +3,8 @@ Firmware update - - + +
diff --git a/uboot-mtk-20220606/failsafe/fsdata/uboot.html b/uboot-mtk-20220606/failsafe/fsdata/uboot.html index 60af28d9e..1e827410d 100755 --- a/uboot-mtk-20220606/failsafe/fsdata/uboot.html +++ b/uboot-mtk-20220606/failsafe/fsdata/uboot.html @@ -3,8 +3,8 @@ U-Boot update - - + +