40 breaking releases

0.41.1 Nov 13, 2023
0.40.1 Oct 18, 2023
0.40.0 Jun 20, 2023
0.39.0 Feb 24, 2023
0.6.0 Mar 29, 2019

#1454 in Asynchronous

Download history 56714/week @ 2023-11-23 49924/week @ 2023-11-30 48814/week @ 2023-12-07 43899/week @ 2023-12-14 27344/week @ 2023-12-21 23359/week @ 2023-12-28 41146/week @ 2024-01-04 43564/week @ 2024-01-11 50287/week @ 2024-01-18 47583/week @ 2024-01-25 43819/week @ 2024-02-01 53842/week @ 2024-02-08 58859/week @ 2024-02-15 56429/week @ 2024-02-22 52840/week @ 2024-02-29 33483/week @ 2024-03-07

210,595 downloads per month
Used in 214 crates (6 directly)

MIT license

360KB
7K 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

~9–24MB
~355K SLoC