mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-04-30 13:12:15 +00:00
Introduce the new `libp2p::SwarmBuilder`. Users should use the new `libp2p::SwarmBuilder` instead of the now deprecated `libp2p::swarm::SwarmBuilder`. See `libp2p::SwarmBuilder` docs on how to use the new builder. Fixes #3657. Fixes #3563. Fixes #3179. Pull-Request: #4120.
Description
The upnp example showcases how to use the upnp network behaviour to externally open ports on the network gateway.
Usage
To run the example, follow these steps:
-
In a terminal window, run the following command:
cargo run
-
This command will start the swarm and print the
NewExternalAddr
if the gateway supportsUPnP
orGatewayNotFound
if it doesn't.
Conclusion
The upnp example demonstrates the usage of libp2p to externally open a port on the gateway if it
supports UPnP
.