mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-29 09:41:34 +00:00
[libp2p-dns] Implement /dnsaddr
resolution. (#1931)
* Implement `/dnsaddr` support on `libp2p-dns`. To that end, since resolving `/dnsaddr` addresses needs "fully qualified" multiaddresses when dialing, i.e. those that end with the `/p2p/...` protocol, we make sure that dialing always uses such fully qualified addresses by appending the `/p2p` protocol as necessary. As a side-effect, this adds support for dialing peers via "fully qualified" addresses, as an alternative to using a `PeerId` together with a `Multiaddr` with or without the `/p2p` protocol. * Adapt libp2p-relay. * Update versions, changelogs and small cleanups.
This commit is contained in:
@ -174,6 +174,16 @@ impl Multiaddr {
|
||||
|
||||
if replaced { Some(address) } else { None }
|
||||
}
|
||||
|
||||
/// Checks whether the given `Multiaddr` is a suffix of this `Multiaddr`.
|
||||
pub fn ends_with(&self, other: &Multiaddr) -> bool {
|
||||
let n = self.bytes.len();
|
||||
let m = other.bytes.len();
|
||||
if n < m {
|
||||
return false
|
||||
}
|
||||
self.bytes[(n - m) ..] == other.bytes[..]
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Multiaddr {
|
||||
|
Reference in New Issue
Block a user