- Fri Jun 19, 2015 7:00 pm
#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.cIn 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.