Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(upnp): add implementation based on IGD protocol #4156

Merged
merged 66 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
bddebad
feat(protocols): Add initial UPnP protocol
jxs Jul 3, 2023
ba6ad5a
cargo clippy
jxs Jul 4, 2023
3638fd9
fix docs
jxs Jul 4, 2023
6671af3
review: address Thomas review
jxs Jul 4, 2023
7edc88b
review: address Thomas review
jxs Jul 5, 2023
5c59216
review: address Thomas review
jxs Jul 5, 2023
cb2dbbc
update copyright
jxs Jul 6, 2023
4172755
rename Provider trait to Gateway
jxs Jul 6, 2023
6fc4cfc
replace UnoderedFutures on the main behaviour
jxs Jul 6, 2023
0eb75da
update Cargo.toml formatting
jxs Jul 7, 2023
3f3f745
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Jul 7, 2023
7d679c8
revert Box<dyn Error> to String conversion.
jxs Jul 8, 2023
28e0fde
clippy
jxs Jul 8, 2023
bdb0818
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Jul 10, 2023
293133b
address Thomas and Max review
jxs Jul 10, 2023
a6b170f
convert Gateway back into Provider and make it a message interface
jxs Jul 11, 2023
96e3a44
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Jul 11, 2023
72eec83
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Jul 14, 2023
e24cc16
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Jul 24, 2023
b0f8f7a
refactor behaviour to reduce the amount of code
jxs Jul 25, 2023
4a90a78
update provider to handle tasks sequentially instead of concurrently
jxs Jul 25, 2023
f2207b6
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Jul 25, 2023
960a50e
switch to idg-next ,
jxs Jul 26, 2023
1874193
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Jul 27, 2023
92f5cea
add Changelog entries
jxs Jul 28, 2023
0b326bd
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Jul 28, 2023
5384ae6
update Cargo.lock
jxs Jul 28, 2023
7398842
fix docs
jxs Jul 28, 2023
e106ad9
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Jul 29, 2023
ac78e67
update multiaddr_to_socketaddr_protocol,
jxs Jul 29, 2023
13f3e74
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Jul 31, 2023
3843453
clippy
jxs Jul 31, 2023
27b2442
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Jul 31, 2023
5b3b905
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Jul 31, 2023
97129b6
downgrade time and pin to 0.3.23
jxs Jul 31, 2023
b1affdd
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Jul 31, 2023
2a0a757
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Aug 1, 2023
550c248
publicly export upnp::Event
jxs Aug 1, 2023
82cfe2a
add upnp-example
jxs Aug 1, 2023
b599faf
address Thomas review
jxs Aug 2, 2023
f3e0fe8
check if the Gateway's external addres is public
jxs Aug 2, 2023
50d6d4e
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Aug 2, 2023
d5c2e82
cargo clippy
jxs Aug 3, 2023
1a81c76
fix docs
jxs Aug 3, 2023
502ec30
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Aug 7, 2023
eb54f3a
address review
jxs Aug 7, 2023
3216093
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Aug 22, 2023
d631d3a
remove config
jxs Aug 26, 2023
fe3c94f
fix examples and feature flags
jxs Aug 26, 2023
98d00de
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Aug 26, 2023
ef6fd56
use SearchOptions::default
jxs Aug 26, 2023
e480e61
feature gate everything
jxs Aug 27, 2023
029eaf6
address review
jxs Aug 31, 2023
194c792
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Aug 31, 2023
e9b5cd6
do not do io on the behaviour,
jxs Sep 1, 2023
7c8c534
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Sep 4, 2023
e5cb61d
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Sep 5, 2023
316b524
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Sep 6, 2023
ebc4fdb
replace example with tokio
jxs Sep 6, 2023
98ba415
Merge branch 'master' of github.com:libp2p/rust-libp2p into add-upnp-…
jxs Sep 6, 2023
b642cd9
deprecate async-std support
jxs Sep 7, 2023
4c18dab
address review
jxs Sep 8, 2023
1de13e8
address missing remark on review
jxs Sep 8, 2023
4b68a48
add publish false to overcome cargo semver
jxs Sep 11, 2023
98108f7
Merge branch 'master' into add-upnp-protocol
jxs Sep 12, 2023
1a36609
Merge branch 'master' into add-upnp-protocol
mergify[bot] Sep 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,110 changes: 836 additions & 274 deletions Cargo.lock
jxs marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ members = [
"protocols/relay",
"protocols/rendezvous",
"protocols/request-response",
"protocols/upnp",
"swarm",
"swarm-derive",
"swarm-test",
Expand Down Expand Up @@ -87,6 +88,7 @@ libp2p-quic = { version = "0.8.0-alpha", path = "transports/quic" }
libp2p-relay = { version = "0.16.0", path = "protocols/relay" }
libp2p-rendezvous = { version = "0.13.0", path = "protocols/rendezvous" }
libp2p-request-response = { version = "0.25.0", path = "protocols/request-response" }
libp2p-upnp = { version = "0.1.0", path = "protocols/upnp" }
libp2p-swarm = { version = "0.43.0", path = "swarm" }
libp2p-swarm-derive = { version = "0.33.0", path = "swarm-derive" }
libp2p-swarm-test = { version = "0.2.0", path = "swarm-test" }
Expand Down
8 changes: 6 additions & 2 deletions libp2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ full = [
"websocket",
"webtransport-websys",
"yamux",
"upnp"
]

async-std = ["libp2p-swarm/async-std", "libp2p-mdns?/async-io", "libp2p-tcp?/async-io", "libp2p-dns?/async-std"]
async-std = ["libp2p-swarm/async-std", "libp2p-mdns?/async-io", "libp2p-tcp?/async-io",
"libp2p-dns?/async-std", "libp2p-upnp?/async-std"]
autonat = ["dep:libp2p-autonat"]
cbor = ["libp2p-request-response?/cbor"]
dcutr = ["dep:libp2p-dcutr", "libp2p-metrics?/dcutr"]
Expand All @@ -76,14 +78,15 @@ secp256k1 = ["libp2p-identity/secp256k1"]
serde = ["libp2p-core/serde", "libp2p-kad?/serde", "libp2p-gossipsub?/serde"]
tcp = ["dep:libp2p-tcp"]
tls = ["dep:libp2p-tls"]
tokio = ["libp2p-swarm/tokio", "libp2p-mdns?/tokio", "libp2p-tcp?/tokio", "libp2p-dns?/tokio"]
tokio = ["libp2p-swarm/tokio", "libp2p-mdns?/tokio", "libp2p-tcp?/tokio", "libp2p-dns?/tokio", "libp2p-upnp?/tokio"]
uds = ["dep:libp2p-uds"]
wasm-bindgen = ["futures-timer/wasm-bindgen", "instant/wasm-bindgen", "getrandom/js", "libp2p-swarm/wasm-bindgen", "libp2p-gossipsub?/wasm-bindgen"]
wasm-ext = ["dep:libp2p-wasm-ext"]
wasm-ext-websocket = ["wasm-ext", "libp2p-wasm-ext?/websocket"]
websocket = ["dep:libp2p-websocket"]
webtransport-websys = ["dep:libp2p-webtransport-websys"]
yamux = ["dep:libp2p-yamux"]
upnp = ["dep:libp2p-upnp"]

[dependencies]
bytes = "1"
Expand Down Expand Up @@ -125,6 +128,7 @@ libp2p-mdns = { workspace = true, optional = true }
libp2p-tcp = { workspace = true, optional = true }
libp2p-tls = { workspace = true, optional = true }
libp2p-uds = { workspace = true, optional = true }
libp2p-upnp = { workspace = true, optional = true }
libp2p-websocket = { workspace = true, optional = true }

[dev-dependencies]
Expand Down
4 changes: 4 additions & 0 deletions libp2p/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ pub use libp2p_tls as tls;
#[cfg(not(target_arch = "wasm32"))]
#[doc(inline)]
pub use libp2p_uds as uds;
#[cfg(feature = "upnp")]
#[cfg(not(target_arch = "wasm32"))]
#[doc(inline)]
pub use libp2p_upnp as upnp;
#[cfg(feature = "wasm-ext")]
#[doc(inline)]
pub use libp2p_wasm_ext as wasm_ext;
Expand Down
28 changes: 28 additions & 0 deletions protocols/upnp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "libp2p-upnp"
edition = "2021"
rust-version = "1.60.0"
description = "UPnP support for libp2p transports"
version = "0.1.0"
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"]

thomaseizinger marked this conversation as resolved.
Show resolved Hide resolved
[dependencies]
async-trait = "0.1.68"
futures = "0.3.28"
futures-timer = "3.0.2"
igd = { version = "0.12.1", optional = true, features = ["aio"] }
igd_async_std = { version = "0.12.4", optional = true, features = ["aio"] }
jxs marked this conversation as resolved.
Show resolved Hide resolved
libp2p-core = { workspace = true }
libp2p-swarm = { workspace = true }
log = "0.4.19"
void = "1.0.2"
tokio = { version = "1.29", default-features = false, features = ["rt", "rt-multi-thread"], optional = true }
thomaseizinger marked this conversation as resolved.
Show resolved Hide resolved
async-std = { version = "1.12.0"}
mxinden marked this conversation as resolved.
Show resolved Hide resolved

[features]
tokio = ["dep:igd", "dep:tokio"]
async-std = ["dep:igd_async_std"]

Loading