Chat freely about anything...

User avatar
By treii28
#70084 Has anyone ever succeeded in getting a captive portal to cause a pop-up for the redirected content to a specific landing page? I've tried everything under the sun and while my android will complain about a non-connected internet and other things, it never actually requests/suggests opening a browser as I've seen done on some open-wifi hotspots with sign-in pages.
I'm trying to implement what will actually be a non-internet connected device that users would sign into at a remote location to show they had arrived, kind of like a geocache but using wifi sign in. I did the dnsServer glob (all names to local IP), I've done a number of url redirects. I've tried feeding the specific content (instead of the re-directs) but nothing pops up.

Relevant code:

Code: Select all    #include <ESPAsyncWebServer.h>
    #include <ESP8266WiFi.h>
    #include <DNSServer.h>
    #include <ESP8266mDNS.h>


    IPAddress apIp ( 10, 10, 10, 10 );
    AsyncWebServer asyncWebServer(80);
    DNSServer dnsServer;
    const char* captiveRedirect = "/index.htm";

    dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
    dnsServer.start ( DNS_PORT, "*", apIp );

    DBG_OUTPUT_PORT.println("Initializing MDNS for local hostname on AP");
    if (MDNS.begin(apHostname)) {
        MDNS.addService("http", "tcp", 80);
        DBG_OUTPUT_PORT.println("MDNS responder started");
        DBG_OUTPUT_PORT.print("You can now connect to http://");
        DBG_OUTPUT_PORT.print(apHostname);
        DBG_OUTPUT_PORT.println(".local");
    }

    //Android captive portal. Maybe not needed. Might be handled by notFound handler.
    asyncWebServer.addRewrite( new AsyncWebRewrite("/generate_204", captiveRedirect));
    //asyncWebServer.on ( "/generate_204", returnOK );
    //Microsoft captive portal. Maybe not needed. Might be handled by notFound handler.
    asyncWebServer.addRewrite( new AsyncWebRewrite("/fwlink", captiveRedirect));
    //asyncWebServer.on ( "/fwlink", returnOK );
    //Microsoft windows 10
    //asyncWebServer.on ( "/connecttest.txt", returnOK );
    asyncWebServer.addRewrite( new AsyncWebRewrite("/connecttest.txt", captiveRedirect));
    // apple devices
    asyncWebServer.addRewrite( new AsyncWebRewrite("/hotspot-detect.html", captiveRedirect));
    //asyncWebServer.on ( "/hotspot-detect.html", returnOK );
    asyncWebServer.addRewrite( new AsyncWebRewrite("/library/test/success.html", captiveRedirect));
    //asyncWebServer.on ( "/library/test/success.html", returnOK );
    // kindle
    asyncWebServer.addRewrite( new AsyncWebRewrite("/kindle-wifi/wifistub.html", captiveRedirect));
    //asyncWebServer.on ( "/kindle-wifi/wifistub.html", returnOK );

    asyncWebServer.on("/delete", HTTP_DELETE, handleDelete);
    // upload a file to /upload
    asyncWebServer.on("/upload", HTTP_POST, returnOK, handleUpload);
    // Catch-All Handlers
    asyncWebServer.onFileUpload(handleUpload);
    //asyncWebServer.onRequestBody(onBody);

    asyncWebServer.on("/signin", HTTP_GET, addLog);

    asyncWebServer.onNotFound(handleNotFound);

    asyncWebServer.begin();
User avatar
By treii28
#70096 Digging deep into the bowels of the internet, there was some discussion about other people having problems with this on the mobile-rick-roll github page. One person raised the suspicion that perhaps it is because of the DNS cache in mobile devices.

So let me add to my question if there is anyway to tell a device connecting to wifi to not cache dns info and/or is there any way to set up something similar to the DNS glob but for ip routing on a device that is not connected to the internet? (i.e. answer port 80 for any address?)
User avatar
By eduperez
#70139 Android devices have the Google DNSs hard-coded, they will always use 8.8.8.8 and 8.8.4.4, despite what the DHPC server might tell them to use. You need to configure your gateway to redirect all outgoing traffic to port 53 to your DNS.
User avatar
By treii28
#70240
eduperez wrote:You need to configure your gateway to redirect all outgoing traffic to port 53 to your DNS.


ok, how? My gateway 'is' the esp8266. I'm not connecting these devices to the internet in any way. Plus, I can see (at least my android phone) making the dns request and getting the response. (with a modified DNSServer code from the mobile-rick-roll example) It just doesn't seem to ever show up at the web server.

If I could figure out how to redirect port 53 to the esp8266, I could just as easily redirect port 80 to the esp8266 to get the same desired result. But I can't seem to find any resources anywhere that even begin to suggest how to do such a thing on the esp8266.

I see there's an implementation of lwip in the core files, but can't find any user-friendly documentation for it if you aren't already a tcp/ip hardcore packet-muncher already and can find very little in the way of anyone even using it on the esp8266 -- or at least posting example code to prove it.