2018-08-29 11:24:44 +02:00
|
|
|
[package]
|
|
|
|
name = "libp2p"
|
2021-11-26 09:34:58 -07:00
|
|
|
edition = "2021"
|
2022-12-23 03:17:59 +11:00
|
|
|
rust-version = "1.65.0"
|
2018-12-06 19:22:06 +01:00
|
|
|
description = "Peer-to-peer networking library"
|
2022-12-09 15:44:08 +01:00
|
|
|
version = "0.51.0"
|
2018-08-29 11:24:44 +02:00
|
|
|
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-08-29 11:24:44 +02:00
|
|
|
|
|
|
|
[features]
|
2022-09-30 01:32:22 +10:00
|
|
|
full = [
|
2022-10-11 23:10:10 +11:00
|
|
|
"async-std",
|
2022-01-14 10:27:28 +01:00
|
|
|
"autonat",
|
2022-09-30 01:32:22 +10:00
|
|
|
"dcutr",
|
2020-03-11 15:33:22 +01:00
|
|
|
"deflate",
|
2022-10-11 23:10:10 +11:00
|
|
|
"dns",
|
2022-09-30 01:32:22 +10:00
|
|
|
"ecdsa",
|
2020-03-11 15:33:22 +01:00
|
|
|
"floodsub",
|
2022-09-30 01:32:22 +10:00
|
|
|
"gossipsub",
|
2020-03-11 15:33:22 +01:00
|
|
|
"identify",
|
|
|
|
"kad",
|
2022-10-11 23:10:10 +11:00
|
|
|
"mdns",
|
2022-09-30 01:32:22 +10:00
|
|
|
"metrics",
|
2020-03-11 15:33:22 +01:00
|
|
|
"mplex",
|
|
|
|
"noise",
|
|
|
|
"ping",
|
|
|
|
"plaintext",
|
|
|
|
"pnet",
|
2022-11-14 16:12:16 +04:00
|
|
|
"quic",
|
2022-11-13 10:59:14 +11:00
|
|
|
"macros",
|
protocols/relay: Implement circuit relay specification (#1838)
This commit implements the [libp2p circuit
relay](https://github.com/libp2p/specs/tree/master/relay) specification. It is
based on previous work from https://github.com/libp2p/rust-libp2p/pull/1134.
Instead of altering the `Transport` trait, the approach taken in this commit
is to wrap an existing implementation of `Transport` allowing one to:
- Intercept `dial` requests with a relayed address.
- Inject incoming relayed connections with the local node being the destination.
- Intercept `listen_on` requests pointing to a relay, ensuring to keep a
constant connection to the relay, waiting for incoming requests with the local
node being the destination.
More concretely one would wrap an existing `Transport` implementation as seen
below, allowing the `Relay` behaviour and the `RelayTransport` to communicate
via channels.
### Example
```rust
let (relay_transport, relay_behaviour) = new_transport_and_behaviour(
RelayConfig::default(),
MemoryTransport::default(),
);
let transport = relay_transport
.upgrade(upgrade::Version::V1)
.authenticate(plaintext)
.multiplex(YamuxConfig::default())
.boxed();
let mut swarm = Swarm::new(transport, relay_behaviour, local_peer_id);
let relay_addr = Multiaddr::from_str("/memory/1234").unwrap()
.with(Protocol::P2p(PeerId::random().into()))
.with(Protocol::P2pCircuit);
let dst_addr = relay_addr.clone().with(Protocol::Memory(5678));
// Listen for incoming connections via relay node (1234).
Swarm::listen_on(&mut swarm, relay_addr).unwrap();
// Dial node (5678) via relay node (1234).
Swarm::dial_addr(&mut swarm, dst_addr).unwrap();
```
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
Co-authored-by: David Craven <david@craven.ch>
2021-03-11 16:07:59 +01:00
|
|
|
"relay",
|
2021-09-08 00:36:52 +10:00
|
|
|
"rendezvous",
|
2022-09-30 01:32:22 +10:00
|
|
|
"request-response",
|
2022-09-07 09:16:22 +03:00
|
|
|
"rsa",
|
2020-03-11 15:33:22 +01:00
|
|
|
"secp256k1",
|
2022-09-30 01:32:22 +10:00
|
|
|
"serde",
|
2022-10-11 23:10:10 +11:00
|
|
|
"tcp",
|
2022-10-24 11:54:44 +11:00
|
|
|
"tls",
|
2022-10-25 22:09:46 +11:00
|
|
|
"tokio",
|
2020-03-11 15:33:22 +01:00
|
|
|
"uds",
|
2022-09-30 01:32:22 +10:00
|
|
|
"wasm-bindgen",
|
2020-03-11 15:33:22 +01:00
|
|
|
"wasm-ext",
|
2022-09-30 01:32:22 +10:00
|
|
|
"wasm-ext-websocket",
|
2022-11-17 09:17:31 +04:00
|
|
|
"webrtc",
|
2020-03-11 15:33:22 +01:00
|
|
|
"websocket",
|
|
|
|
"yamux",
|
|
|
|
]
|
2022-11-15 15:26:03 +01:00
|
|
|
|
|
|
|
async-std = ["libp2p-swarm/async-std", "libp2p-mdns?/async-io", "libp2p-tcp?/async-io", "libp2p-dns?/async-std", "libp2p-quic?/async-std"]
|
2022-06-10 11:36:29 -05:00
|
|
|
autonat = ["dep:libp2p-autonat"]
|
|
|
|
dcutr = ["dep:libp2p-dcutr", "libp2p-metrics?/dcutr"]
|
|
|
|
deflate = ["dep:libp2p-deflate"]
|
2022-10-11 23:10:10 +11:00
|
|
|
dns = ["dep:libp2p-dns"]
|
2022-11-13 10:59:14 +11:00
|
|
|
ecdsa = ["libp2p-core/ecdsa"]
|
2022-06-10 11:36:29 -05:00
|
|
|
floodsub = ["dep:libp2p-floodsub"]
|
2022-11-13 10:59:14 +11:00
|
|
|
gossipsub = ["dep:libp2p-gossipsub", "libp2p-metrics?/gossipsub"]
|
2022-06-10 11:36:29 -05:00
|
|
|
identify = ["dep:libp2p-identify", "libp2p-metrics?/identify"]
|
|
|
|
kad = ["dep:libp2p-kad", "libp2p-metrics?/kad"]
|
2022-11-13 10:59:14 +11:00
|
|
|
macros = ["libp2p-swarm/macros"]
|
|
|
|
mdns = ["dep:libp2p-mdns"]
|
2022-06-10 11:36:29 -05:00
|
|
|
metrics = ["dep:libp2p-metrics"]
|
|
|
|
mplex = ["dep:libp2p-mplex"]
|
|
|
|
noise = ["dep:libp2p-noise"]
|
|
|
|
ping = ["dep:libp2p-ping", "libp2p-metrics?/ping"]
|
|
|
|
plaintext = ["dep:libp2p-plaintext"]
|
|
|
|
pnet = ["dep:libp2p-pnet"]
|
2022-11-14 16:12:16 +04:00
|
|
|
quic = ["dep:libp2p-quic"]
|
2022-06-10 11:36:29 -05:00
|
|
|
relay = ["dep:libp2p-relay", "libp2p-metrics?/relay"]
|
|
|
|
rendezvous = ["dep:libp2p-rendezvous"]
|
2022-11-13 10:59:14 +11:00
|
|
|
request-response = ["dep:libp2p-request-response"]
|
|
|
|
rsa = ["libp2p-core/rsa"]
|
|
|
|
secp256k1 = ["libp2p-core/secp256k1"]
|
|
|
|
serde = ["libp2p-core/serde", "libp2p-kad?/serde", "libp2p-gossipsub?/serde"]
|
2022-10-11 23:10:10 +11:00
|
|
|
tcp = ["dep:libp2p-tcp"]
|
2022-12-13 07:58:01 +11:00
|
|
|
tls = ["dep:libp2p-tls"]
|
2022-11-17 09:17:31 +04:00
|
|
|
tokio = ["libp2p-swarm/tokio", "libp2p-mdns?/tokio", "libp2p-tcp?/tokio", "libp2p-dns?/tokio", "libp2p-quic?/tokio", "libp2p-webrtc?/tokio"]
|
2022-06-10 11:36:29 -05:00
|
|
|
uds = ["dep:libp2p-uds"]
|
2022-11-24 23:12:35 +01:00
|
|
|
wasm-bindgen = ["futures-timer/wasm-bindgen", "instant/wasm-bindgen", "getrandom/js", "libp2p-swarm/wasm-bindgen"]
|
2022-06-10 11:36:29 -05:00
|
|
|
wasm-ext = ["dep:libp2p-wasm-ext"]
|
|
|
|
wasm-ext-websocket = ["wasm-ext", "libp2p-wasm-ext?/websocket"]
|
2022-11-17 09:17:31 +04:00
|
|
|
webrtc = ["dep:libp2p-webrtc", "libp2p-webrtc?/pem"]
|
2022-06-10 11:36:29 -05:00
|
|
|
websocket = ["dep:libp2p-websocket"]
|
|
|
|
yamux = ["dep:libp2p-yamux"]
|
2018-08-29 11:24:44 +02:00
|
|
|
|
|
|
|
[dependencies]
|
2021-01-12 12:48:37 +01:00
|
|
|
bytes = "1"
|
2023-01-31 23:34:17 +00:00
|
|
|
futures = "0.3.26"
|
2021-10-30 12:41:30 +02:00
|
|
|
futures-timer = "3.0.2" # Explicit dependency to be used in `wasm-bindgen` feature
|
|
|
|
getrandom = "0.2.3" # Explicit dependency to be used in `wasm-bindgen` feature
|
|
|
|
instant = "0.1.11" # Explicit dependency to be used in `wasm-bindgen` feature
|
2022-01-14 10:27:28 +01:00
|
|
|
|
2022-12-12 12:30:23 +01:00
|
|
|
libp2p-autonat = { version = "0.10.0", path = "protocols/autonat", optional = true }
|
2022-12-20 09:52:08 +01:00
|
|
|
libp2p-core = { version = "0.39.0", path = "core" }
|
2022-12-12 12:30:23 +01:00
|
|
|
libp2p-dcutr = { version = "0.9.0", path = "protocols/dcutr", optional = true }
|
|
|
|
libp2p-floodsub = { version = "0.42.0", path = "protocols/floodsub", optional = true }
|
|
|
|
libp2p-identify = { version = "0.42.0", path = "protocols/identify", optional = true }
|
|
|
|
libp2p-kad = { version = "0.43.0", path = "protocols/kad", optional = true }
|
|
|
|
libp2p-metrics = { version = "0.12.0", path = "misc/metrics", optional = true }
|
2022-12-20 09:52:08 +01:00
|
|
|
libp2p-mplex = { version = "0.39.0", path = "muxers/mplex", optional = true }
|
|
|
|
libp2p-noise = { version = "0.42.0", path = "transports/noise", optional = true }
|
2022-12-12 12:30:23 +01:00
|
|
|
libp2p-ping = { version = "0.42.0", path = "protocols/ping", optional = true }
|
2022-12-20 09:52:08 +01:00
|
|
|
libp2p-plaintext = { version = "0.39.0", path = "transports/plaintext", optional = true }
|
2022-11-18 22:04:16 +11:00
|
|
|
libp2p-pnet = { version = "0.22.2", path = "transports/pnet", optional = true }
|
2022-12-12 12:30:23 +01:00
|
|
|
libp2p-relay = { version = "0.15.0", path = "protocols/relay", optional = true }
|
|
|
|
libp2p-rendezvous = { version = "0.12.0", path = "protocols/rendezvous", optional = true }
|
|
|
|
libp2p-request-response = { version = "0.24.0", path = "protocols/request-response", optional = true }
|
2022-12-09 15:44:08 +01:00
|
|
|
libp2p-swarm = { version = "0.42.0", path = "swarm" }
|
2022-11-02 23:02:21 +11:00
|
|
|
libp2p-uds = { version = "0.37.0", path = "transports/uds", optional = true }
|
2022-12-20 09:52:08 +01:00
|
|
|
libp2p-wasm-ext = { version = "0.39.0", path = "transports/wasm-ext", optional = true }
|
|
|
|
libp2p-yamux = { version = "0.43.0", path = "muxers/yamux", optional = true }
|
|
|
|
multiaddr = { version = "0.17.0" }
|
2022-02-16 15:16:04 +01:00
|
|
|
parking_lot = "0.12.0"
|
2020-10-14 11:17:15 +02:00
|
|
|
pin-project = "1.0.0"
|
2021-03-15 12:31:21 +01:00
|
|
|
smallvec = "1.6.1"
|
2018-08-29 11:24:44 +02:00
|
|
|
|
2020-06-30 17:31:02 +02:00
|
|
|
[target.'cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))'.dependencies]
|
2022-12-20 09:52:08 +01:00
|
|
|
libp2p-deflate = { version = "0.39.0", path = "transports/deflate", optional = true }
|
|
|
|
libp2p-dns = { version = "0.39.0", path = "transports/dns", optional = true }
|
2022-12-12 12:30:23 +01:00
|
|
|
libp2p-mdns = { version = "0.43.0", path = "protocols/mdns", optional = true }
|
2022-12-20 09:52:08 +01:00
|
|
|
libp2p-quic = { version = "0.7.0-alpha.2", path = "transports/quic", optional = true }
|
|
|
|
libp2p-tcp = { version = "0.39.0", path = "transports/tcp", optional = true }
|
|
|
|
libp2p-tls = { version = "0.1.0-alpha.2", path = "transports/tls", optional = true }
|
|
|
|
libp2p-webrtc = { version = "0.4.0-alpha.2", path = "transports/webrtc", optional = true }
|
|
|
|
libp2p-websocket = { version = "0.41.0", path = "transports/websocket", optional = true }
|
2022-02-14 21:24:58 +11:00
|
|
|
|
|
|
|
[target.'cfg(not(target_os = "unknown"))'.dependencies]
|
2022-12-12 12:30:23 +01:00
|
|
|
libp2p-gossipsub = { version = "0.44.0", path = "protocols/gossipsub", optional = true }
|
2018-08-29 11:24:44 +02:00
|
|
|
|
|
|
|
[dev-dependencies]
|
2021-01-12 13:35:11 +01:00
|
|
|
async-std = { version = "1.6.2", features = ["attributes"] }
|
2021-08-16 20:02:11 +02:00
|
|
|
async-trait = "0.1"
|
2023-01-18 10:05:59 +11:00
|
|
|
either = "1.8.0"
|
2022-12-02 18:06:09 +01:00
|
|
|
env_logger = "0.10.0"
|
2022-10-14 12:51:23 +08:00
|
|
|
clap = { version = "4.0.13", features = ["derive"] }
|
2022-01-20 16:43:32 +08:00
|
|
|
tokio = { version = "1.15", features = ["io-util", "io-std", "macros", "rt", "rt-multi-thread"] }
|
2018-08-29 11:24:44 +02:00
|
|
|
|
2022-12-20 00:41:07 +01:00
|
|
|
libp2p-mplex = { path = "muxers/mplex" }
|
|
|
|
libp2p-noise = { path = "transports/noise" }
|
|
|
|
libp2p-tcp = { path = "transports/tcp", features = ["tokio"] }
|
2022-12-19 11:26:19 +04:00
|
|
|
|
2017-04-08 03:31:22 +02:00
|
|
|
[workspace]
|
2017-11-02 11:09:50 +01:00
|
|
|
members = [
|
2018-05-16 12:59:36 +02:00
|
|
|
"core",
|
2021-08-13 22:51:54 +02:00
|
|
|
"misc/metrics",
|
2018-08-29 11:24:44 +02:00
|
|
|
"misc/multistream-select",
|
2022-05-16 19:17:49 +02:00
|
|
|
"misc/rw-stream-sink",
|
2022-03-11 08:44:05 -03:00
|
|
|
"misc/keygen",
|
2022-05-05 18:28:47 +02:00
|
|
|
"misc/prost-codec",
|
2022-09-22 12:48:32 +04:00
|
|
|
"misc/quickcheck-ext",
|
2018-11-15 17:41:11 +01:00
|
|
|
"muxers/mplex",
|
|
|
|
"muxers/yamux",
|
2022-10-17 11:23:13 +11:00
|
|
|
"muxers/test-harness",
|
2022-02-08 15:56:35 +01:00
|
|
|
"protocols/dcutr",
|
2022-01-14 10:27:28 +01:00
|
|
|
"protocols/autonat",
|
2018-08-29 11:24:44 +02:00
|
|
|
"protocols/floodsub",
|
2020-01-25 02:16:02 +11:00
|
|
|
"protocols/gossipsub",
|
2021-09-08 00:36:52 +10:00
|
|
|
"protocols/rendezvous",
|
2018-08-29 11:24:44 +02:00
|
|
|
"protocols/identify",
|
|
|
|
"protocols/kad",
|
2020-02-24 21:36:55 +03:00
|
|
|
"protocols/mdns",
|
2018-11-15 17:41:11 +01:00
|
|
|
"protocols/ping",
|
protocols/relay: Implement circuit relay specification (#1838)
This commit implements the [libp2p circuit
relay](https://github.com/libp2p/specs/tree/master/relay) specification. It is
based on previous work from https://github.com/libp2p/rust-libp2p/pull/1134.
Instead of altering the `Transport` trait, the approach taken in this commit
is to wrap an existing implementation of `Transport` allowing one to:
- Intercept `dial` requests with a relayed address.
- Inject incoming relayed connections with the local node being the destination.
- Intercept `listen_on` requests pointing to a relay, ensuring to keep a
constant connection to the relay, waiting for incoming requests with the local
node being the destination.
More concretely one would wrap an existing `Transport` implementation as seen
below, allowing the `Relay` behaviour and the `RelayTransport` to communicate
via channels.
### Example
```rust
let (relay_transport, relay_behaviour) = new_transport_and_behaviour(
RelayConfig::default(),
MemoryTransport::default(),
);
let transport = relay_transport
.upgrade(upgrade::Version::V1)
.authenticate(plaintext)
.multiplex(YamuxConfig::default())
.boxed();
let mut swarm = Swarm::new(transport, relay_behaviour, local_peer_id);
let relay_addr = Multiaddr::from_str("/memory/1234").unwrap()
.with(Protocol::P2p(PeerId::random().into()))
.with(Protocol::P2pCircuit);
let dst_addr = relay_addr.clone().with(Protocol::Memory(5678));
// Listen for incoming connections via relay node (1234).
Swarm::listen_on(&mut swarm, relay_addr).unwrap();
// Dial node (5678) via relay node (1234).
Swarm::dial_addr(&mut swarm, dst_addr).unwrap();
```
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
Co-authored-by: David Craven <david@craven.ch>
2021-03-11 16:07:59 +01:00
|
|
|
"protocols/relay",
|
2020-06-29 17:08:40 +02:00
|
|
|
"protocols/request-response",
|
2019-07-04 14:47:59 +02:00
|
|
|
"swarm",
|
2021-01-26 22:49:08 +01:00
|
|
|
"swarm-derive",
|
2023-01-24 22:28:57 +00:00
|
|
|
"interop-tests",
|
2021-02-01 16:37:19 +01:00
|
|
|
"transports/deflate",
|
2018-11-15 17:41:11 +01:00
|
|
|
"transports/dns",
|
2021-02-01 16:37:19 +01:00
|
|
|
"transports/noise",
|
2022-10-24 11:54:44 +11:00
|
|
|
"transports/tls",
|
2021-02-01 16:37:19 +01:00
|
|
|
"transports/plaintext",
|
|
|
|
"transports/pnet",
|
2022-11-14 16:12:16 +04:00
|
|
|
"transports/quic",
|
2018-08-29 11:24:44 +02:00
|
|
|
"transports/tcp",
|
2018-11-15 17:41:11 +01:00
|
|
|
"transports/uds",
|
2019-04-25 15:44:40 +02:00
|
|
|
"transports/websocket",
|
2022-11-17 09:17:31 +04:00
|
|
|
"transports/wasm-ext",
|
2023-02-09 22:14:25 -08:00
|
|
|
"transports/webrtc",
|
|
|
|
"interop-tests"
|
2017-11-02 11:09:50 +01:00
|
|
|
]
|
2020-10-08 06:37:16 -04:00
|
|
|
|
2022-03-22 11:22:17 +01:00
|
|
|
[[example]]
|
|
|
|
name = "chat"
|
2022-09-30 01:32:22 +10:00
|
|
|
required-features = ["full"]
|
2022-03-22 11:22:17 +01:00
|
|
|
|
2020-10-08 06:37:16 -04:00
|
|
|
[[example]]
|
|
|
|
name = "chat-tokio"
|
2022-09-30 01:32:22 +10:00
|
|
|
required-features = ["full"]
|
2022-03-22 11:22:17 +01:00
|
|
|
|
|
|
|
[[example]]
|
|
|
|
name = "file-sharing"
|
2022-09-30 01:32:22 +10:00
|
|
|
required-features = ["full"]
|
2022-03-22 11:22:17 +01:00
|
|
|
|
|
|
|
[[example]]
|
|
|
|
name = "gossipsub-chat"
|
2022-09-30 01:32:22 +10:00
|
|
|
required-features = ["full"]
|
2022-03-22 11:22:17 +01:00
|
|
|
|
|
|
|
[[example]]
|
|
|
|
name = "ipfs-private"
|
2022-09-30 01:32:22 +10:00
|
|
|
required-features = ["full"]
|
|
|
|
|
|
|
|
[[example]]
|
|
|
|
name = "ipfs-kad"
|
|
|
|
required-features = ["full"]
|
|
|
|
|
|
|
|
[[example]]
|
|
|
|
name = "ping"
|
|
|
|
required-features = ["full"]
|
|
|
|
|
|
|
|
[[example]]
|
|
|
|
name = "mdns-passive-discovery"
|
|
|
|
required-features = ["full"]
|
|
|
|
|
|
|
|
[[example]]
|
|
|
|
name = "distributed-key-value-store"
|
|
|
|
required-features = ["full"]
|
2022-10-24 04:00:20 +02:00
|
|
|
|
2022-11-05 01:10:30 +05:30
|
|
|
# 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"]
|