ESP8266 Webserver Project

Moderator: Sprite_tm

User avatar
By MozisII
#19608 Hello, I succeed compile and test programs without too much effort ! Great and thanks.
I try to take advantage of my bigger flash but system don't boot. I try it touching user_config.h and uncomment #define FLASH_4M (according to my flash) in place of FLASH_512K. While booting program complains about config and stop. Using any FLASH_* (but AUTOFLASH and 512K) crash. AUTOSIZE boot like a 512K flash.
What other operation I have to do to use rest of my flash ?
Thanks
User avatar
By iothing
#20988 Hey there,

Great job Israel Lot , however I ran into the same problem piperpilot and jcferreira had.

My understanding of a captive portal is that the user can enter ANY hostname in the browser and always gets the same content.

In the special case that someone from the wifi that the esp8266 is connected to as a client aka station tries to access the esp8266 website is's not not ok to do a HTTP redirect (301) to the INTERFACE_DOMAIN as the DNS server the client uses will not very likely resolve to the esp8266 ip and thus the client cannot access the esp8266 as piperpilot pointed out.

I solved this by modifying app/dns/dns.c and app/http/cgi.c:

app/dns/dns.c
In the function dnsQueryReceived remove the parsing stuff, just build the response for ANY domain:

Code: Select all@@ -49,7 +49,7 @@
 
 static void ICACHE_FLASH_ATTR dnsQueryReceived(void *arg, char *data, unsigned short length) {
 
-
+/**
 // parse incoming query domain
     char domain[30];
     char *writePos=domain;
@@ -76,7 +76,7 @@
     if(!isKnownDNS(domain))
        return;
 
-
+ **/
 
     struct espconn *conn=arg;
   //build response


app/http/cgi.c:
In the function cgi_check_host we skip the check for matching host and just process the next rule:

Code: Select all@@ -170,7 +170,7 @@
 
                NODE_DBG("Host header found: %s, domain: %s",hostHeader->value,domain);
 
-
+return HTTPD_CGI_NEXT_RULE;
                if(os_strncmp(hostHeader->value,domain,strlen(domain))==0) //compare ignoring http:// and last /
                {
                        NODE_DBG("Hosts match");


Maybe this helps someone.
User avatar
By clinkme
#22112 The first is just a typo I think. The second leads to memory leaks on wifi scan.
Code: Select all279c284
<       cJSON_AddNumberToObject(root,"ap_count",wifi_get_opmode());
---
>             cJSON_AddNumberToObject(root,"ap_count",wifi_status.scan_result.ap_count);
302c307
<          return HTTPD_CGI_DONE;
---
>          return HTTPD_CGI_MORE;