Basically that is what some captive portals do.
I developed that script on nodemcu_20150212.bin without any significant trouble and it ran ok there.
To make use of the node.compile() option, I upgraded to the 20150213.bin but the MCU crashed and rebooted when trying to send back the DNS reply.
The LUA script looks like this:
svr=net.createServer(net.UDP) svr:on("receive",function(svr,pl) decodedns(pl) encodedns (query, transaction_id) svr:send(response) end) svr:listen(53) function decodedns(pl) --do some magic end function encodedns(query, transaction_id) --do some more magic end
The svr:send failed and crashed the mcu. It totally lacks all input sanitation and can easily be derailed, but that is another story.
Looking at the changes from 20150212 to 20150213, the only suspicious change was this:
@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. */ -#define LUAL_BUFFERSIZE BUFSIZ +#define LUAL_BUFFERSIZE (BUFSIZ*4) /* }================================================================== */
I changed that back to the original buffer size and sure enough my script was fine again.