-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Currently, because the Dns
resolver functions return an nb::Result
, this means that some higher-level has to actually cache the the hostname being looked up during repeated calls to resolve the name. However, this isn't really a great API because it enforces caching and RAM usage if the hostnames are long. Thus, if an implementation wants to support N simultanenous queries of 255 bytes, it must cache at least 255 * N bytes locally.
Ideally, we would refactor the functions to be get_host_by_name() -> Handle
, where Handle
is some unique ID that can be queried against in the future (and can ideally be really lightweight, like a u32
).
So the API may be:
trait DnsLookup {
type Handle;
fn start_query(&mut self, hostname: &str, typ: QueryType) -> Result<Handle, Self::Error>;
fn check_query(&mut self, handle: &Handle) -> Result<IpAddr, Self::Error>;
fn cancel_query(&mut self, handle: Handle);
}
Also, it seems like get_host_by_ip()
is a bit of a different DNS use-case and isn't super well-suited for embedded (I just mark it as unimplemented!()
in my case because smoltcp
doesn't support it). Perhaps it would be best to move this to a separate trait.