JFLib

netio/dns/resolver.rs#

Source: lib/netio/dns/resolver.rs

the resolver: queries over UDP and TCP and the encrypted transports, answers bound to their
question (read_reply), the search list, the cache
  • enum Reply what an answer says about its question

    • Found(Lookup) -- the name exists: its records of the type (none: NODATA) and how long they may be kept
    • NoName(Option<u32>) -- no such name (NXDOMAIN); how many seconds that may be kept (None: not at all, no SOA)
    • Truncated -- too large for UDP: ask over TCP
    • NoEdns -- FORMERR without EDNS in the answer to a query with it: ask again without (RFC 6891 7)
    • Failed(u16) -- the server failed or refused (its whole RCODE: SERVFAIL 2, NOTIMP 4, REFUSED 5, ...)
    • Bad -- malformed, or not an answer to the query
  • fn read_reply(m: &[u8], q: &[u8]) -> Reply what the answer m says to the query q (both whole messages): the id, the response bit, a standard query, the question, the RCODE; the records of the asked name or of the end of its CNAME chain in the answer section, of the asked type and class IN

  • struct Resolver a resolver with its configuration, its encrypted servers' connections and a cache

impl Resolver

  • fn new(cfg: Config) -> Resolver a resolver of this configuration with a cache of 1000 entries
  • fn system() -> Resolver this computer's configuration (Config::system)
  • fn with_cache(self, entries: usize) -> Resolver a cache of at most this many answers (0: none)
  • fn config(&self) -> &Config the configuration it was made with
  • fn clear_cache(&self) forgets the cached answers (and what DNSSEC knows of zones)
  • fn lookup(&self, name: &str, rtype: u16) -> NetResult<Lookup> the records of name of type rtype (see the top of dns.rs)
  • fn resolve(&self, host: &str, port: u16) -> NetResult<Vec<SocketAddr>> the addresses of a host (as dns::resolve_with: numbers, localhost, the hosts file, the app's permissions), A and AAAA through this resolver and its cache

Source: docs/API.md in the JFLib repository.