Network Programming in Elixir and Erlang: DNS server does not work with XDig code in the book

xdif/server.ex code from book does not work with the XDig client from the book.

I noticed inside handle_info call, it’s not sending the question(s) in reply.

Current code excerpt -

reply_header = %XDig.Protocol.Header{
      message_id: header.message_id,
      qr: 1,
      opcode: 0,
      rcode: 0,
      an_count: length(answers)
    }

    reply = [
      XDig.Protocol.encode_header(reply_header),
      Enum.map(answers, &XDig.Protocol.encode_answer/1)
    ]

which I had to change to -

    reply_header = %XDig.Protocol.Header{
      message_id: header.message_id,
      qr: 1,
      opcode: 0,
      rcode: 0,
      qd_count: length(questions),
      an_count: length(answers)
    }

    reply = [
      XDig.Protocol.encode_header(reply_header),
      Enum.map(questions, &XDig.Protocol.encode_question/1),
      Enum.map(answers, &XDig.Protocol.encode_answer/1)
    ]

to make it work. Now both Mac’s dig command and XDig client from book seems to work with server code.

Thanks!