Compare commits
2 Commits
69222548bd
...
003d103bfa
Author | SHA1 | Date |
---|---|---|
kozabrada123 | 003d103bfa | |
Flori | 484c69229d |
File diff suppressed because it is too large
Load Diff
24
Cargo.toml
24
Cargo.toml
|
@ -28,13 +28,17 @@ serde_json = { version = "1.0.111", features = ["raw_value"] }
|
|||
serde-aux = "4.3.1"
|
||||
serde_with = "3.4.0"
|
||||
serde_repr = "0.1.18"
|
||||
reqwest = { features = ["multipart", "json"], version = "0.11.23" }
|
||||
reqwest = { features = [
|
||||
"multipart",
|
||||
"json",
|
||||
"rustls-tls-webpki-roots",
|
||||
], version = "=0.11.26", default-features = false }
|
||||
url = "2.5.0"
|
||||
chrono = { version = "0.4.31", features = ["serde"] }
|
||||
regex = "1.10.2"
|
||||
custom_error = "1.9.2"
|
||||
futures-util = "0.3.30"
|
||||
http = "0.2.11"
|
||||
http = "0.2.12"
|
||||
base64 = "0.21.7"
|
||||
bitflags = { version = "2.4.1", features = ["serde"] }
|
||||
lazy_static = "1.4.0"
|
||||
|
@ -50,22 +54,24 @@ sqlx = { version = "0.7.3", features = [
|
|||
"json",
|
||||
"chrono",
|
||||
"ipnetwork",
|
||||
"runtime-tokio-native-tls",
|
||||
"runtime-tokio-rustls",
|
||||
"any",
|
||||
], optional = true }
|
||||
discortp = { version = "0.5.0", optional = true, features = ["rtp", "discord", "demux"] }
|
||||
discortp = { version = "0.5.0", optional = true, features = [
|
||||
"rtp",
|
||||
"discord",
|
||||
"demux",
|
||||
] }
|
||||
crypto_secretbox = { version = "0.1.1", optional = true }
|
||||
rand = "0.8.5"
|
||||
flate2 = { version = "1.0.30", optional = true }
|
||||
webpki-roots = "0.26.3"
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
rustls = "0.21.10"
|
||||
rustls-native-certs = "0.6.3"
|
||||
tokio-tungstenite = { version = "0.20.1", features = [
|
||||
"rustls-tls-native-roots",
|
||||
"rustls-native-certs",
|
||||
"rustls-tls-webpki-roots",
|
||||
] }
|
||||
native-tls = "0.2.11"
|
||||
hostname = "0.3.1"
|
||||
getrandom = { version = "0.2.12" }
|
||||
|
||||
|
@ -79,4 +85,4 @@ wasmtimer = "0.2.0"
|
|||
lazy_static = "1.4.0"
|
||||
wasm-bindgen-test = "0.3.42"
|
||||
wasm-bindgen = "0.2.92"
|
||||
simple_logger = { version = "5.0.0", default-features=false }
|
||||
simple_logger = { version = "5.0.0", default-features = false }
|
||||
|
|
20
README.md
20
README.md
|
@ -97,7 +97,25 @@ All major desktop operating systems (Windows, macOS (aarch64/x86_64), Linux (aar
|
|||
`wasm32-unknown-unknown` is a supported compilation target on versions `0.12.0` and up. This allows you to use
|
||||
Chorus in your browser, or in any other environment that supports WebAssembly.
|
||||
|
||||
We recommend checking out the examples directory, as well as the documentation for more information.
|
||||
To compile for `wasm32-unknown-unknown`, execute the following command:
|
||||
|
||||
```sh
|
||||
cargo build --target=wasm32-unknown-unknown --no-default-features
|
||||
```
|
||||
|
||||
The following features are supported on `wasm32-unknown-unknown`:
|
||||
|
||||
| Feature | WASM Support |
|
||||
| ----------------- | ------------ |
|
||||
| `client` | ✅ |
|
||||
| `rt` | ✅ |
|
||||
| `rt-multi-thread` | ❌ |
|
||||
| `backend` | ❌ |
|
||||
| `voice` | ❌ |
|
||||
| `voice_udp` | ❌ |
|
||||
| `voice_gateway` | ✅ |
|
||||
|
||||
We recommend checking out the "examples" directory, as well as the documentation for more information.
|
||||
|
||||
## MSRV (Minimum Supported Rust Version)
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
#!/bin/sh
|
||||
|
||||
cargo build --no-default-features --target=wasm32-unknown-unknown "$@"
|
|
@ -32,17 +32,19 @@ impl TungsteniteBackend {
|
|||
pub async fn connect(
|
||||
websocket_url: &str,
|
||||
) -> Result<(TungsteniteSink, TungsteniteStream), TungsteniteBackendError> {
|
||||
let mut roots = rustls::RootCertStore::empty();
|
||||
let certs = rustls_native_certs::load_native_certs();
|
||||
|
||||
if let Err(e) = certs {
|
||||
log::error!("Failed to load platform native certs! {:?}", e);
|
||||
return Err(TungsteniteBackendError::FailedToLoadCerts { error: e });
|
||||
}
|
||||
|
||||
for cert in certs.unwrap() {
|
||||
roots.add(&rustls::Certificate(cert.0)).unwrap();
|
||||
}
|
||||
let certs = webpki_roots::TLS_SERVER_ROOTS;
|
||||
let roots = rustls::RootCertStore {
|
||||
roots: certs
|
||||
.iter()
|
||||
.map(|cert| {
|
||||
rustls::OwnedTrustAnchor::from_subject_spki_name_constraints(
|
||||
cert.subject.to_vec(),
|
||||
cert.subject_public_key_info.to_vec(),
|
||||
cert.name_constraints.as_ref().map(|der| der.to_vec()),
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
};
|
||||
let (websocket_stream, _) = match connect_async_tls_with_config(
|
||||
websocket_url,
|
||||
None,
|
||||
|
@ -58,11 +60,7 @@ impl TungsteniteBackend {
|
|||
.await
|
||||
{
|
||||
Ok(websocket_stream) => websocket_stream,
|
||||
Err(e) => {
|
||||
return Err(TungsteniteBackendError::TungsteniteError {
|
||||
error: e,
|
||||
})
|
||||
}
|
||||
Err(e) => return Err(TungsteniteBackendError::TungsteniteError { error: e }),
|
||||
};
|
||||
|
||||
Ok(websocket_stream.split())
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
#!/bin/sh
|
||||
|
||||
wasm-pack test --firefox --headless -- --no-default-features --target=wasm32-unknown-unknown "$@"
|
Loading…
Reference in New Issue