2018-11-24 13:55:18 +01:00
|
|
|
[package]
|
|
|
|
name = "libp2p-mdns"
|
2021-11-26 09:34:58 -07:00
|
|
|
edition = "2021"
|
2022-11-18 22:04:16 +11:00
|
|
|
rust-version = "1.62.0"
|
2022-12-12 12:30:23 +01:00
|
|
|
version = "0.43.0"
|
2018-11-24 13:55:18 +01:00
|
|
|
description = "Implementation of the libp2p mDNS discovery method"
|
|
|
|
authors = ["Parity Technologies <admin@parity.io>"]
|
|
|
|
license = "MIT"
|
2018-12-06 19:22:06 +01:00
|
|
|
repository = "https://github.com/libp2p/rust-libp2p"
|
|
|
|
keywords = ["peer-to-peer", "libp2p", "networking"]
|
|
|
|
categories = ["network-programming", "asynchronous"]
|
2018-11-24 13:55:18 +01:00
|
|
|
|
|
|
|
[dependencies]
|
2022-11-14 22:35:18 +00:00
|
|
|
async-io = { version = "1.3.1", optional = true }
|
2021-03-02 10:18:24 +01:00
|
|
|
data-encoding = "2.3.2"
|
2023-01-31 23:34:17 +00:00
|
|
|
futures = "0.3.26"
|
2022-11-18 01:12:23 +00:00
|
|
|
if-watch = "3.0.0"
|
2022-12-20 09:52:08 +01:00
|
|
|
libp2p-core = { version = "0.39.0", path = "../../core" }
|
2022-12-09 15:44:08 +01:00
|
|
|
libp2p-swarm = { version = "0.42.0", path = "../../swarm" }
|
2021-03-02 10:18:24 +01:00
|
|
|
log = "0.4.14"
|
|
|
|
rand = "0.8.3"
|
|
|
|
smallvec = "1.6.1"
|
2021-03-15 17:33:49 +01:00
|
|
|
socket2 = { version = "0.4.0", features = ["all"] }
|
2022-09-01 23:53:38 -04:00
|
|
|
tokio = { version = "1.19", default-features = false, features = ["net", "time"], optional = true}
|
2022-11-17 23:06:30 +11:00
|
|
|
trust-dns-proto = { version = "0.22.0", default-features = false, features = ["mdns", "tokio-runtime"] }
|
2022-11-14 22:35:18 +00:00
|
|
|
void = "1.0.2"
|
2022-09-01 23:53:38 -04:00
|
|
|
|
|
|
|
[features]
|
2022-11-18 01:12:23 +00:00
|
|
|
tokio = ["dep:tokio", "if-watch/tokio"]
|
|
|
|
async-io = ["dep:async-io", "if-watch/smol"]
|
2022-09-01 23:53:38 -04:00
|
|
|
|
misc/mdns: Update to futures-preview (#1247)
* misc/mdns/service: Use async std with stack pinned futures
* misc/mdns: Define mdns broadcast address as lazy static
* misc/mdns: Drop future before borrowing their arguments again
* misc/mdns: Send queries on query socket, not socket
* misc/mdns: Use poll_next_unpin on query interval stream
* misc/mdns: Ensure underlying task is woken up on next interval tick
* misc/mdns: Wrap match expression in scope to drop future early
* misc/mdns: Adjust 'discovery_ourselves' test
* misc/mdns: Make query interval fire instantly on first tick
This is an optimization only important for short lived use cases, e.g.
unit tests. Instead of waiting for 20 seconds at first, the query
interval fires right away and thereby the service makes progress
instantly.
* misc/mdns: Adjust MdnsService documentation tests
* misc/mdns: Do not drop UDP socket send and reicv futures
Libp2p-mdns uses the async-std crate for network io. This crate only
offers async send and receive functions. In order to use this in non
async/await functions one needs to keep the future returned by the crate
functions around across `poll` invocations.
The future returned by the crate functions references the io resource.
Thus one has to keep both the io resource as well as the future
referencing it. This results in a self-referencing struct which is not
possible to create with safe Rust.
Instead, by having `MdnsService::next` (former `MdnsService::poll`) take
ownership of `self`, the Rust async magic takes care of the above (See
code comments for more details).
As a (negative) side effect, given that `MdnsService::next` takes
ownership of `self`, there is nothing to bind the lifetime of the
returned `MdnsPacket` to. With no better solution in mind, this patch
makes `MdnsPacket` static, not referencing the `MdnsService` receive
buffer.
* misc/mdns: Fix code comments and remove *if Free* TODO
* misc/mdns: Minor refactorings
* misc/mdns: Build responses in behaviour.rs directly
* misc/mdns: Move response ttl duration to constant
* misc/mdns: Remove optimization todo comment
* misc/mdns: Add query interval test
* misc/mdns: Move packet parsing into MdnPacket impl
* misc/mdns: Don't have receiving packets starve the query interval
When we 'await' on receiving a packet on the udp socket without
receiving a single packet we starve the remaining logic of the mdns
service, in this case the logic triggered on the receive interval.
* misc/mdns: Add debug_assert to MaybeBusyMdnsService check
* misc/mdns: Implement Debug for MaybeBusyMdnsService
* misc/mdns: Make ownership note a normal comment, not a doc comment
* misc/mdns: Have discovered_peers return an iterator
2019-11-20 13:25:12 +01:00
|
|
|
[dev-dependencies]
|
2021-08-03 14:55:06 +02:00
|
|
|
async-std = { version = "1.9.0", features = ["attributes"] }
|
2022-12-02 18:06:09 +01:00
|
|
|
env_logger = "0.10.0"
|
2022-12-13 07:58:01 +11:00
|
|
|
libp2p-noise = { path = "../../transports/noise" }
|
|
|
|
libp2p-swarm = { path = "../../swarm", features = ["tokio", "async-std"] }
|
|
|
|
libp2p-tcp = { path = "../../transports/tcp", features = ["tokio", "async-io"] }
|
|
|
|
libp2p-yamux = { path = "../../muxers/yamux" }
|
2022-09-01 23:53:38 -04:00
|
|
|
tokio = { version = "1.19", default-features = false, features = ["macros", "rt", "rt-multi-thread", "time"] }
|
|
|
|
|
|
|
|
[[test]]
|
|
|
|
name = "use-async-std"
|
|
|
|
required-features = ["async-io"]
|
|
|
|
|
|
|
|
[[test]]
|
|
|
|
name = "use-tokio"
|
|
|
|
required-features = ["tokio"]
|
|
|
|
|
2022-10-24 04:00:20 +02:00
|
|
|
|
2022-12-09 15:44:08 +01:00
|
|
|
# Passing arguments to the docsrs builder in order to properly document cfg's.
|
2022-10-24 04:00:20 +02:00
|
|
|
# More information: https://docs.rs/about/builds#cross-compiling
|
|
|
|
[package.metadata.docs.rs]
|
|
|
|
all-features = true
|
|
|
|
rustdoc-args = ["--cfg", "docsrs"]
|
|
|
|
rustc-args = ["--cfg", "docsrs"]
|