Commit Graph

1008 Commits

Author SHA1 Message Date
d862b40383 refactor(examples): remove #[behaviour(to_swarm = "Event")]
Removes the usage of the `to_swarm` `libp2p-swarm-derive` attribute in favor of the automatically generated event through the `NetworkBehaviour` derive macro.

Pull-Request: #4580.
2023-10-03 22:21:17 +00:00
980bda088d deps: bump regex from 1.9.5 to 1.9.6
Pull-Request: #4577.
2023-10-03 02:03:02 +00:00
3ff354f1ef deps: bump thiserror from 1.0.48 to 1.0.49
Pull-Request: #4578.
2023-10-03 01:50:38 +00:00
90a9752dc7 deps: bump sha2 from 0.10.7 to 0.10.8
Pull-Request: #4579.
2023-10-02 09:03:11 +00:00
ecdd0ff767 refactor(identify): use ReadyUpgrade for {In,Out}boundUpgrade
Related: #2863.

Pull-Request: #4563.
2023-09-28 23:23:54 +00:00
665181efb5 chore: address latest clippy lints
I ran clippy on the current nightly and fixed issues found by it. Noteworthy are two instances of the [never_loop](https://rust-lang.github.io/rust-clippy/master/index.html#/never_loop) lint.

Pull-Request: #4571.
2023-09-28 10:08:51 +00:00
d30eb9daa7 fix(upnp): do not return failure events repeatedly
When a gateway is not found or is not routable, UPnP `NetworkBehaviour`'s `poll` repeatedly returns the same failure state, which increases CPU usage.

Pull-Request: #4569.
2023-09-28 07:52:24 +00:00
c8b5f49ec2 refactor(kad): rename to follow naming convention across repository
Renamed the following

`kad::Kademlia` -> `kad::Behaviour`
`kad::KademliaEvent` -> `kad::Event`
`kad::KademliaBucketInserts` -> `kad::BucketInserts`
`kad::KademliaStoreInserts` -> `kad::StoreInserts`
`kad::KademliaConfig` -> `kad::Config`
`kad::KademliaCaching` -> `kad::Caching`
`kad::KademliaEvent` -> `kad::Event`
`kad::KademliaConnectionType` -> `kad::ConnectionType`
`KademliaHandler` -> `Handler`
`KademliaHandlerEvent` -> `HandlerEvent`
`KademliaProtocolConfig` -> `ProtocolConfig`
`KademliaHandlerIn` -> `HandlerIn`
`KademliaRequestId` -> `RequestId`
`KademliaHandlerQueryErr` -> `HandlerQueryErr`

Resolves: #4485

Pull-Request: #4547.
2023-09-27 20:25:22 +00:00
fffd47b69f refactor(plaintext): rename symbols to follow naming convention
Related: #2217.

Pull-Request: #4535.
2023-09-27 19:42:45 +00:00
f6b5a1376a chore(kad): update kad caching docs for clarity about write mechanism
Pull-Request: #4564.
2023-09-27 19:30:33 +00:00
38ea7ad453 fix(upnp): use correct mapping protocol for UDP
Return `PortMappingProtocol::UDP` when the multiaddress protocol is UDP.

Pull-Request: #4542.
2023-09-25 10:50:12 +00:00
94432d83ad deps: bump smallvec from 1.11.0 to 1.11.1
Pull-Request: #4551.
2023-09-25 08:33:29 +00:00
ad45d23d94 fix(identify): handle partial push messages
According to the [spec], all fields within push messages are optional. To handle missing fields, we deserialize push messages into a different struct, patch the previously received, full identify message with it and emit this as the new info.

Previously, we failed to parse the message which causes incompatibility with js-libp2p nodes as they don't send the public key in push messages. See 88c47f51f9/packages/libp2p/src/identify/identify.ts (L205-L210).

[spec]: https://github.com/libp2p/specs/tree/master/identify#identifypush

Pull-Request: #4495.
2023-09-24 11:36:58 +00:00
95890b550b refactor(dns): unify symbol naming
Renamed the following
- `dns::GenDnsConfig`  ->  `dns::Config`
- `dns::DnsConfig` -> `dns::async_std::Config`
- `dns::TokioDnsConfig` -> `dns::tokio::Config`

If async-std feature is enable, use `dns::async_std::Config`. When using tokio, import `dns::tokio::Config` . There is no need to use `dns::Config` directly.

Resolves #4486.
Related: #2217.

Pull-Request: #4505.
2023-09-24 05:31:42 +00:00
600b6af314 chore: prepare non-breaking releases
Crates to be released:

- core
- misc/futures-bounded
- misc/server
- misc/webrtc-utils
- protocols/kad
- protocols/ping
- protocols/upnp
- swarm
- transports/webrtc-websys
- transports/webrtc

Pull-Request: #4537.
2023-09-22 11:02:02 +00:00
32df6e8747 refactor(relay): delete now unused Action
This is a relict from when we still had to delay the construction of `ToSwarm` commands because some data was only available in `poll` via `PollParameters`. This is now resolved and `PollParameters` will go away.

Pull-Request: #4536.
2023-09-22 04:50:05 +00:00
efea4902a5 refactor(relay): move stream-handling away from {In,Out}boundUpgrade
Fixes: #4075.

Pull-Request: #4275.
2023-09-20 08:11:36 +00:00
c52a2fc3af feat(swarm): allow configuration to idle connection timeout
Previously, a connection would be shut down immediately as soon as its `ConnectionHandler` reports `KeepAlive::No`. As we have gained experience with libp2p, it turned out that this isn't ideal.

For one, tests often need to keep connections alive longer than the configured protocols require. Plus, some usecases require connections to be kept alive in general.

Both of these needs are currently served by the `keep_alive::Behaviour`. That one does essentially nothing other than statically returning `KeepAlive::Yes` from its `ConnectionHandler`.

It makes much more sense to deprecate `keep_alive::Behaviour` and instead allow users to globally configure an `idle_conncetion_timeout` on the `Swarm`. This timeout comes into effect once a `ConnectionHandler` reports `KeepAlive::No`. To start with, this timeout is 0. Together with https://github.com/libp2p/rust-libp2p/issues/3844, this will allow us to move towards a much more aggressive closing of idle connections, together with a more ergonomic way of opting out of this behaviour.

Fixes #4121.

Pull-Request: #4161.
2023-09-19 22:32:29 +00:00
3ee8ab6581 deps: bump serde_json from 1.0.106 to 1.0.107
Pull-Request: #4515.
2023-09-18 09:41:40 +00:00
8a523f950f deps: bump socket2 from 0.5.3 to 0.5.4
Pull-Request: #4513.
2023-09-18 09:17:45 +00:00
508cad1f0d feat(kad): migrate to quick-protobuf-codec crate
Resolves #4487.

Pull-Request: #4501.
2023-09-15 21:11:09 +00:00
411a0495c5 feat(upnp): add implementation based on IGD protocol
Implements UPnP via the IGD protocol. The usage of IGD is an implementation detail and is planned to be extended to support NATpnp.

Resolves: #3903.

Pull-Request: #4156.
2023-09-12 10:29:27 +00:00
f798572e78 deps: bump lru from 0.11.0 to 0.11.1
Pull-Request: #4478.
2023-09-11 23:57:05 +00:00
0df1a96e3c deps: bump base64 from 0.21.3 to 0.21.4
Pull-Request: #4479.
2023-09-11 23:32:09 +00:00
ae3cef14cb deps: bump serde_json from 1.0.105 to 1.0.106
Pull-Request: #4481.
2023-09-11 14:13:30 +00:00
b08eb21794 deps: bump unsigned-varint from 0.7.1 to 0.7.2
Pull-Request: #4480.
2023-09-11 11:54:37 +00:00
7a94dd820a deps: bump bytes from 1.4.0 to 1.5.0
Pull-Request: #4476.
2023-09-11 09:36:26 +00:00
cd32435d85 fix(ping): honor ping interval in case of errors
This PR adds a delay to ping connection handler after exceeding the failure rate to prevent opening a outbound stream right after an error.

Resolves #4410.

Pull-Request: #4423.
2023-09-09 09:37:25 +00:00
0cc4881740 deps: bump thiserror from 1.0.44 to 1.0.48
Pull-Request: #4430.
2023-09-04 10:23:24 +00:00
c1bccd5c1c deps: bump base64 from 0.21.2 to 0.21.3
Pull-Request: #4401.
2023-09-04 09:43:13 +00:00
50b8b637cf deps: bump trust-dns-proto from 0.22.0 to 0.23.0
On https://github.com/libp2p/rust-libp2p/pull/3102 we left the `tokio-runtime` feature because of https://github.com/bluejekyll/trust-dns/issues/1830, meanwhile https://github.com/bluejekyll/trust-dns/pull/1831 was merged and `0.23.0` was released with it, so we no longer require the `tokio-runtime` feature.

Pull-Request: #4418.
2023-09-04 06:57:49 +00:00
82e654c8a4 deps: bump regex from 1.9.3 to 1.9.5
Pull-Request: #4433.
2023-09-04 04:57:13 +00:00
06bc6777a1 chore: fix lint warnings introduced by beta clippy
Pull-Request: #4386.
2023-08-24 12:27:42 +00:00
eb83367430 deps: bump clap from 4.3.21 to 4.3.23
Pull-Request: #4359.
2023-08-21 09:37:15 +00:00
76797f8ad0 deps: bump tokio from 1.31.0 to 1.32.0
Pull-Request: #4356.
2023-08-21 09:16:26 +00:00
608e2dbb19 deps: bump serde_json from 1.0.104 to 1.0.105
Pull-Request: #4347.
2023-08-19 22:41:44 +00:00
16b2f1563d chore: use workspace rust-version
Pull-Request: #4344.
2023-08-18 09:02:22 +00:00
2c4c961d69 deps: bump log from 0.4.19 to 0.4.20
Pull-Request: #4322.
2023-08-14 10:16:13 +00:00
8022769daf deps: bump clap from 4.3.19 to 4.3.21
Pull-Request: #4319.
2023-08-14 09:20:07 +00:00
a4b8ff4673 deps: bump tokio from 1.29.1 to 1.31.0
Pull-Request: #4318.
2023-08-14 09:00:31 +00:00
5a8eb793fe chore: prepare libp2p v0.52.2
Pull-Request: #4312.
2023-08-11 10:10:42 +00:00
e65155281e fix(kad): reduce noise of "remote supports our protocol" log
This PR changes the logging of the Kademlia connection handler related to the remote Kademlia mode changes:
- Downgrade log level for the remote kademlia protocol report from `info` to `debug`.
- Introduce connection_id for the handler to improve logging.

Pull-Request: #4278.
2023-08-07 09:31:15 +00:00
1278161603 deps: bump regex from 1.9.1 to 1.9.3
Pull-Request: #4295.
2023-08-07 08:35:57 +00:00
f95f39f634 feat(gossipsub): add getter function to obtain TopicScoreParams
Added a getter function to obtain `TopicScoreParams`. I need this function for testing which checks if scoring parameters are updated as expected.

Pull-Request: #4231.
2023-08-03 15:19:25 +00:00
cb8a92026a deps(yamux): update yamux to v0.12
Pull-Request: #3013.
2023-08-02 15:02:54 +00:00
37d57f41de fix(relay): remove unconditional async-std dependency
`libp2p-relay` crate specifies the `libp2p-swarm/async-std` feature, which causes an `async-std` dependency to always be introduced.

Pull-Request: #4283.
2023-08-02 13:46:27 +00:00
4d637aedb7 docs: fix last OutboundQueryCompleted in kad doc
`OutboundQueryCompleted` hasn't been fully replaced by `OutboundQueryProgressed` in kad doc.

Pull-Request: #4257.
2023-08-02 10:43:37 +00:00
23d7d1a247 feat(kad): implement common traits on RoutingUpdate
A few weeks ago when I was debugging my wrong setup with kademlia, I could not conveniently debug `RoutingUpdate` after adding an address to the DHT. It would be nice to have a few derivable traits on a public enum.

Pull-Request: #4270.
2023-07-31 14:23:45 +00:00
8ff2cf3a37 fix(relay): export RateLimiter type
The `rate-limiter` module  was not made publicly available. This change exports the `RateLimiter` trait defined within that module which allows users to define their own rate limiters. To make common usecases easy, we also provide a set of constructor functions for common rate limiters.

Resolves #3741.

Pull-Request: #3742.
2023-07-31 13:58:20 +00:00
cf3cff147c fix(kad): prevent simultaneous dials to peer
By default, dialing is prevented when already connected. `kad` already checks this manually before doing dials. By changing the condition from `Disconnected` to `NotDialing`, we prevent simultaneous dials to a peer.

Pull-Request: #4224.
2023-07-24 17:06:48 +00:00