- Tue Jun 16, 2015 8:19 pm
#20644
I've got this (mostly) working, using the new DNSserver library:
https://github.com/esp8266/Arduino/tree/esp8266-sdk-1.0/hardware/esp8266com/esp8266/libraries/DNSServerBy default, the library only handles requests for a specified URL (e.g., example.com), but you can easily modify DNSServer.cpp to get you most of the way:
Code: Select all// Original
// if (_dnsHeader->QR == DNS_QR_QUERY &&
// _dnsHeader->OPCode == DNS_OPCODE_QUERY &&
// requestIncludesOnlyOneQuestion() &&
// getDomainNameWithoutWwwPrefix() == _domainName)
// Modified to remove domainName check - Works! - but doesnt handle domain subdirs
if (_dnsHeader->QR == DNS_QR_QUERY &&
_dnsHeader->OPCode == DNS_OPCODE_QUERY &&
requestIncludesOnlyOneQuestion())
This will redirect any simple domain name (e.g., example.com, fu.bar, etc), but it doesn't handle a URL with a web page attached (e.g., example.com/examples) - or, rather, it redirects the domain and sends the page request to your server, which chokes on it.
I've asked the DNSServer library author to consider adding a captive portal function, and I'm hoping to have time later this week to play with it more - it seems like it ought to be easy to strip the page request.
Anyone have a suggestion for how to approach the problem?