-
Notifications
You must be signed in to change notification settings - Fork 7.6k
DNSServer refactoring, switch to AsyncUDP #7482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
AsyncUDP offers event driven approch for handling udp dns req's WiFiUDP hooks to loop() for packet processing and making useless malloc's each run
get rid of intermediate mem buffers and extra data copies, most of the data could be referenced or copied from the source packet - removed _buffer member - replaced DNSQuestion.QName from uint8_t[] to char* added sanity checks for mem bounds optimize label/packet length calculations other code cleanup
DNSHeader and DNSQuestion structs could be created on stack no need to keep it as obj members
Exciting work. The challenge with a major change like this is it won't be merged until the next major release (3.0.0?), so #7475 is still useful. |
@mrengineer7777 you maybe right. So I've forked bundled lib integrating this PR into separate repo ESP32-DNSServerAsync for anyone wish to try/test/use. |
- default constructor and start() method simply runs a catch-all DNS setup - avoid string comparison for domain reqs in catch-all mode - use IPaddress class for _resolvedIP (looking for IPv6 support in future)
- use webserver instead of simple tcp setver - use redirects to allows CaptivePortal detection pop-ups in modern systems
add isUp() method - returns 'true' if server is up and UDP socket is listening for UDP req's add isCaptive() method - returns 'true' if server runs in catch-all (captive portal mode) some doxygen comments added start() method now keeps existing IP address if any
@vortigont could you please sign the CLA? |
@me-no-dev done! |
👋 Hello vortigont, we appreciate your contribution to this project! Click to see more instructions ...
Review and merge process you can expect ...
|
@vortigont thanks a lot! Tested and confirmed all working as expected |
Following bugfix #7475. Current implementation of DNSServer lib 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.
https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/src/WiFiUdp.cpp#L205-L221
This PR offers refactored DNSServer code based on bundled AsyncUDP lib and some other optimizations.
- got rid of intermediate mem buffers and extra data copies in DNSServer code
- added sanity checks for mem bounds
- optimize label/packet length calculations
- removed some dynamically allocated members
- refactored "Captive Portal" example, now it invokes a pop-up suggesting to access a portal page on majority of modern systems/devices/browsers
- other code cleanup
This PR in a forked lib ESP32-DNSServerAsync that could be easily tested.
Other known issues: