Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By blackie
#21705 Setting the reply code to NoError didn't help me much.

I think the DNS response needs a question and answer section.

I moddified / added
Code: Select all _dnsHeader->QDCount = _dnsHeader->QDCount;     //was = 0
_dnsHeader->RA = 1;                                                                  //added

at the begining of DNSServer::replyWithIP() .

RA=1 sets the recursion available bit in the header. QDCount sets the count of questions in the header.



current dig
Code: Select allC:\tmp\BIND9.10.2-P1.x64>dig test.com
;; Warning: Message parser reports malformed message packet.

; <<>> DiG 9.10.2-P1 <<>> test.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52866
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: Message has 3 extra bytes at end

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;test.com.                      IN      A

;; Query time: 193 msec
;; SERVER: 192.168.4.1#53(192.168.4.1)
;; WHEN: Fri Jun 26 06:58:12 Eastern Daylight Time 2015
;; MSG SIZE  rcvd: 51


DNS packet overview
http://www.ccs.neu.edu/home/amislove/te ... primer.pdf
Last edited by blackie on Fri Jun 26, 2015 6:24 am, edited 3 times in total.
User avatar
By SwiCago
#21708 Blackie, you may be on to something! I don't see where in the code of DNSServer.CCP or DNSServer.h the original question is returned. According to DNS spec, when query is made...the question must be returned along with the answer. I see the answer, but I don't see the question being returned. The question is the requested domain...so if I ask for www.test.com, then www.test.com must be returned along with the IP
Burkmurry would you double check the DNSServer package and see of it is in fact there or not?!?
User avatar
By blackie
#21726 i think the question is in the buffer, so it would be a part of the response.

_udp.write(_buffer, _currentPacketSize);

Edit:
I have it working on Windows.

Code: Select allvoid DNSServer::replyWithIP()
{
  _dnsHeader->QR = DNS_QR_RESPONSE;
  _dnsHeader->ANCount = _dnsHeader->QDCount;
//  _dnsHeader->QDCount = 0;
  _dnsHeader->RA = 1;                                      //added

  _udp.beginPacket(_udp.remoteIP(), _udp.remotePort());
  _udp.write(_buffer, _currentPacketSize);

  _udp.write((uint8_t)192);     //  answer name is a pointer
   _udp.write((uint8_t)12);      // pointer to offset at 0x00c


      _udp.write((uint8_t)0);   // 0x0001  answer is type A query (host address)
  _udp.write((uint8_t)1);

    _udp.write((uint8_t)0);   //0x0001 answer is class IN (internet address)
  _udp.write((uint8_t)1);
 
  _udp.write((unsigned char*)&_ttl, 4);

    // Length of RData is 4 bytes (because, in this case, RData is IPv4)
 _udp.write((uint8_t)0);
  _udp.write((uint8_t)4);
  _udp.write(_resolvedIP, sizeof(_resolvedIP));
  _udp.endPacket();
}
User avatar
By burkmurray
#21874 @ AndyReischle - I watched your video and saw the Android connection. Can you tell us what you had to change to make it work?

Also, a couple of things you may want to try:

Inserting
Code: Select all<meta name='viewport' content='initial-scale=1'>

into the <head> of your html pages forces mobile screens to display at a 1:1 ratio, rather than minimized, so you won't have to "unpinch" to see your page. I've tested this on iPhones and iPads, but not Android. It makes a huge difference in usability.

Also, sending
Code: Select all<HTML><HEAD><TITLE>Success</TITLE></HEAD><BODY>Success</BODY></HTML>

will let IOS skip through its captive portal.
I use a a simple boolean token to figure out whether the user has already been sent the SUCCESS header, then pass through if true:
Code: Select allvoid handleNotFound() {
  if (!auth) {
    auth = 1;
// Auto launch browser? <a href="http://www.domain.com/" target="_system">Link Text</a>
    webServer.send(200, "text/html", "<HTML><HEAD><TITLE>Success</TITLE></HEAD><BODY>Success</BODY></HTML>");
  }
 handleRoot();
}


The token gets reset to "0" when the user logs off. I haven't yet figured out how to automatically open the browser, but I'm hoping that's just a result of my lack of HTML experience and not because it's impossible.

Hope that helps, and please do let us know how you've addressed Android. (I'll have a look at your latest code, too, but my LUA is even weaker than my HTML.)