-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(webrtc): add WebRTC for WASM environments #4248
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
Merged
Merged
Changes from 27 commits
Commits
Show all changes
256 commits
Select commit
Hold shift + click to select a range
e215808
utils
DougAnderson444 19d20f1
fingerprint intial commit
DougAnderson444 10ca24c
errors init commit
DougAnderson444 1790f01
add FusedJsPromise
DougAnderson444 5d34fd3
It compiles (TM), more work to do
DougAnderson444 132c1e6
commit lockfile
DougAnderson444 15fa477
commit lockfile
DougAnderson444 a188e60
Merge branch 'websys-rtc' of https://github.com/DougAnderson444/rust-…
DougAnderson444 babd0da
Merge branch 'master' into websys-rtc
DougAnderson444 dd30772
add license = "MIT"
DougAnderson444 8e3a65e
rm unused code
DougAnderson444 ee537f2
corrections for ci
DougAnderson444 56e66da
add webrtc-websys-test-server
DougAnderson444 0302655
clean up deps for ci
DougAnderson444 74ca3c0
configure Manifest for split: tokio/websys
DougAnderson444 950569f
mv into /webrtc/websys path under feature flag
DougAnderson444 d1ee35e
add Fused Callback Future & maybe_init
DougAnderson444 4d4eae0
move state to common folder
DougAnderson444 fb6e3bc
add common mod
DougAnderson444 a3d281b
add libp2p-core to test
DougAnderson444 431dcfc
add dial server test
DougAnderson444 5248eaf
add logging to test server
DougAnderson444 16d8943
set up client test logging
DougAnderson444 ccfef61
create libp2p-webrtc-utils
DougAnderson444 ba5bf7f
move common out of webrtc/tokio
DougAnderson444 d237dc6
it handshakes
DougAnderson444 e3a78fd
restrict log
DougAnderson444 682151a
add to roadmap
DougAnderson444 312e724
use milliseconds
DougAnderson444 429f511
re-org names, folders, crates
DougAnderson444 bc45750
rm local utils module
DougAnderson444 65f9499
rm local utils import
DougAnderson444 0a8bb18
add WebRTC web-sys to interop tests
DougAnderson444 e8d97e3
rename Substream to Stream
DougAnderson444 7754bd9
use log::debug!
DougAnderson444 3aa336c
rename utils/stream
DougAnderson444 3d77c61
rename stream, address thomas' comments
DougAnderson444 976faef
refactor create data channel, rename stream
DougAnderson444 949b697
refactored DataChannel::new function
DougAnderson444 b13337f
rm comment
DougAnderson444 a040dc4
use WebRTCDirect
DougAnderson444 492fc63
only listen on non wasm32 arch
DougAnderson444 983e2d1
readme consistent with test-plans/multidim-interop
DougAnderson444 af4ecee
lock file
DougAnderson444 97b2085
add cfg windows guard for local testing
DougAnderson444 f78f88d
rm pub from utils
DougAnderson444 ac1c82a
reduce to two top-level free functions
DougAnderson444 c8995ac
fix log::debug, general cleanup
DougAnderson444 7af14f7
refactor log::debug
DougAnderson444 ac538ac
use new upgrade::outbound() fn
DougAnderson444 b0079d8
refactor log::debug
DougAnderson444 4b674d6
fix typo
DougAnderson444 052b6bb
sw to Localhost, rm WebRTCWebSys
DougAnderson444 190fc1b
fix buggy close sequence
DougAnderson444 5bdd56f
set readme to webrtc-direc naming
DougAnderson444 a749145
rename WebRTCStream to simply `Stream`
DougAnderson444 c982e13
rename WebRTCStream to simply `Stream`
DougAnderson444 e099807
convert `CbFutures` to `futures::Channel`
DougAnderson444 3f076b7
rm readme.md
DougAnderson444 efc2a3b
convert `CbFutures` to `futures::channel`
DougAnderson444 61cce46
refactor RtcDataChannelBuilder
DougAnderson444 e8d1f53
rm dead sdp code
DougAnderson444 de485ed
rm dead code
DougAnderson444 612732a
clean up logging
DougAnderson444 f957e4a
fix wasm Closure
DougAnderson444 bf7bf2a
add trace logging
DougAnderson444 b0229c1
convert to `try_send` and `log::trace`
DougAnderson444 5f34cc3
add example (so awesome seeing it in action)
DougAnderson444 73d3924
audit dependencies, rm unused
DougAnderson444 ec5cb38
correct naming: webrtc-direct
DougAnderson444 a34bc3b
update readme dialer instr
DougAnderson444 06824e8
revert chromedriver condition for windows
DougAnderson444 66852d8
mv ./stream/mod.rs to ./stream.rs
DougAnderson444 56baebf
test server formatting
DougAnderson444 254d67b
logging
DougAnderson444 ac23860
stream identifier for web-sys
DougAnderson444 68d0564
rm callback futures module
DougAnderson444 080c27e
rm unused dep
DougAnderson444 305dadf
mv sdp noise fngerprnt err to libp2p-webrtc-utils
DougAnderson444 de6098d
bump deps
DougAnderson444 e00166a
update ROADMAP
DougAnderson444 1618c49
asynchronous-codec = "0.6"
DougAnderson444 358b86c
commit lock file
DougAnderson444 7b8db4b
merge yamux from main
DougAnderson444 adbbe4e
Merge branch 'master' into websys-rtc
DougAnderson444 2e8c2e5
fix reqwest version
DougAnderson444 da71eb3
fix merge error
DougAnderson444 2913fbe
fix licences
DougAnderson444 01dd0ee
rm chrono dep
DougAnderson444 8842070
add trunk note
DougAnderson444 c825cc3
fix test
DougAnderson444 a55ea68
fix missing dep
DougAnderson444 7116393
commit lockfile
DougAnderson444 a37a727
fix formatting
DougAnderson444 d10203c
leptos uses nightly
DougAnderson444 12fdffa
fix test
DougAnderson444 97ed723
add rust-version.workspace
DougAnderson444 99cc8da
switch Leptos example to rust stable channel
DougAnderson444 ef6ebee
switch to Ipv6Addr::UNSPECIFIED for CI
DougAnderson444 b26046e
rust-version = { workspace = true }
DougAnderson444 1777566
cleanup & docs
DougAnderson444 f7ecb18
rename bin to webrtc-example-server
DougAnderson444 40b24e8
log, publish (false) and naming
DougAnderson444 66bbf6c
refactor example/client to vanilla wasm
DougAnderson444 6e0b93b
use bounded channel
DougAnderson444 7bb0884
cleanup
DougAnderson444 de88725
only spawn axum server once
DougAnderson444 6aa2cfe
update example readme to remove leptos refs
DougAnderson444 8aa139a
fix cargo categories, fix single line
DougAnderson444 e0c0ca4
rm dead comment
DougAnderson444 dc0d569
switch to `warn`
DougAnderson444 a562d18
fix cargo categories, single line
DougAnderson444 f6fb6fa
fixed formatting discrepancoes
DougAnderson444 75aed7f
revert tokio specific code back into webrtc crate
DougAnderson444 16f72a6
wasm specific code into webrtc-websys crate
DougAnderson444 049823c
rm unneeded comment
DougAnderson444 c5f5af8
set libp2p-webrtc = "0.7.0-alpha"
DougAnderson444 aa3b15a
use Fingerprint From
DougAnderson444 d424782
use wasm-logger
DougAnderson444 e37e985
simplify: remove remote addr option
DougAnderson444 9484a79
remove duplicate test folder
DougAnderson444 d82906f
rm utils feature tokio
DougAnderson444 2541c35
rm utils feature wasm-bindgen
DougAnderson444 1dbc906
update members to reflect removed folders
DougAnderson444 693ada7
move random_ufrag to libp2p-webrtc-utils
DougAnderson444 a5c0bdc
mv `parse_webrtc_dial_addr` to `utils`
DougAnderson444 50e9e9d
encapsulate utils in user crate sub modules
DougAnderson444 b02a560
mv env vars to `main.rs`
DougAnderson444 c018124
auto derive NetworkBehaviour, use libp2p path
DougAnderson444 bd808c5
impl From for `utils` errors (Public API)
DougAnderson444 6609c0b
single line deps
DougAnderson444 3c50865
add static and multiaddr servers
DougAnderson444 0419302
apply loop improvement, use server module
DougAnderson444 919863b
update example readme
DougAnderson444 a1dca96
minimize diff
DougAnderson444 21833e3
fix small example stuff
DougAnderson444 328ea89
minimize diff
DougAnderson444 be50b1f
fixes for minimal diff
DougAnderson444 4f4c5cc
rm extraneous logging
DougAnderson444 d355a43
implement `DropListener` logic
DougAnderson444 36871f7
Merge branch 'master' into websys-rtc
DougAnderson444 f993450
imporve example loop logic
DougAnderson444 8b3a400
cleaner deps
DougAnderson444 b9e55c4
fix clippy
DougAnderson444 f650469
set [email protected] to support rustc v1.65
DougAnderson444 14cd90f
fix more clippy errors
DougAnderson444 464faea
rm panic error logging
DougAnderson444 82c862b
substreams as streams everywhere
DougAnderson444 092dc57
revert auto formatting
DougAnderson444 5ddd2ca
revert auto formatting
DougAnderson444 2769297
Merge branch 'websys-rtc' of https://github.com/DougAnderson444/rust-…
DougAnderson444 ac60389
fix rustdoc error
DougAnderson444 4d8af29
add/update CHANGELOGs & README
DougAnderson444 0e1c189
Reduce diff
thomaseizinger f584f39
Reduce diff on lockfile
thomaseizinger ed811ac
Use single line dependency syntax
thomaseizinger d93d453
Remove unnecessary whitespace
thomaseizinger 3e7865e
Init logger directly instead of setting var
thomaseizinger 4457789
Reduce to 1 HTTP server
thomaseizinger 69e3e86
Remove infallible error
thomaseizinger d8a09d9
Remove `.html` fallback
thomaseizinger f5be65d
Inline into 1 file
thomaseizinger c7e2f73
Convention over configuration
thomaseizinger 716fd75
Print address where we are server the client
thomaseizinger 19c4af3
Break from loop if channel is disconnected
thomaseizinger 3a13278
Use `thiserror`
thomaseizinger 1820e7e
Inline `error.rs` file
thomaseizinger 31ae801
Add newline to end of files
thomaseizinger 0b21a3f
Have event loop block `fn main`
thomaseizinger 3546f56
Simplify `fetch_server_addr`
thomaseizinger 8fec2e5
Fix docs
thomaseizinger c0d74d3
Remove feature that should not be set for libraries
thomaseizinger 2643b73
Update transports/webrtc-websys/CHANGELOG.md
DougAnderson444 4ca20fb
Merge branch 'master' into websys-rtc
DougAnderson444 681994f
Switch back to IPv4 for interop-tests
thomaseizinger 99fb67d
Update instructions for webrtc-direct
thomaseizinger aab3c78
Extend instructions with redis
thomaseizinger 6619124
Remove unused imports
thomaseizinger 7182dcf
Merge branch 'master' into websys-rtc
thomaseizinger fdf106a
Simplify wasm code
thomaseizinger 6a377dd
Merge client and server into one crate
thomaseizinger e00da70
Remove need for fetching address
thomaseizinger 09317d0
Merge branch 'master' into websys-rtc
thomaseizinger 311062b
Remove `stream_identifier` hack
thomaseizinger 0180da7
Simplify `PollDataChannel` implementation
thomaseizinger d89ebe1
Ensure DC is ready for writing
thomaseizinger 863647d
Don't leak closures and make them FnMuts
thomaseizinger d7930d2
Unify `Stream` implementations
thomaseizinger dd1e8a0
Retain read_buf_capacity for native WebRTC impl
thomaseizinger 507ce67
Unify SPF answer creation
thomaseizinger 8230ca5
Polish SDP creation
thomaseizinger 519a48b
Tidy up upgrade process by introducing wrapper for web_sys object
thomaseizinger 75fcbdf
Tidy comments and fn names
thomaseizinger 91ca28e
Tidy up new data channel creation
thomaseizinger 66fdf45
Rename field
thomaseizinger 2240f7b
Don't leak closure
thomaseizinger 33f412c
Remove `ConnectionInner`
thomaseizinger 8fb2600
Merge branch 'master' into websys-rtc
thomaseizinger 2e758ab
Restore public API of `libp2p-webrtc`
thomaseizinger 70a2ff3
Minimize diff and get rid of shared error
thomaseizinger f7d2cb1
Reduce diff
thomaseizinger c6418df
Reduce `libp2p-webrtc` version to 0.6.1-alpha
thomaseizinger 2499b9f
Reduce diff
thomaseizinger 771ff81
Update lockfile
thomaseizinger 2141fea
Minimize deps
thomaseizinger ddc1f1d
Move `libp2p-webrtc-utils`to `misc/`
thomaseizinger 3c08227
Merge branch 'master' into websys-rtc
DougAnderson444 3bb4c53
Update `Cargo.lock`
thomaseizinger 3d50096
Temporarily set `publish = false`
thomaseizinger 8129cb7
Appease clippy
thomaseizinger 92d8f89
Misc fixes to reduce diff / duplication
thomaseizinger 30a0026
Reduce diff
thomaseizinger 5845556
Merge branch 'master' into websys-rtc
thomaseizinger 09055f4
Fix compile error
thomaseizinger 03edec6
rm LICENSE fm example
DougAnderson444 244a157
add 'description', 'repository' to Cargo.toml
DougAnderson444 7c56d57
more loquacious comment about content serving
DougAnderson444 a77603e
Swarm with a capital `S` in README
DougAnderson444 9e41d00
use `.expect()` instead of `.unwrap()`
DougAnderson444 870045a
allow `non_upper_case_globals` for rust_embed
DougAnderson444 4dd3bd1
Fail connection on overload
thomaseizinger d26864f
Rename function and add docs
thomaseizinger 470fab7
Add docs for `overloaded`
thomaseizinger ed01381
remove old comment about being "unimplemented"
DougAnderson444 6c859fa
Merge branch 'master' into websys-rtc
DougAnderson444 5ec051b
Merge branch 'websys-rtc' of https://github.com/DougAnderson444/rust-…
DougAnderson444 8505d0d
check if local firefox
DougAnderson444 75e25b5
use `Ipv6Addr::UNSPECIFIED` instead of `LOCALHOST`
DougAnderson444 a880251
send reset signal when read Error occurs
DougAnderson444 fc26ded
set repo to lowercase in docker .yml
DougAnderson444 8c23eb1
set repo to lowercase in docker .yml
DougAnderson444 a24d4ed
set REPO to lowercase in docker-image.yml
DougAnderson444 55b651d
use github env var in docker yml
DougAnderson444 dd04b4f
Merge branch 'websys-rtc'
DougAnderson444 4a14e74
add coverage for hostname as IPv6
DougAnderson444 e3896b8
remove duplicate REPO naming in yml
DougAnderson444 c4693f0
fix rustdoc hyperlink
DougAnderson444 65c027b
update webpki 0.22.1 for RUSTSEC-2023-0052
DougAnderson444 5d30cbf
publish=false, temp fix to CI semver-checks-action
DougAnderson444 66e7844
Merge branch 'master' into websys-rtc
thomaseizinger 952160e
Make example work in Firefox
thomaseizinger 5d22479
Don't set waker on connection shutdown
thomaseizinger f4d2ecf
Remove unused import
thomaseizinger 7a2eda1
revert docker.yml casing change
DougAnderson444 6e3cfe6
Merge branch 'master' into websys-rtc
thomaseizinger a0abc3e
Merge branch 'master' into websys-rtc
thomaseizinger 1c9f0a7
Merge branch 'master' into websys-rtc
thomaseizinger 0e331a4
Merge branch 'master' into websys-rtc
thomaseizinger 46876ad
revert commit a880251 (send Reset)
0a74524
Merge branch 'master' into websys-rtc
DougAnderson444 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
thomaseizinger marked this conversation as resolved.
Show resolved
Hide resolved
|
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod substream; |
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,14 @@ | ||
pub(crate) mod state; | ||
|
||
/// Maximum length of a message. | ||
/// | ||
/// "As long as message interleaving is not supported, the sender SHOULD limit the maximum message | ||
/// size to 16 KB to avoid monopolization." | ||
/// Source: <https://www.rfc-editor.org/rfc/rfc8831#name-transferring-user-data-on-a> | ||
pub(crate) const MAX_MSG_LEN: usize = 16384; // 16kiB | ||
/// Length of varint, in bytes. | ||
pub(crate) const VARINT_LEN: usize = 2; | ||
/// Overhead of the protobuf encoding, in bytes. | ||
pub(crate) const PROTO_OVERHEAD: usize = 5; | ||
/// Maximum length of data, in bytes. | ||
pub(crate) const MAX_DATA_LEN: usize = MAX_MSG_LEN - VARINT_LEN - PROTO_OVERHEAD; |
thomaseizinger marked this conversation as resolved.
Show resolved
Hide resolved
|
File renamed without changes.
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,98 @@ | ||
use futures::FutureExt; | ||
use std::cell::Cell; | ||
use std::future::Future; | ||
use std::pin::Pin; | ||
use std::rc::Rc; | ||
use std::task::{ready, Context, Poll, Waker}; | ||
|
||
pub struct FusedCbFuture<T>(Option<CbFuture<T>>); | ||
|
||
impl<T> FusedCbFuture<T> { | ||
pub(crate) fn new() -> Self { | ||
Self(None) | ||
} | ||
|
||
pub(crate) fn maybe_init<F>(&mut self, init: F) -> &mut Self | ||
where | ||
F: FnOnce() -> CbFuture<T>, | ||
{ | ||
if self.0.is_none() { | ||
self.0 = Some(init()); | ||
} | ||
|
||
self | ||
} | ||
|
||
/// Checks if future is already running | ||
pub(crate) fn is_active(&self) -> bool { | ||
self.0.is_some() | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct CbFuture<T>(Rc<CallbackFutureInner<T>>); | ||
|
||
struct CallbackFutureInner<T> { | ||
waker: Cell<Option<Waker>>, | ||
result: Cell<Option<T>>, | ||
} | ||
|
||
impl<T> std::fmt::Debug for CallbackFutureInner<T> { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
f.debug_struct("CallbackFutureInner").finish() | ||
} | ||
} | ||
|
||
impl<T> Default for CallbackFutureInner<T> { | ||
fn default() -> Self { | ||
Self { | ||
waker: Cell::new(None), | ||
result: Cell::new(None), | ||
} | ||
} | ||
} | ||
|
||
impl<T> CbFuture<T> { | ||
/// New Callback Future | ||
pub(crate) fn new() -> Self { | ||
Self(Rc::new(CallbackFutureInner::<T>::default())) | ||
} | ||
|
||
// call this from your callback | ||
pub(crate) fn publish(&self, result: T) { | ||
self.0.result.set(Some(result)); | ||
if let Some(w) = self.0.waker.take() { | ||
w.wake() | ||
}; | ||
} | ||
} | ||
|
||
impl<T> Future for CbFuture<T> { | ||
type Output = T; | ||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { | ||
match self.0.result.take() { | ||
Some(x) => Poll::Ready(x), | ||
None => { | ||
self.0.waker.set(Some(cx.waker().clone())); | ||
Poll::Pending | ||
} | ||
} | ||
} | ||
} | ||
|
||
impl<T> Future for FusedCbFuture<T> { | ||
type Output = T; | ||
|
||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { | ||
let val = ready!(self | ||
.0 | ||
.as_mut() | ||
.expect("FusedCbFuture not initialized") | ||
.poll_unpin(cx)); | ||
|
||
// Future finished, drop it | ||
self.0.take(); | ||
|
||
Poll::Ready(val) | ||
} | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.