Home

Awesome

ESP32 Async DNSServer

This is a forked version of ESP32's bundled DNSServer. Unlike bundled version based on WiFiUDP lib this fork was rewritten to use AsyncUDP lib and is more efficient on using CPU/mem resources.

A PR espressif/arduino-esp32#7482 has been raised for the upstream. Untill(unless) it accepted this repo will be a test-lab for developing. Feel free to use this lib to replace bundled ESP32's DNSServer.

====

Bundled implementation of DNSServer lib for ESP32 uses WiFiUDP which is not very efficient considering cpu/mem resources. It hooks to loop() for packet processing doing useless malloc's/free each run cycle, even when no requests are received.

https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/src/WiFiUdp.cpp#L205-L221

int WiFiUDP::parsePacket(){
// skipped
  char * buf = new char[1460];
  if ((len = recvfrom(udp_server, buf, 1460, MSG_DONTWAIT, (struct sockaddr *) &si_other, (socklen_t *)&slen)) == -1){
    delete[] buf;
    return 0;
  }

This PR offers refactored DNSServer code based on bundled AsyncUDP lib along with other optimizations and enhansments.

Other known issues: