41 breaking releases

0.42.0 Aug 9, 2024
0.41.1 Nov 13, 2023
0.40.1 Oct 18, 2023
0.40.0 Jun 20, 2023
0.6.0 Mar 29, 2019

#1819 in Asynchronous

Download history 57275/week @ 2024-08-16 66295/week @ 2024-08-23 73115/week @ 2024-08-30 70393/week @ 2024-09-06 65225/week @ 2024-09-13 72978/week @ 2024-09-20 66946/week @ 2024-09-27 75067/week @ 2024-10-04 68870/week @ 2024-10-11 70352/week @ 2024-10-18 64501/week @ 2024-10-25 70183/week @ 2024-11-01 63739/week @ 2024-11-08 63205/week @ 2024-11-15 69789/week @ 2024-11-22 59760/week @ 2024-11-29

270,256 downloads per month
Used in 263 crates (6 directly)

MIT license

350KB
6.5K SLoC

DNS name resolution

Transport for libp2p.

This crate provides the type async_std::Transport and tokio::Transport for use with async-std and tokio, respectively.

A Transport is an address-rewriting libp2p_core::Transport wrapper around an inner Transport. The composed transport behaves like the inner transport, except that libp2p_core::Transport::dial resolves /dns/..., /dns4/..., /dns6/... and /dnsaddr/... components of the given Multiaddr through a DNS, replacing them with the resolved protocols (typically TCP/IP).

The async-std feature and hence the async_std::Transport are enabled by default. Tokio users can furthermore opt-in to the tokio-dns-over-rustls and tokio-dns-over-https-rustls features. For more information about these features, please refer to the documentation of trust-dns-resolver.

On Unix systems, if no custom configuration is given, trust-dns-resolver will try to parse the /etc/resolv.conf file. This approach comes with a few caveats to be aware of:

  1. This fails (panics even!) if /etc/resolv.conf does not exist. This is the case on all versions of Android.
  2. DNS configuration is only evaluated during startup. Runtime changes are thus ignored.
  3. DNS resolution is obviously done in process and consequently not using any system APIs (like libc's gethostbyname). Again this is problematic on platforms like Android, where there's a lot of complexity hidden behind the system APIs.

If the implementation requires different characteristics, one should consider providing their own implementation of Transport or use platform specific APIs to extract the host's DNS configuration (if possible) and provide a custom ResolverConfig.

Dependencies

~10–23MB
~357K SLoC