Skip to content

Commit

Permalink
update serverloc
Browse files Browse the repository at this point in the history
  • Loading branch information
tablatronix committed Nov 17, 2023
1 parent 0e20168 commit 18145e4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions WiFiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2421,16 +2421,18 @@ void WiFiManager::handleNotFound() {
* Return true in that case so the page handler do not try to handle the request again.
*/
boolean WiFiManager::captivePortal() {
#ifdef WM_DEBUG_LEVEL
DEBUG_WM(WM_DEBUG_MAX,"-> " + server->hostHeader());
#endif

if(!_enableCaptivePortal) return false; // skip redirections, @todo maybe allow redirection even when no cp ? might be useful

String serverLoc = toStringIp(server->client().localIP());

#ifdef WM_DEBUG_LEVEL
DEBUG_WM(WM_DEBUG_DEV,"-> " + server->hostHeader());
DEBUG_WM(WM_DEBUG_DEV,"serverLoc " + serverLoc);
#endif

// fallback for ipv6 bug
if(serverLoc = "0.0.0.0"){
if(serverLoc == "0.0.0.0"){
if ((WiFi.status()) != WL_CONNECTED)
serverLoc = toStringIp(WiFi.softAPIP());
else
Expand All @@ -2443,6 +2445,7 @@ boolean WiFiManager::captivePortal() {
if (doredirect) {
#ifdef WM_DEBUG_LEVEL
DEBUG_WM(WM_DEBUG_VERBOSE,F("<- Request redirected to captive portal"));
DEBUG_WM(WM_DEBUG_DEV,"serverLoc " + serverLoc);
#endif
server->sendHeader(F("Location"), (String)F("http://") + serverLoc, true); // @HTTPHEAD send redirect
server->send ( 302, FPSTR(HTTP_HEAD_CT2), ""); // Empty content inhibits Content-length header so we have to close the socket ourselves.
Expand Down

0 comments on commit 18145e4

Please sign in to comment.