raybellis / evldns Goto Github PK
View Code? Open in Web Editor NEWAn event-driven DNS server framework
License: Other
An event-driven DNS server framework
License: Other
evldns
should allow for multiple requests and responses to be handled on a single TCP connection.
Ray,
I see that dropping/delaying the requests is "todo", and I needed it for one of my experiments, so I wanted to share some experience of how I did it for your info and feedback.
I was able to get it working rather nicely by adding another bit flag called "defer" to the struct evldns_server_request, and another member called "queue" which is a function pointer with the signature like that of the evldns_server_udp_write_queue, and changing the signature of *_tcp_write_queue to match (and return always 0).
Then evldns_tcp_accept_callback or evldns_udp_read_callback can set the req->queue accordingly.
Also I added an early return from server_process_packet with -1 if the req->defer is set - which avoids any writes if the callback sets it.
Thus, the deferred reply code simply needs to set the req->defer and kick off the long activity with user ptr being the struct evldns_server_request pointer.
Upon the completion of that activity, the callback prepares the wire format by
doing ldns_pkt2wire() call that is otherwise done in server_process_packet, and then call the req->queue(req).
With this, I've quite easily implemented a prototype DNS64 A-filtering proxy based on static.c example and evdns clientside async resolver: for A requests, return 0 replies, for AAAA requests, kick off an async AAAA lookup for the target to upstream, upon completion of that either return the answer or if there are no AAAA records, kick off an A lookup - which, when completes can create a synthesized AAAA reply.
Based on this experience, a couple of things that might be worth doing differently/need further work:
create a couple of "wrapper queue" functions that would also prepare the on-the-wire format and put them into the req->queue rather than the existing ones
there is no way to do either deferred or immediate free of the req... The deferred free can be easily done by exposing the server_request_free(), but since it can not be done from within the callback, probably having another bitflag req->drop which is processed in the respective TCP/UDP routines, might be a viable option ?
--a
What would be the best way to use evldns with dnsmasq in order to achieve following:
I know you could use hosts/address feature of dnsmasq, but I would like to do custom matching later, more dynamic ๐
Hi, Ray:
I have a use case where I'd like to be able to get at the original request sent over the wire by the client, but it looks like the .wire_request
and .wire_reqlen
fields in evldns_server_request
are only set for TCP connections.
It looks like it would be easy to set req->wire_request = buffer; req->wire_reqlen = buflen;
in evldns_udp_read_callback()
. Does that sound correct?
need the ability to specify a unique address vs INADDR_ANY and pass that to bind_to_port. This will allow running multiple processes per host on different addresses.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.