From 5a8e869a7ee0b7998bd5aa82d279a2717caa7270 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Mon, 18 Sep 2023 18:18:12 -0500 Subject: [PATCH] add workaround for #1543 @etoten thanks, slight change, Might have to add ipv6 detection instead and handle it that way --- WiFiManager.cpp | 10 ++++++++++ WiFiManager.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index b5da15a..8ec7131 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -2416,6 +2416,16 @@ boolean WiFiManager::captivePortal() { if(!_enableCaptivePortal) return false; // skip redirections, @todo maybe allow redirection even when no cp ? might be useful String serverLoc = toStringIp(server->client().localIP()); + + // fallback for ipv6 bug + if(serverloc = 0.0.0.0){ + if ((WiFi.status()) != WL_CONNECTED) + serverLoc = toStringIp(WiFi.softAPIP()); + else + serverLoc = toStringIp(WiFi.localIP()); + } + } + if(_httpPort != 80) serverLoc += ":" + (String)_httpPort; // add port if not default bool doredirect = serverLoc != server->hostHeader(); // redirect if hostheader not server ip, prevent redirect loops diff --git a/WiFiManager.h b/WiFiManager.h index dbb0a74..ce0de12 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -618,6 +618,9 @@ class WiFiManager // but not limited to, we could run continuous background scans on various page hits, or xhr hits // which would be better coupled with asyncscan // atm preload is only done on root hit and startcp + // + // preload scanning causes AP to delay showing for users, but also caches and lets the cp load faster once its open + // my scan takes 7-10 seconds boolean _preloadwifiscan = true; // preload wifiscan if true unsigned int _scancachetime = 30000; // ms cache time for preload scans boolean _asyncScan = true; // perform wifi network scan async