message: fixes
  Moves dns server out of webportal setup as it is only needed for softap and captive portal, still enabled for portal so cp can be toggled on and off
diff: @@ -564,6 +564,18 @@ boolean WiFiManager::configPortalHasTimeout(){
  return false;
  }
  +void WiFiManager::setupDNSD(){
  + dnsServer.reset(new DNSServer());
  +
  + /* Setup the DNS server redirecting all the domains to the apIP */
  + dnsServer->setErrorReplyCode(DNSReplyCode::NoError);
  + #ifdef WM_DEBUG_LEVEL
  + // DEBUG_WM("dns server started port: ",DNS_PORT);
  + DEBUG_WM(DEBUG_DEV,F("dns server started with ip: "),WiFi.softAPIP()); // @todo not showing ip
  + #endif
  + dnsServer->start(DNS_PORT, F("*"), WiFi.softAPIP());
  +}
  +
  void WiFiManager::setupConfigPortal() {
  #ifdef WM_DEBUG_LEVEL
  @@ -571,7 +583,6 @@ void WiFiManager::setupConfigPortal() {
  #endif
  // setup dns and web servers
  - dnsServer.reset(new DNSServer());
  server.reset(new WM_WebServer(_httpPort));
  if(_httpPort != 80) {
  @@ -580,19 +591,10 @@ void WiFiManager::setupConfigPortal() {
  #endif
  }
  - /* Setup the DNS server redirecting all the domains to the apIP */
  - dnsServer->setErrorReplyCode(DNSReplyCode::NoError);
  - #ifdef WM_DEBUG_LEVEL
  - // DEBUG_WM("dns server started port: ",DNS_PORT);
  - DEBUG_WM(DEBUG_DEV,F("dns server started with ip: "),WiFi.softAPIP()); // @todo not showing ip
  - #endif
  - dnsServer->start(DNS_PORT, F("*"), WiFi.softAPIP());
  -
  - // @todo new callback, webserver started, callback cannot override handlers, but can grab them first
  -
  if ( _webservercallback != NULL) {
  _webservercallback();
  }
  + // @todo add a new callback maybe, after webserver started, callback cannot override handlers, but can grab them first
  /* Setup httpd callbacks, web pages: root, wifi config pages, SO captive portal detectors and not found. */
  @@ -688,6 +690,12 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
  #endif
  setupConfigPortal();
  + #ifdef WM_DEBUG_LEVEL
  + DEBUG_WM(DEBUG_DEV,F("setupDNSD"));
  + #endif
  + setupDNSD();
  +
  +
  if(!_configPortalIsBlocking){
  #ifdef WM_DEBUG_LEVEL
  DEBUG_WM(DEBUG_VERBOSE,F("Config Portal Running, non blocking/processing"));
  @@ -748,8 +756,11 @@ boolean WiFiManager::process(){
  //using esp enums returns for now, should be fine
  uint8_t WiFiManager::processConfigPortal(){
  + if(configPortalActive){
  //DNS handler
  dnsServer->processNextRequest();
  + }
  +
  //HTTP handler
  server->handleClient();
  @@ -826,21 +837,25 @@ uint8_t WiFiManager::processConfigPortal(){
  bool WiFiManager::shutdownConfigPortal(){
  if(webPortalActive) return false;
  + if(configPortalActive){
  //DNS handler
  dnsServer->processNextRequest();
  + }
  +
  //HTTP handler
  server->handleClient();
  // @todo what is the proper way to shutdown and free the server up
  server->stop();
  server.reset();
  - dnsServer->stop(); // free heap ?
  - dnsServer.reset();
  WiFi.scanDelete(); // free wifi scan results
  if(!configPortalActive) return false;
  + dnsServer->stop(); // free heap ?
  + dnsServer.reset();
  +
  // turn off AP
  // @todo bug workaround
  // https://github.com/esp8266/Arduino/issues/3793
  