-fix segfault
+There is a strange networking problem, calling udp_read more than once
+gives an error
+upd.read (with a dot) doesn't work at all.
-fix pkt printing its id: <id>
+I suspect these 2 errors are related. It may be the case this is a bug
+in the core ldns
rdf_ip = rdf.new_frm_str(LDNS_RDF_TYPE_A, "127.0.0.1")
socket = udp.open(rdf_ip, 5353)
+
+while true do
+
-- read from the socket, this blocks...
wirebuf, sockaddr_from, fromlen = udp_read(socket) -- this works
--wirebuf, sockaddr_from, fromlen = udp.read(socket) -- this doesn't
lua_debug("received from the interface")
+ -- next we must send it to our recursive nameserver
+ -- and pick up the result
+ -- then we modify the result somewhat and sent it back
+ -- to the client
+
id = packet.id(wirepkt);
packet.print(wirepkt)
lua_packet_ancount_incr(pkt, 2)
wirebuf2 = packet.to_buf(pkt)
+ -- write back to the client
bytes = lua_udp_write(socket, wirebuf2, sockaddr_from)
if bytes == -1 then
lua_debug("write error")
end
+end
+
udp.close(socket)