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

transports/quic: Add implementation based on quinn-proto #2289

Merged
merged 260 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
260 commits
Select commit Hold shift + click to select a range
f760494
Use std HashMap instead of fnv's
kpp Sep 8, 2021
9a88cf2
Remove ToLibp2p to_keypair
kpp Sep 8, 2021
35ac0fb
Move iovs init into a separate function
kpp Sep 9, 2021
d665212
Use mem::replace to unbind recv_buf
kpp Sep 11, 2021
ee7a7f5
Update transports/quic/src/endpoint.rs
dvc94ch Sep 11, 2021
aee258c
Merge master (#18)
kpp Sep 14, 2021
314e1c5
Merge branch 'master' into libp2p-quic
dvc94ch Sep 14, 2021
9b36bc1
Update transports/quic/src/transport.rs
dvc94ch Oct 2, 2021
7c33cdc
Add David's credentials to quic/src headers
kpp Oct 14, 2021
da60d1f
Merge branch 'master' into libp2p-quic
kpp Oct 14, 2021
4e94add
Merge branch 'master' into libp2p-quic
kpp Oct 14, 2021
d889fb1
Merge branch 'master' into libp2p-quic
kpp Oct 21, 2021
af73d98
Mirror quic features in the root Cargo.toml
kpp Oct 21, 2021
1e0078c
Fix tests after merging master
kpp Oct 21, 2021
b30ae08
Fix TLS 1.2 error msg
kpp Oct 25, 2021
9f11c30
Expect substreams when accessing by id in the inner struct
kpp Oct 26, 2021
9425cc5
Comment out _max_datagrams
kpp Oct 26, 2021
25ee1fe
Cut off noise crypto
kpp Nov 9, 2021
f35fde1
Remove generic crypto code
kpp Nov 9, 2021
8844e7c
Merge branch 'master' into libp2p-quic
kpp Nov 9, 2021
756f2e7
Apply cargo fmt
kpp Nov 9, 2021
3b1ff34
Don't require remote PK to dial a peer
kpp Nov 11, 2021
e51fd82
Merge branch 'master' into libp2p-quic
kpp Dec 13, 2021
63e4696
- Get rid of barebones-x509
kpp Dec 14, 2021
2ea0ae7
Add tests for x509 parser
kpp Dec 15, 2021
0e8e5b5
Upgrade quinn-proto, rustls, webpki
kpp Dec 15, 2021
f5236a8
Fix fmt
kpp Dec 15, 2021
24b47b3
Check that generated certs are parsed but not valid
kpp Dec 15, 2021
b92a660
Add idle timeout for smoke tests
kpp Dec 15, 2021
4a317df
Replace everything with old code
kpp Feb 2, 2022
d8aa2f3
Fix deps
kpp Feb 2, 2022
99439ca
Fix tests
kpp Feb 3, 2022
35e6766
Add Connection::remote_peer_id to extract peer_id
kpp Feb 3, 2022
15aa70b
Remove Connection::next_incoming in favor of poll_incoming
kpp Feb 3, 2022
154b73d
Add connection::local_addr to report it in ListenerEvent::Upgrade
kpp Feb 7, 2022
8bfcca2
tmp: Swarm pool size = 1
kpp Feb 15, 2022
a3fea03
Merge branch 'master' into libp2p-quic
kpp Feb 15, 2022
3089512
Tmp commit
kpp Feb 15, 2022
f7e52d0
Fix InAddr::One to produce event only once, move InAddr into a separa…
kpp Feb 15, 2022
3bdcb4a
Add more logs
kpp Feb 26, 2022
86c4129
Fixing disconnects
kpp Apr 6, 2022
4c4c5f3
close muxer from the client side
kpp Apr 6, 2022
78219ce
Merge branch 'libp2p-quic' into libp2p-quic-reimplementation
kpp Apr 6, 2022
ebaf5ac
cargo fmt
kpp Apr 6, 2022
d6228ca
Prettify code and get rid of tracings
kpp Apr 7, 2022
728c2ba
cargo fmt
kpp Apr 7, 2022
deca16a
retrict concurrent_connections_and_streams to 3:8 params
kpp Apr 7, 2022
8cdc476
Polish the code
kpp May 9, 2022
13eea61
Merge pull request #14 from kpp/libp2p-quic-reimplementation
kpp May 9, 2022
6bd3041
Remove old comments
kpp May 11, 2022
5674ae4
Merge libp2p 0.44.0
kpp May 11, 2022
af909b1
Fix smoke test
kpp May 11, 2022
ce03449
Fix several warnings
kpp May 18, 2022
b2a34e4
Remove tmp change in swarm pool_size
kpp Jun 8, 2022
38c2fd5
Set libp2p-quic to v0.7
kpp Jun 8, 2022
ef8decf
Remove old comments
kpp Jun 8, 2022
e55c0cf
Simplify the code in timeout system
kpp Jun 8, 2022
e937ce6
Remove additional recursion_limit
kpp Jun 8, 2022
5d6e336
Merge branch 'master' into libp2p-quic-0.46
kpp Jun 21, 2022
ffafd49
Fix upgrade bugs
kpp Jun 21, 2022
772162b
cargo fmt
kpp Jun 22, 2022
4851552
Fix intradocs
kpp Jun 22, 2022
c4c07a2
Fix intradocs
kpp Jun 22, 2022
73d4ea6
Merge pull request #15 from kpp/libp2p-quic-0.46
kpp Jun 22, 2022
def0a38
Merge branch 'master' into libp2p-quic
kpp Jun 22, 2022
66ed300
Merge commit 'eb490c08e9ebd1c4' into quic-async-muxer
kpp Jul 7, 2022
cb92ae5
Impl AsyncRead/AsyncWrite for Substream
kpp Jul 7, 2022
8aff243
Merge pull request #18 from kpp/quic-async-muxer
kpp Jul 7, 2022
6b758e3
Merge branch 'master' of github.com:libp2p/rust-libp2p into quic/mult…
elenaf9 Jul 10, 2022
5157ea1
transports/quic: adapt to transport trait changes
elenaf9 Jun 27, 2022
57743ef
transports/quic: support multiple listening endpoints
elenaf9 Jul 4, 2022
e5e5b34
transports/quic: re-use endpoints for dialing
elenaf9 Jul 4, 2022
39d855c
transports/quic: test endpoint re-use
elenaf9 Jul 4, 2022
0e797cf
transports/quic: use intra-doc links in docs
elenaf9 Jul 10, 2022
ef7b823
transports/quic: remove mutex in `InAddr`
elenaf9 Jul 10, 2022
a375524
transports/quic: fix clippy
elenaf9 Jul 10, 2022
917bccc
transport/quic: add test for closing a listener
elenaf9 Jul 10, 2022
5fe3e1c
Add an ignored test to dial ipv6 from ipv4
kpp Jul 21, 2022
574d534
Get rid of recursion in poll_if_addr
kpp Jul 21, 2022
9e1cc81
cargo fmt
kpp Jul 22, 2022
2c41f70
Merge pull request #5 from kpp/kpp-multiple-endpoints
elenaf9 Jul 22, 2022
1a4b8ac
quic: match socket family of endpoint for dialing
elenaf9 Jul 23, 2022
bf06d96
quic: fix outdated docs & intra-doc links
elenaf9 Jul 23, 2022
7019d49
Merge branch 'master' of github.com:libp2p/rust-libp2p into quic/mult…
elenaf9 Jul 31, 2022
07c0dba
Merge branch 'master' of github.com:libp2p/rust-libp2p into quic/muxer
elenaf9 Aug 3, 2022
57840a3
transports/quic: adapt QuicMuxer to libp2p#2724
elenaf9 Aug 3, 2022
3ce0ef9
transports/quic: apply suggestions from review
elenaf9 Aug 13, 2022
3060d12
transports/quic: rename QuicMuxerInner -> Inner
elenaf9 Aug 13, 2022
63c6edc
transports/quic: improve poll_{inbound, outbound}
elenaf9 Aug 13, 2022
1aeaba3
Merge branch 'master' of github.com:libp2p/rust-libp2p into quic/muxer
elenaf9 Aug 19, 2022
95fc6da
transports/quic: drive connection in `QuicMuxer::poll`
elenaf9 Aug 19, 2022
0d7c8a5
transports/quic: refactor `Connection::poll_event`
elenaf9 Aug 21, 2022
67b52aa
transports/quic: rm `Connection::is_handshaking`
elenaf9 Aug 21, 2022
66974fc
transports/quic: refactor connection closing
elenaf9 Aug 22, 2022
c88efe8
transports/quic: rm mutex around to_endpoint tx
elenaf9 Aug 22, 2022
0a82be4
transports/quic/tests: drive peers concurrently
elenaf9 Aug 22, 2022
e0684ab
Merge pull request #19 from elenaf9/quic/multiple-endpoints-2
kpp Aug 27, 2022
69caf98
Merge branch 'master' of github.com:libp2p/rust-libp2p into quic/muxer
elenaf9 Sep 9, 2022
fe3e09b
transports/quic: upgrade to if-watch v2.0.0
elenaf9 Sep 9, 2022
b6924db
transports/quic: fix clippy
elenaf9 Sep 9, 2022
689460f
transports/quic: fix smoke test
elenaf9 Sep 9, 2022
41d39fb
transports/quic: add `Endpoint::try_send`
elenaf9 Sep 10, 2022
4c617a0
subscribe
elenaf9 Sep 17, 2022
4e027b1
transports/quic: handle substream being dropped
elenaf9 Sep 19, 2022
bdba780
transports/quic: return err on read after reset
elenaf9 Sep 19, 2022
40cb4f3
transports/quic: apply comments from code review
elenaf9 Sep 19, 2022
f8d1430
transports/quic: better naming, fix docs
elenaf9 Sep 20, 2022
4c3229b
transports/quic: add doc for `Endpoint:try_send`
elenaf9 Sep 20, 2022
e393fe5
transports/quic: add `ip_to_listenaddr`
elenaf9 Sep 20, 2022
d28db18
transports/quic: disable connection migration
elenaf9 Sep 20, 2022
42db0ed
transports/quic: minor fix
elenaf9 Sep 20, 2022
d46b72e
transports/quic: minor fixes
elenaf9 Sep 20, 2022
ec3c74a
transports/quic: rework forwarding of new connections
elenaf9 Sep 20, 2022
b7103aa
transports/quic: fix broken intra-doc link
elenaf9 Sep 20, 2022
7f902b4
Merge pull request #23 from elenaf9/quic/muxer
kpp Sep 22, 2022
9df25f1
transports/quic: apply suggestions from review
elenaf9 Sep 21, 2022
68294cc
Merge branch 'master' of github.com:libp2p/rust-libp2p into libp2p-quic
elenaf9 Sep 22, 2022
0aba584
Use FQN instead of renaming import
thomaseizinger Sep 23, 2022
78a7566
Import functions that are used multiple times
thomaseizinger Sep 23, 2022
edf3f36
Favor `?` over `map` and `and_then`
thomaseizinger Sep 23, 2022
eea474d
Favor early return over `if let Some`
thomaseizinger Sep 23, 2022
40b600d
Fix new clippy lint
thomaseizinger Sep 23, 2022
c5fc181
transports/quic: abstract runtime
elenaf9 Sep 27, 2022
0a27006
Merge branch 'master' of github.com:libp2p/rust-libp2p into libp2p-quic
elenaf9 Sep 27, 2022
df8de30
transports/quic: minor fixes
elenaf9 Sep 28, 2022
6dfe97a
transports/quic: introduce EndpointDriver
elenaf9 Sep 28, 2022
43dbf45
transports/quic: clean error types
elenaf9 Sep 28, 2022
ba8675d
lib.rs: fix quic re-export
elenaf9 Sep 28, 2022
d7259ff
transports/quic: fix intra-doc-links
elenaf9 Sep 28, 2022
db25b27
transports/quic: fmt, fix clippy
elenaf9 Sep 28, 2022
c1c0448
transports/quic: mark version as alpha
elenaf9 Sep 30, 2022
5fb7369
transports/quic: apply suggestions from code review
elenaf9 Sep 30, 2022
7162821
Merge branch 'master' of github.com:libp2p/rust-libp2p into libp2p-quic
elenaf9 Oct 1, 2022
b3b8b33
transport/quic/tests: unwrap results, rm anyhow
elenaf9 Sep 30, 2022
a91894d
transport/quic: suggestions from code-review
elenaf9 Sep 30, 2022
916d323
transport/quic/test: remove tracing
elenaf9 Oct 1, 2022
2b80d05
transports/quic: use `log` instead of `tracing`
elenaf9 Oct 1, 2022
a3ed858
transports/quic: fix intra-doc-link
elenaf9 Oct 1, 2022
ebc2c9a
transport/quic: Remove default feature
elenaf9 Oct 3, 2022
dcf6198
transports/quic: poll-based Provider interface
elenaf9 Oct 2, 2022
aff6c99
transports/quic: suggestions from code review
elenaf9 Oct 4, 2022
4d0d143
transports/quic: handle connection dropped
elenaf9 Oct 4, 2022
bcd0718
transports/quic: remove outdated comments
elenaf9 Oct 4, 2022
85b8bb6
transports/quic: format
elenaf9 Oct 4, 2022
71595d0
transports/quic/Cargo.toml fix authors
elenaf9 Oct 4, 2022
1a7b0ff
transports/quic: handle dropping better
elenaf9 Oct 4, 2022
f2a9ebc
transports/quic: only translate quic addresses
elenaf9 Oct 4, 2022
831383a
Cargo.toml: add "quic-tokio" to feature `full`
elenaf9 Oct 4, 2022
8e729bf
transports/quic: follow naming convention of #2217
elenaf9 Oct 4, 2022
49e359b
transports/quic: rename `Upgrade` -> `Connecting`
elenaf9 Oct 4, 2022
03c4da9
transports/quic: fix intra-doc-links
elenaf9 Oct 4, 2022
ec21fb1
transports/quic: derive `Debug` where possible
elenaf9 Oct 4, 2022
6f284cc
transports/quic: apply suggestions from review
elenaf9 Oct 4, 2022
7c332bb
transports/quic: move provider into own mod
elenaf9 Oct 4, 2022
0b80573
transports/quic: add `SocketFamily` enum
elenaf9 Oct 4, 2022
eafa89e
transports/quic: wake on new pending dial
elenaf9 Oct 4, 2022
112345f
Introduce dedicated `dial` functions
thomaseizinger Oct 4, 2022
7a86e30
Extract dedicated `DialerState`
thomaseizinger Oct 4, 2022
4dbb086
Don't print inner Display of error
thomaseizinger Oct 6, 2022
1d57b69
Merge branch 'master' into libp2p-quic
thomaseizinger Oct 6, 2022
4010be0
Remove unnecessary clone
thomaseizinger Oct 6, 2022
40e4545
Use `Self` to refer to impl type
thomaseizinger Oct 6, 2022
4d2c457
Don't repeat module name in type
thomaseizinger Oct 6, 2022
8693b4e
Call `map_err` inside `new_dial`
thomaseizinger Oct 6, 2022
6d7a8a6
Better name for returned future
thomaseizinger Oct 6, 2022
a43b12d
Better type-safety for disconnected background task
thomaseizinger Oct 6, 2022
1c0e0f1
Fix docs
thomaseizinger Oct 6, 2022
42e58a8
Fix broken intra-doc links
thomaseizinger Oct 6, 2022
716fa16
Update transports/quic/src/endpoint.rs
kpp Oct 6, 2022
2264ab8
transports/quic: expose config params, add handshake timeout
elenaf9 Oct 12, 2022
f121350
transports/quic/tests: use quickcheck
elenaf9 Oct 12, 2022
963d3dd
transports/quic: report PeerId in Connected event
elenaf9 Oct 12, 2022
9e394b3
transports/quic: minor changes on closing logic
elenaf9 Oct 12, 2022
7e48fe4
transports/quic: wake connection on substream write
elenaf9 Oct 12, 2022
fdca477
transports/quic: suggestions from review
elenaf9 Oct 12, 2022
6a7e514
Merge branch 'master' of github.com:libp2p/rust-libp2p into libp2p-quic
elenaf9 Oct 12, 2022
8d3147a
transports/quic: suggestions from code review
elenaf9 Oct 12, 2022
82b6a9d
transports/quic: suggestions from code review
elenaf9 Oct 12, 2022
b89ef33
transport/quic: select listener deterministically
elenaf9 Oct 13, 2022
3fa3e9e
transports/quic: enhance docs
elenaf9 Oct 13, 2022
6430af0
Remove unnecessary `pub` qualifiers of utility functions
thomaseizinger Oct 6, 2022
b77ee8c
Don't repeat protocol name in muxer struct
thomaseizinger Oct 6, 2022
60c2761
Have `new_dial` return a future
thomaseizinger Oct 6, 2022
c0b8a55
transports/quic: add single `Error` for crate
elenaf9 Oct 13, 2022
2eafbe6
transports/quic: test EndpointDriver drop on listener close
elenaf9 Oct 14, 2022
f880d70
transports/quic: fix intra-doc link
elenaf9 Oct 14, 2022
c33d17f
transports/quic: test dialer drop
elenaf9 Oct 14, 2022
1f83766
transports/quic: better debugging statements
elenaf9 Oct 14, 2022
6af1116
transports/quic: improve logic for picking a dialer
elenaf9 Oct 14, 2022
3b0bd06
transports/quic: test dialing wrong PeerId`
elenaf9 Oct 14, 2022
3121a63
Merge branch 'master' of github.com:libp2p/rust-libp2p into libp2p-quic
elenaf9 Oct 14, 2022
a412057
transports/quic: remove deny(unsafe-code) flag
elenaf9 Oct 16, 2022
4325f5c
transports/quic: follow libp2p#2962
elenaf9 Oct 16, 2022
3982a6c
transports/quic: follow libp2p#2983
elenaf9 Oct 16, 2022
8bcf9df
transports/quic: move struct within file
elenaf9 Oct 16, 2022
5da85e7
transports/quic: handle `Inner` in `Connecting`
elenaf9 Oct 16, 2022
6307b8b
quic: return `quinn_proto::Event` in `Connection::poll_event`
elenaf9 Oct 16, 2022
0271539
quic: inline `Connection` into `muxer::Inner`
elenaf9 Oct 16, 2022
d2e2436
quic: rename Muxer -> Connection
elenaf9 Oct 16, 2022
c075dad
quic: move polling logic from Inner to Connection
elenaf9 Oct 16, 2022
954908b
quic: rename Inner -> State
elenaf9 Oct 16, 2022
8034850
quic: submodules for connection
elenaf9 Oct 16, 2022
f146834
*: Prepare v0.49.0 (#2931)
mxinden Oct 14, 2022
6732482
transports/dns/: Don't feature flag std::io import (#3027)
mxinden Oct 14, 2022
1da2732
.github/workflows: Don't allow concurrent workflow runs (#3000)
thomaseizinger Oct 15, 2022
0fc4e64
muxers: Add test harness for `StreamMuxer` implementations (#2952)
thomaseizinger Oct 17, 2022
b51f280
Don't rename crates in manifest
thomaseizinger Oct 17, 2022
9df0980
Merge branch 'master' of github.com:libp2p/rust-libp2p into libp2p-quic
elenaf9 Oct 20, 2022
4cad080
quic: add config max_data and max_stream_data
elenaf9 Oct 20, 2022
445a2a4
quic: assert that we only drop datagram events
elenaf9 Oct 20, 2022
70cc694
quic/connection: make internal fns private
elenaf9 Oct 20, 2022
a38f0e9
quic/substream: break read early if buf is empty
elenaf9 Oct 20, 2022
3725f5f
quic/substream: fix comment
elenaf9 Oct 20, 2022
4b3d35e
quic: continue read from socket if write is busy
elenaf9 Oct 22, 2022
bbe736f
quic/endpoint: unify channel capacity
elenaf9 Oct 23, 2022
c8b794a
quic: fix docs
elenaf9 Oct 23, 2022
f97b849
Merge branch 'master' of github.com:libp2p/rust-libp2p into libp2p-quic
elenaf9 Oct 23, 2022
f24443d
Merge branch 'master' into libp2p-quic
thomaseizinger Oct 24, 2022
e099867
Update to use `libp2p_tls`
thomaseizinger Oct 24, 2022
eb1b2cd
quic: finalize read chunks before return error
elenaf9 Oct 24, 2022
55ccdb3
quic: improve logs
elenaf9 Oct 24, 2022
a69f95f
Merge branch 'master' into libp2p-quic
kpp Oct 28, 2022
da2a6db
quic: revert 4010be0
elenaf9 Oct 28, 2022
c17df6d
quic: stricter `is_quic_addr` check
elenaf9 Oct 28, 2022
58c3f67
quic/tests: add `tcp_and_quic` test
elenaf9 Oct 28, 2022
d0e4cd7
Remove unnecessary `async`
thomaseizinger Nov 1, 2022
49134fb
Don't fail inside `AsyncWrite::close`
thomaseizinger Nov 1, 2022
8c50c9b
Add muxer compliance test suite for QUIC
thomaseizinger Nov 1, 2022
6fb98a2
Migrate tests away from `Swarm`
thomaseizinger Nov 1, 2022
859a3b9
Move utilities to the bottom
thomaseizinger Nov 2, 2022
9b95c31
Merge branch 'master' into libp2p-quic
kpp Nov 5, 2022
6833b91
Add timeout to concurrency test
thomaseizinger Nov 10, 2022
f2c390d
Change note
thomaseizinger Nov 10, 2022
0fadf35
Fix missing feature
thomaseizinger Nov 10, 2022
aa768f7
Run tests with default config
thomaseizinger Nov 11, 2022
eb9bfb6
Merge pull request #27 from libp2p/rework-tests
kpp Nov 11, 2022
1feb629
quic: fix test_dialer_drop test
elenaf9 Nov 12, 2022
a7acce4
quic: update to quinn-protov0.9
elenaf9 Nov 12, 2022
20c3fce
quic: clean dependencies
elenaf9 Nov 12, 2022
bea79a8
quic: make clippy happy
elenaf9 Nov 12, 2022
0ab672a
quic/tests: remove `dialer_can_receive` test
elenaf9 Nov 12, 2022
4b042b2
quic: Update to if-watchv3.0.0
elenaf9 Nov 12, 2022
7770943
quic: rm debug_assert(!is_closed) on new connection
elenaf9 Nov 12, 2022
e3c955c
quic/connection: send to endpoint before receiving
elenaf9 Nov 12, 2022
56e39b8
quic: Add initial release entry to CHANGELOG
elenaf9 Nov 12, 2022
1b5741e
Merge branch 'master' of github.com:libp2p/rust-libp2p into libp2p-quic
elenaf9 Nov 12, 2022
cd7f38f
quic: Add entry to libp2p CHANGELOG
elenaf9 Nov 12, 2022
588b76e
Merge branch 'master' of github.com:libp2p/rust-libp2p into libp2p-quic
elenaf9 Nov 13, 2022
b14516a
quic: Use `quic-v1` codepoint
elenaf9 Nov 13, 2022
5ac7e54
Merge branch 'master' into libp2p-quic
elenaf9 Nov 14, 2022
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
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ default = [
"deflate",
"dns-async-std",
"floodsub",
"gossipsub",
"identify",
"kad",
"gossipsub",
"mdns",
"mplex",
"noise",
"ping",
"plaintext",
"pnet",
"quic",
"relay",
"request-response",
"rendezvous",
Expand All @@ -37,16 +38,17 @@ deflate = ["libp2p-deflate"]
dns-async-std = ["libp2p-dns", "libp2p-dns/async-std"]
dns-tokio = ["libp2p-dns", "libp2p-dns/tokio"]
floodsub = ["libp2p-floodsub"]
gossipsub = ["libp2p-gossipsub"]
identify = ["libp2p-identify", "libp2p-metrics/identify"]
kad = ["libp2p-kad", "libp2p-metrics/kad"]
gossipsub = ["libp2p-gossipsub"]
metrics = ["libp2p-metrics"]
mdns = ["libp2p-mdns"]
mplex = ["libp2p-mplex"]
noise = ["libp2p-noise"]
ping = ["libp2p-ping", "libp2p-metrics/ping"]
plaintext = ["libp2p-plaintext"]
pnet = ["libp2p-pnet"]
quic = ["libp2p-quic"]
relay = ["libp2p-relay"]
request-response = ["libp2p-request-response"]
rendezvous = ["libp2p-rendezvous"]
Expand Down Expand Up @@ -97,6 +99,7 @@ wasm-timer = "0.2.4"
libp2p-deflate = { version = "0.30.0", path = "transports/deflate", optional = true }
libp2p-dns = { version = "0.30.0", path = "transports/dns", optional = true, default-features = false }
libp2p-mdns = { version = "0.32.0", path = "protocols/mdns", optional = true }
libp2p-quic = { version = "0.6.0", path = "transports/quic", optional = true }
libp2p-tcp = { version = "0.30.0", path = "transports/tcp", default-features = false, optional = true }
libp2p-websocket = { version = "0.31.0", path = "transports/websocket", optional = true }

Expand Down Expand Up @@ -132,6 +135,7 @@ members = [
"transports/noise",
"transports/plaintext",
"transports/pnet",
"transports/quic",
"transports/tcp",
"transports/uds",
"transports/websocket",
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ pub use libp2p_plaintext as plaintext;
#[cfg_attr(docsrs, doc(cfg(feature = "pnet")))]
#[doc(inline)]
pub use libp2p_pnet as pnet;
#[cfg(feature = "quic")]
#[cfg_attr(docsrs, doc(cfg(feature = "quic")))]
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
#[doc(inline)]
pub use libp2p_quic as quic;
#[cfg(feature = "relay")]
#[cfg_attr(docsrs, doc(cfg(feature = "relay")))]
#[doc(inline)]
Expand Down
45 changes: 45 additions & 0 deletions transports/quic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[package]
name = "libp2p-quic"
version = "0.6.0"
kpp marked this conversation as resolved.
Show resolved Hide resolved
authors = ["David Craven <[email protected]>", "Parity Technologies <[email protected]>"]
elenaf9 marked this conversation as resolved.
Show resolved Hide resolved
edition = "2018"
description = "TLS and Noise based QUIC transport implementation for libp2p"
repository = "https://github.com/libp2p/rust-libp2p"
license = "MIT"

[features]
kpp marked this conversation as resolved.
Show resolved Hide resolved
noise = ["quinn-noise", "ed25519-dalek"]
tls = ["barebones-x509", "quinn-proto/tls-rustls", "rcgen", "ring", "rustls", "untrusted", "webpki", "yasna"]

[dependencies]
async-global-executor = "2.0.2"
async-io = "1.6.0"
barebones-x509 = { version = "0.5.0", optional = true, features = ["webpki", "rustls", "std"] }
bytes = "1.0.1"
ed25519-dalek = { version = "1.0.1", optional = true }
futures = "0.3.15"
if-watch = "0.2.2"
libp2p-core = { version = "0.30.0", path = "../../core" }
multihash = { version = "0.14.0", default-features = false }
parking_lot = "0.11.1"
quinn-noise = { version = "0.3.0", optional = true }
quinn-proto = { version = "0.7.3", default-features = false }
rcgen = { version = "0.8.11", optional = true }
ring = { version = "0.16.20", optional = true }
rustls = { version = "0.19.1", optional = true, features = ["dangerous_configuration"] }
thiserror = "1.0.26"
tracing = "0.1.26"
udp-socket = "0.1.5"
untrusted = { version = "0.7.1", optional = true }
webpki = { version = "0.21.4", optional = true, features = ["std"] }
yasna = { version = "0.4.0", optional = true }

[dev-dependencies]
anyhow = "1.0.41"
elenaf9 marked this conversation as resolved.
Show resolved Hide resolved
async-std = { version = "1.9.0", features = ["attributes"] }
async-trait = "0.1.50"
libp2p = { version = "0.40.0", default-features = false, features = ["request-response"], path = "../.." }
log-panics = "2.0.0"
rand = "0.8.4"
rand_core = "0.5.1"
tracing-subscriber = "0.2.19"
219 changes: 219 additions & 0 deletions transports/quic/src/crypto.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
// Copyright 2021 David Craven.
kpp marked this conversation as resolved.
Show resolved Hide resolved
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

use libp2p_core::PeerId;
use quinn_proto::crypto::Session;
use quinn_proto::TransportConfig;
use std::sync::Arc;

pub struct CryptoConfig<C: Crypto> {
pub keypair: C::Keypair,
pub psk: Option<[u8; 32]>,
pub keylogger: Option<C::Keylogger>,
pub transport: Arc<TransportConfig>,
}

#[cfg(feature = "noise")]
trait CloneKeypair {
fn clone_keypair(&self) -> Self;
}

#[cfg(feature = "noise")]
impl CloneKeypair for ed25519_dalek::Keypair {
fn clone_keypair(&self) -> Self {
ed25519_dalek::Keypair::from_bytes(&self.to_bytes()).expect("serde works")
}
}

pub trait ToLibp2p {
fn to_public(&self) -> libp2p_core::identity::PublicKey;
fn to_peer_id(&self) -> PeerId {
self.to_public().to_peer_id()
}
}

#[cfg(feature = "noise")]
impl ToLibp2p for ed25519_dalek::Keypair {
fn to_public(&self) -> libp2p_core::identity::PublicKey {
self.public.to_public()
}
}

#[cfg(feature = "noise")]
impl ToLibp2p for ed25519_dalek::PublicKey {
fn to_public(&self) -> libp2p_core::identity::PublicKey {
let public_key = self.to_bytes();
let public_key =
libp2p_core::identity::ed25519::PublicKey::decode(&public_key[..]).unwrap();
libp2p_core::identity::PublicKey::Ed25519(public_key)
}
}

#[cfg(feature = "tls")]
impl ToLibp2p for libp2p_core::identity::Keypair {
fn to_public(&self) -> libp2p_core::identity::PublicKey {
self.public()
}
}

pub trait Crypto: std::fmt::Debug + Clone + 'static {
type Session: Session + Unpin;
type Keylogger: Send + Sync;
type Keypair: Send + Sync + ToLibp2p;
type PublicKey: Send + std::fmt::Debug + PartialEq<Self::PublicKey>;

fn new_server_config(
config: &Arc<CryptoConfig<Self>>,
) -> <Self::Session as Session>::ServerConfig;
fn new_client_config(
config: &Arc<CryptoConfig<Self>>,
remote_public: Self::PublicKey,
) -> <Self::Session as Session>::ClientConfig;
fn supported_quic_versions() -> Vec<u32>;
fn default_quic_version() -> u32;
fn peer_id(session: &Self::Session) -> Option<PeerId>;
fn extract_public_key(generic_key: libp2p_core::PublicKey) -> Option<Self::PublicKey>;
fn keylogger() -> Self::Keylogger;
}

#[cfg(feature = "noise")]
#[derive(Clone, Copy, Debug)]
pub struct NoiseCrypto;

#[cfg(feature = "noise")]
impl Crypto for NoiseCrypto {
type Session = quinn_noise::NoiseSession;
type Keylogger = Arc<dyn quinn_noise::KeyLog>;
type Keypair = ed25519_dalek::Keypair;
type PublicKey = ed25519_dalek::PublicKey;

fn new_server_config(
config: &Arc<CryptoConfig<Self>>,
) -> <Self::Session as Session>::ServerConfig {
Arc::new(
quinn_noise::NoiseServerConfig {
keypair: config.keypair.clone_keypair(),
psk: config.psk,
keylogger: config.keylogger.clone(),
supported_protocols: vec![b"libp2p".to_vec()],
}
.into(),
)
}

fn new_client_config(
config: &Arc<CryptoConfig<Self>>,
remote_public_key: Self::PublicKey,
) -> <Self::Session as Session>::ClientConfig {
quinn_noise::NoiseClientConfig {
keypair: config.keypair.clone_keypair(),
psk: config.psk,
alpn: b"libp2p".to_vec(),
remote_public_key,
keylogger: config.keylogger.clone(),
}
.into()
}

fn supported_quic_versions() -> Vec<u32> {
quinn_noise::SUPPORTED_QUIC_VERSIONS.to_vec()
}

fn default_quic_version() -> u32 {
quinn_noise::DEFAULT_QUIC_VERSION
}

fn peer_id(session: &Self::Session) -> Option<PeerId> {
Some(session.peer_identity()?.to_peer_id())
}

fn extract_public_key(generic_key: libp2p_core::PublicKey) -> Option<Self::PublicKey> {
let public_key = if let libp2p_core::PublicKey::Ed25519(public_key) = generic_key {
public_key.encode()
} else {
return None;
};
Self::PublicKey::from_bytes(&public_key).ok()
}

fn keylogger() -> Self::Keylogger {
Arc::new(quinn_noise::KeyLogFile::new())
}
}

#[cfg(feature = "tls")]
#[derive(Clone, Copy, Debug)]
pub struct TlsCrypto;

#[cfg(feature = "tls")]
impl Crypto for TlsCrypto {
type Session = quinn_proto::crypto::rustls::TlsSession;
type Keylogger = Arc<dyn rustls::KeyLog>;
type Keypair = libp2p_core::identity::Keypair;
type PublicKey = libp2p_core::identity::PublicKey;

fn new_server_config(
config: &Arc<CryptoConfig<Self>>,
) -> <Self::Session as Session>::ServerConfig {
assert!(config.psk.is_none(), "invalid config");
let mut server = crate::tls::make_server_config(&config.keypair).expect("invalid config");
if let Some(key_log) = config.keylogger.clone() {
server.key_log = key_log;
}
Arc::new(server)
}

fn new_client_config(
config: &Arc<CryptoConfig<Self>>,
remote_public: Self::PublicKey,
) -> <Self::Session as Session>::ClientConfig {
assert!(config.psk.is_none(), "invalid config");
let mut client =
crate::tls::make_client_config(&config.keypair, remote_public.to_peer_id())
.expect("invalid config");
if let Some(key_log) = config.keylogger.clone() {
client.key_log = key_log;
}
Arc::new(client)
}

fn supported_quic_versions() -> Vec<u32> {
quinn_proto::DEFAULT_SUPPORTED_VERSIONS.to_vec()
}

fn default_quic_version() -> u32 {
quinn_proto::DEFAULT_SUPPORTED_VERSIONS[0]
}

fn peer_id(session: &Self::Session) -> Option<PeerId> {
let certificate = session.get_peer_certificates()?.into_iter().next()?;
Some(crate::tls::extract_peerid_or_panic(
quinn_proto::Certificate::from(certificate).as_der(),
))
}

fn extract_public_key(generic_key: libp2p_core::PublicKey) -> Option<Self::PublicKey> {
Some(generic_key)
}

fn keylogger() -> Self::Keylogger {
Arc::new(rustls::KeyLogFile::new())
}
}
Loading