-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(transports/webrtc-websys): Browser to Browser WebRTC #5978
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
Open
elijahhampton
wants to merge
10
commits into
libp2p:master
Choose a base branch
from
elijahhampton:feat(webrtc)-implement-webrtc-protocol-for-browser-to-browser-communication
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
97e65c7
Implements basic WebRTC signaling process. Establishes a browser tran…
elijahhampton 081b9a8
Removes unwrap() in place of mapping to proper Errors. Adds utility f…
elijahhampton ebcef5a
Draft implementation of circuit relay v2. Integration of circuit rela…
elijahhampton 25601ac
Move browser impl to dedicated folder
elijahhampton da5bb21
Adds relayv2 feature and feature gates circuit relay crate
elijahhampton bd4aa0a
Creates example, removes circuit relay logic, completes dial and rese…
elijahhampton 919a8eb
Fixes errors in signaling, adds example, moves logic from transport …
elijahhampton f1d5b76
Removes unused functions. Restore visibility of vars, fns in /relay
elijahhampton b7fa2b3
Adds signaling config and retry mechanism for the signaling handler.
elijahhampton c31af1b
Adds delay for retries. Adds helper functions to signaling protocol h…
elijahhampton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
[package] | ||
authors = ["Elijah Hampton <[email protected]>"] | ||
categories = ["asynchronous", "network-programming", "wasm", "web-programming"] | ||
description = "Circuit Relay V2 for libp2p under WASM environment" | ||
edition.workspace = true | ||
keywords = ["circuit-relay", "libp2p", "networking", "peer-to-peer"] | ||
license = "MIT" | ||
name = "libp2p-circuit-relay-v2" | ||
repository = "https://github.com/libp2p/rust-libp2p" | ||
rust-version = { workspace = true } | ||
version = "0.1.0" | ||
publish = true | ||
|
||
[build-dependencies] | ||
prost-build = "0.13.5" | ||
|
||
[dependencies] | ||
futures = { workspace = true } | ||
js-sys = { version = "0.3" } | ||
libp2p-core = { workspace = true } | ||
libp2p-webrtc-utils = { workspace = true } | ||
libp2p-tcp = { path = "../../transports/tcp" } | ||
libp2p-relay = { workspace = true } | ||
libp2p-gossipsub = { workspace = true } | ||
thiserror = { workspace = true } | ||
tokio = { workspace = true, features = ["full"] } | ||
tracing = { workspace = true } | ||
wasm-bindgen = { version = "0.2.90" } | ||
wasm-bindgen-futures = { version = "0.4.42" } | ||
web-sys = { version = "0.3.70", features = [ | ||
"RtcPeerConnection", | ||
"RtcConfiguration", | ||
"RtcSessionDescription", | ||
"RtcSessionDescriptionInit", | ||
"RtcSdpType", | ||
"RtcDataChannel", | ||
"RtcDataChannelEvent", | ||
"RtcDataChannelInit", | ||
"RtcDataChannelState", | ||
"RtcDataChannelType", | ||
"RtcIceConnectionState", | ||
"RtcIceGatheringState", | ||
"RtcIceCandidate", | ||
"RtcIceCandidateInit", | ||
"RtcPeerConnectionIceEvent", | ||
"Event", | ||
"EventTarget", | ||
"MessageEvent", | ||
"Window", | ||
"Document", | ||
"Navigator", | ||
"RtcCertificate", | ||
"RtcPeerConnectionState", | ||
"RtcSignalingState", | ||
"Location", | ||
"HtmlDocument", | ||
"WebSocket" | ||
]} | ||
libp2p-swarm = { workspace = true } | ||
quick-protobuf = "0.8" | ||
quick-protobuf-codec = { workspace = true } | ||
prost = "0.13.5" | ||
|
||
[lints] | ||
workspace = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fn main() { | ||
prost_build::compile_protos(&["src/proto/message.proto"], &["src/proto"]) | ||
.unwrap(); | ||
} | ||
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mod protocol_id; | ||
|
||
pub use protocol_id; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
syntax = "proto3"; | ||
package circuit_relay; | ||
|
||
message Voucher { | ||
// These fields are marked optional for backwards compatibility with proto2. | ||
// Users should make sure to always set these. | ||
optional bytes relay = 1; | ||
optional bytes peer = 2; | ||
optional uint64 expiration = 3; | ||
} | ||
|
||
message HopMessage { | ||
enum Type { | ||
RESERVE = 0; | ||
CONNECT = 1; | ||
STATUS = 2; | ||
} | ||
|
||
// This field is marked optional for backwards compatibility with proto2. | ||
// Users should make sure to always set this. | ||
optional Type type = 1; | ||
|
||
optional Peer peer = 2; | ||
optional Reservation reservation = 3; | ||
optional Limit limit = 4; | ||
|
||
optional Status status = 5; | ||
} | ||
|
||
message StopMessage { | ||
enum Type { | ||
CONNECT = 0; | ||
STATUS = 1; | ||
} | ||
|
||
// This field is marked optional for backwards compatibility with proto2. | ||
// Users should make sure to always set this. | ||
optional Type type = 1; | ||
|
||
optional Peer peer = 2; | ||
optional Limit limit = 3; | ||
|
||
optional Status status = 4; | ||
} | ||
|
||
message Peer { | ||
// This field is marked optional for backwards compatibility with proto2. | ||
// Users should make sure to always set this. | ||
optional bytes id = 1; | ||
repeated bytes addrs = 2; | ||
} | ||
|
||
message Reservation { | ||
// This field is marked optional for backwards compatibility with proto2. | ||
// Users should make sure to always set this. | ||
optional uint64 expire = 1; // Unix expiration time (UTC) | ||
repeated bytes addrs = 2; // relay addrs for reserving peer | ||
optional bytes voucher = 3; // reservation voucher | ||
} | ||
|
||
message Limit { | ||
optional uint32 duration = 1; // seconds | ||
optional uint64 data = 2; // bytes | ||
} | ||
|
||
enum Status { | ||
// zero value field required for proto3 compatibility | ||
UNUSED = 0; | ||
OK = 100; | ||
RESERVATION_REFUSED = 200; | ||
RESOURCE_LIMIT_EXCEEDED = 201; | ||
PERMISSION_DENIED = 202; | ||
CONNECTION_FAILED = 203; | ||
NO_RESERVATION = 204; | ||
MALFORMED_MESSAGE = 400; | ||
UNEXPECTED_MESSAGE = 401; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/// Protocol ID for the Hop protocol. | ||
pub const RELAY_V2_HOP_CODEC: &str = "/libp2p/circuit/relay/0.2.0/hop"; | ||
/// Protocol ID for the Stop protocol. | ||
pub const RELAY_V2_STOP_CODEC: &str = "/libp2p/circuit/relay/0.2.0/stop"; | ||
|
||
/// Voucher envelope domain. | ||
pub const RELAY_VOUCHER_DOMAIN: &str = "libp2p-relay-rsvp"; | ||
/// Voucher Multicodec code. | ||
pub const RELAY_VOUCHER_CODEC: u64 = 0x0302; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
fn main() { | ||
prost_build::compile_protos(&["src/browser/proto/message.proto"], &["src/browser/proto"]) | ||
.unwrap(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
mod signaling; | ||
mod transport; | ||
mod stream; | ||
mod transport; | ||
|
||
pub mod pb { | ||
include!(concat!(env!("OUT_DIR"), "/signaling.rs")); | ||
} | ||
|
||
pub use self::{ | ||
signaling::{Signaling, SIGNALING_PROTOCOL_ID}, | ||
stream::ProtobufStream, | ||
transport::BrowserTransport, | ||
stream::ProtobufStream | ||
}; | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick FYI, we should not use prost but instead use
quick-protobuf
:). See #3024There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Thanks for catching that.