shuttle: added tls support for clients and chaned standart route to shuttle server
This commit is contained in:
parent
6fd67f5f4e
commit
17b7b4a61a
4 changed files with 128 additions and 16 deletions
78
Cargo.lock
generated
78
Cargo.lock
generated
|
|
@ -1913,6 +1913,21 @@ dependencies = [
|
||||||
"subtle",
|
"subtle",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ring"
|
||||||
|
version = "0.17.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"cfg-if",
|
||||||
|
"getrandom",
|
||||||
|
"libc",
|
||||||
|
"spin",
|
||||||
|
"untrusted",
|
||||||
|
"windows-sys 0.52.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.23"
|
version = "0.1.23"
|
||||||
|
|
@ -1932,6 +1947,37 @@ dependencies = [
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustls"
|
||||||
|
version = "0.22.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432"
|
||||||
|
dependencies = [
|
||||||
|
"log",
|
||||||
|
"ring",
|
||||||
|
"rustls-pki-types",
|
||||||
|
"rustls-webpki",
|
||||||
|
"subtle",
|
||||||
|
"zeroize",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustls-pki-types"
|
||||||
|
version = "1.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "beb461507cee2c2ff151784c52762cf4d9ff6a61f3e80968600ed24fa837fa54"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustls-webpki"
|
||||||
|
version = "0.102.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f3bce581c0dd41bce533ce695a1437fa16a7ab5ac3ccfa99fe1a620a7885eabf"
|
||||||
|
dependencies = [
|
||||||
|
"ring",
|
||||||
|
"rustls-pki-types",
|
||||||
|
"untrusted",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustversion"
|
name = "rustversion"
|
||||||
version = "1.0.15"
|
version = "1.0.15"
|
||||||
|
|
@ -2454,6 +2500,17 @@ dependencies = [
|
||||||
"syn 2.0.60",
|
"syn 2.0.60",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tokio-rustls"
|
||||||
|
version = "0.25.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f"
|
||||||
|
dependencies = [
|
||||||
|
"rustls",
|
||||||
|
"rustls-pki-types",
|
||||||
|
"tokio",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-stream"
|
name = "tokio-stream"
|
||||||
version = "0.1.15"
|
version = "0.1.15"
|
||||||
|
|
@ -2473,8 +2530,12 @@ checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"log",
|
"log",
|
||||||
|
"rustls",
|
||||||
|
"rustls-pki-types",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
"tokio-rustls",
|
||||||
"tungstenite",
|
"tungstenite",
|
||||||
|
"webpki-roots",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -2687,6 +2748,8 @@ dependencies = [
|
||||||
"httparse",
|
"httparse",
|
||||||
"log",
|
"log",
|
||||||
"rand",
|
"rand",
|
||||||
|
"rustls",
|
||||||
|
"rustls-pki-types",
|
||||||
"sha1",
|
"sha1",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"url",
|
"url",
|
||||||
|
|
@ -2745,6 +2808,12 @@ dependencies = [
|
||||||
"subtle",
|
"subtle",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "untrusted"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "url"
|
name = "url"
|
||||||
version = "2.5.0"
|
version = "2.5.0"
|
||||||
|
|
@ -2882,6 +2951,15 @@ dependencies = [
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "webpki-roots"
|
||||||
|
version = "0.26.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009"
|
||||||
|
dependencies = [
|
||||||
|
"rustls-pki-types",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ path = "src/shuttle.rs"
|
||||||
futures-util = "0.3"
|
futures-util = "0.3"
|
||||||
tungstenite = "0.21.0"
|
tungstenite = "0.21.0"
|
||||||
tokio = { version = "1.28.1", features = ["full"] }
|
tokio = { version = "1.28.1", features = ["full"] }
|
||||||
tokio-tungstenite = { version = "0.21.0" }
|
tokio-tungstenite = { version = "0.21.0", features =["rustls-tls-webpki-roots"] }
|
||||||
serde_json = { version = "1.0" }
|
serde_json = { version = "1.0" }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
uuid = { version = "1.3.2", features = ["v4"] }
|
uuid = { version = "1.3.2", features = ["v4"] }
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ impl Args {
|
||||||
sender::start_sender(
|
sender::start_sender(
|
||||||
relay.as_deref().unwrap_or(
|
relay.as_deref().unwrap_or(
|
||||||
env::var("APP_ORIGIN")
|
env::var("APP_ORIGIN")
|
||||||
.unwrap_or("ws://0.0.0.0:8000/ws".to_string())
|
.unwrap_or("wss://caesar-transfer-iu.shuttleapp.rs/ws".to_string())
|
||||||
.as_str(),
|
.as_str(),
|
||||||
),
|
),
|
||||||
files,
|
files,
|
||||||
|
|
|
||||||
|
|
@ -48,21 +48,55 @@ use tokio_tungstenite::{
|
||||||
use tracing::{debug, error};
|
use tracing::{debug, error};
|
||||||
|
|
||||||
pub async fn start_sender(relay: &str, files: &[String]) {
|
pub async fn start_sender(relay: &str, files: &[String]) {
|
||||||
let Ok(mut request) = relay.into_client_request() else {
|
match relay.into_client_request() {
|
||||||
println!("Error: Failed to create request.");
|
Ok(mut request) => {
|
||||||
return;
|
request
|
||||||
};
|
.headers_mut()
|
||||||
|
.insert("Origin", HeaderValue::from_str(relay).unwrap());
|
||||||
|
|
||||||
request
|
debug!("Attempting to connect to {relay}...");
|
||||||
.headers_mut()
|
|
||||||
.insert("Origin", HeaderValue::from_str(relay).unwrap());
|
|
||||||
|
|
||||||
debug!("Attempting to connect to {relay}...");
|
match connect_async(request).await {
|
||||||
|
Ok((socket, _)) => {
|
||||||
|
let paths = files.to_vec();
|
||||||
|
sender::start(socket, paths).await;
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
error!("Error: Failed to connect with error: {e}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
error!("Error: failed to create request with reason: {e:?}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// let Ok(mut request) = relay.into_client_request() else {
|
||||||
|
// println!("Error: Failed to create request.");
|
||||||
|
// return;
|
||||||
|
// };
|
||||||
|
|
||||||
let Ok((socket, _)) = connect_async(request).await else {
|
// request
|
||||||
error!("Error: Failed to connect.");
|
// .headers_mut()
|
||||||
return;
|
// .insert("Origin", HeaderValue::from_str(relay).unwrap());
|
||||||
};
|
|
||||||
let paths = files.to_vec();
|
// debug!("Attempting to connect to {relay}...");
|
||||||
sender::start(socket, paths).await
|
|
||||||
|
// match connect_async(request).await {
|
||||||
|
// Ok((socket, _)) => {
|
||||||
|
// let paths = files.to_vec();
|
||||||
|
// sender::start(socket, paths).await;
|
||||||
|
// }
|
||||||
|
// Err(e) => {
|
||||||
|
// error!("Error: Failed to connect with error: {e}");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// let Ok((socket, _)) = connect_async(request).await else {
|
||||||
|
// error!("Error: Failed to connect.");
|
||||||
|
// return;
|
||||||
|
// };
|
||||||
|
// let paths = files.to_vec();
|
||||||
|
// sender::start(socket, paths).await
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue