#dns #c-ares #futures

c-ares-resolver

An asynchronous DNS resolver, backed by c-ares

30 releases (stable)

7.2.1 Jan 20, 2021
7.2.0 Nov 29, 2020
7.1.3 Sep 5, 2020
7.0.0 Nov 17, 2019
0.2.0 Nov 20, 2016

#39 in Asynchronous

Download history 647/week @ 2020-11-07 714/week @ 2020-11-14 734/week @ 2020-11-21 562/week @ 2020-11-28 764/week @ 2020-12-05 839/week @ 2020-12-12 652/week @ 2020-12-19 627/week @ 2020-12-26 287/week @ 2021-01-02 1380/week @ 2021-01-09 791/week @ 2021-01-16 1012/week @ 2021-01-23 1474/week @ 2021-01-30 1224/week @ 2021-02-06 1250/week @ 2021-02-13 1075/week @ 2021-02-20

2,973 downloads per month
Used in 5 crates (4 directly)

MIT license

55KB
937 lines

c-ares-resolver

DNS resolvers built on c-ares, for asynchronous DNS requests.

This crate provides three resolver types - the Resolver, the FutureResolver, and the BlockingResolver:

  • The Resolver is the thinnest wrapper around the underlying c-ares library. It returns answers via callbacks. The other resolvers are built on top of this.
  • The FutureResolver returns answers as std::future::Futures.
  • The BlockingResolver isn't asynchronous at all - as the name suggests, it blocks until the lookup completes.

Build Status Build status crates.io

Documentation

API documentation is here.

Examples

extern crate c_ares_resolver;
extern crate futures_executor;
use futures_executor::block_on;

fn main() {
    let resolver = c_ares_resolver::FutureResolver::new().unwrap();
    let query = resolver.query_a("google.com");
    let response = block_on(query);
    match response {
        Ok(result) => println!("{}", result),
        Err(e) => println!("Lookup failed with error '{}'", e)
    }
}

Further example programs can be found here.

Contributing

Contributions are welcome. Please send pull requests!

Dependencies

~3MB
~62K SLoC