From 6c8025c6dec52a26103186848510d72936f15603 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 15 Jan 2023 20:05:05 +0100 Subject: update some stuff --- server/Cargo.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'server/Cargo.toml') diff --git a/server/Cargo.toml b/server/Cargo.toml index 60d510d..4f29cde 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -5,11 +5,11 @@ edition = "2021" [dependencies] warp = "0.3" -tokio = { version = "1.21", features = ["full"] } +tokio = { version = "1.24", features = ["full"] } log = "0.4" -env_logger = "0.8" -futures-util = "0.3.24" +env_logger = "0.10" +futures-util = "0.3.25" listenfd = "1.0.0" -hyper = "0.14.20" -serde = { version = "1.0.144", features = ["derive"] } +hyper = "0.14.23" +serde = { version = "1.0.152", features = ["derive"] } serde_json = "*" -- cgit v1.2.3-70-g09d2 From 2c6f4dc839a279b9d5c10d674489998b021908b8 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 5 Feb 2023 20:57:47 +0100 Subject: update deps --- Cargo.lock | 48 +++++++++--------- client-native-export-track/Cargo.toml | 8 +-- client-native-gui/Cargo.toml | 6 +-- client-native-lib/Cargo.toml | 6 +-- client-native-lib/src/crypto.rs | 9 ++-- client-native-lib/src/peer.rs | 93 +++++++++++++++-------------------- client-native-rift/Cargo.toml | 6 +-- client-native-rift/src/main.rs | 42 ++++++---------- server/Cargo.toml | 6 +-- 9 files changed, 103 insertions(+), 121 deletions(-) (limited to 'server/Cargo.toml') diff --git a/Cargo.lock b/Cargo.lock index d116317..267b1b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -232,9 +232,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.68" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" +checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" [[package]] name = "arboard" @@ -631,9 +631,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "calloop" @@ -722,9 +722,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.1" +version = "4.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec7a4128863c188deefe750ac1d1dfe66c236909f845af04beed823638dc1b2" +checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76" dependencies = [ "bitflags", "clap_derive", @@ -1687,9 +1687,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5" dependencies = [ "futures-core", "futures-sink", @@ -1697,9 +1697,9 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" +checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" [[package]] name = "futures-executor" @@ -1714,9 +1714,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" +checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531" [[package]] name = "futures-lite" @@ -1735,9 +1735,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" +checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70" dependencies = [ "proc-macro2", "quote", @@ -1746,21 +1746,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" +checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" [[package]] name = "futures-task" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" +checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" [[package]] name = "futures-util" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" dependencies = [ "futures-channel", "futures-core", @@ -2110,9 +2110,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.23" +version = "0.14.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" +checksum = "5e011372fa0b68db8350aa7a248930ecc7839bf46d8485577d69f117a75f164c" dependencies = [ "bytes", "futures-channel", @@ -3834,9 +3834,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.24.2" +version = "1.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a12a59981d9e3c38d216785b0c37399f6e415e8d0712047620f189371b0bb" +checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" dependencies = [ "autocfg", "bytes", diff --git a/client-native-export-track/Cargo.toml b/client-native-export-track/Cargo.toml index b8efdca..36ba652 100644 --- a/client-native-export-track/Cargo.toml +++ b/client-native-export-track/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" [dependencies] client-native-lib = { path = "../client-native-lib" } -clap = { version = "4.1.1", features = ["derive"] } +clap = { version = "4.1.4", features = ["derive"] } env_logger = "0.10.0" log = "0.4" -tokio = { version = "1.24", features = ["full"] } -bytes = "1.3.0" -anyhow = "1.0.68" +tokio = { version = "1.25", features = ["full"] } +bytes = "1.4.0" +anyhow = "1.0.69" diff --git a/client-native-gui/Cargo.toml b/client-native-gui/Cargo.toml index f41859c..767433c 100644 --- a/client-native-gui/Cargo.toml +++ b/client-native-gui/Cargo.toml @@ -6,12 +6,12 @@ edition = "2021" [dependencies] client-native-lib = { path = "../client-native-lib" } -clap = { version = "4.1.1", features = ["derive"] } +clap = { version = "4.1.4", features = ["derive"] } async-std = "1.12.0" -tokio = { version = "1.24.1", features = ["full"] } +tokio = { version = "1.25.0", features = ["full"] } env_logger = "0.10.0" log = "0.4" -anyhow = "1.0.68" +anyhow = "1.0.69" crossbeam-channel = "0.5.6" egui = "0.20.1" diff --git a/client-native-lib/Cargo.toml b/client-native-lib/Cargo.toml index 69c6e91..c9b0ea4 100644 --- a/client-native-lib/Cargo.toml +++ b/client-native-lib/Cargo.toml @@ -4,8 +4,8 @@ version = "0.1.0" edition = "2021" [dependencies] -tokio = { version = "1.24", features = ["full"] } -futures-util = "0.3.25" +tokio = { version = "1.25", features = ["full"] } +futures-util = "0.3.26" webrtc = "0.6.0" tokio-tungstenite = { version = "*", features = ["rustls-tls"] } @@ -22,4 +22,4 @@ sha256 = "1.1.1" rand = "0.8.5" rand_chacha = "0.3.1" base64 = "0.21.0" -bytes = "1.3.0" +bytes = "1.4.0" diff --git a/client-native-lib/src/crypto.rs b/client-native-lib/src/crypto.rs index 239c9f3..0472ec7 100644 --- a/client-native-lib/src/crypto.rs +++ b/client-native-lib/src/crypto.rs @@ -7,6 +7,7 @@ use aes_gcm::{ aead::{generic_array::sequence::GenericSequence, Aead}, Aes256Gcm, KeyInit, Nonce, }; +use base64::Engine; use log::info; pub struct Key(Aes256Gcm); @@ -14,7 +15,9 @@ pub struct Key(Aes256Gcm); impl Key { pub fn derive(secret: &str) -> Self { info!("running key generation..."); - let salt = base64::decode("thisisagoodsaltAAAAAAA==").unwrap(); + let salt = base64::engine::general_purpose::STANDARD + .decode("thisisagoodsaltAAAAAAA==") + .unwrap(); let mut key = [0u8; 32]; fastpbkdf2::pbkdf2_hmac_sha256(secret.as_bytes(), salt.as_slice(), 250000, &mut key); @@ -28,10 +31,10 @@ impl Key { let ciphertext = self.0.encrypt(&iv, s.as_bytes()).unwrap(); let mut packet = iv.to_vec(); // TODO this could be doing less allocations packet.extend(ciphertext); - base64::encode(packet) + base64::engine::general_purpose::STANDARD.encode(packet) } pub fn decrypt(&self, s: &str) -> String { - let r = base64::decode(s).unwrap(); + let r = base64::engine::general_purpose::STANDARD.decode(s).unwrap(); let iv = &r[0..12]; let ciphertext = &r[12..]; let plaintext = self.0.decrypt(Nonce::from_slice(iv), ciphertext).unwrap(); diff --git a/client-native-lib/src/peer.rs b/client-native-lib/src/peer.rs index b3b4dd4..8c27234 100644 --- a/client-native-lib/src/peer.rs +++ b/client-native-lib/src/peer.rs @@ -69,34 +69,28 @@ impl Peer { .on_peer_connection_state_change(Box::new(move |s: RTCPeerConnectionState| { info!("connection state changed: {s}"); Box::pin(async {}) - })) - .await; - + })); { let weak = Arc::::downgrade(&peer); - peer.peer_connection - .on_ice_candidate(box move |c| { - if let Some(peer) = weak.upgrade() { - Box::pin(async move { - if let Some(c) = c { - peer.on_ice_candidate(c).await - } - }) - } else { - Box::pin(async move {}) - } - }) - .await; + peer.peer_connection.on_ice_candidate(box move |c| { + if let Some(peer) = weak.upgrade() { + Box::pin(async move { + if let Some(c) = c { + peer.on_ice_candidate(c).await + } + }) + } else { + Box::pin(async move {}) + } + }) } { let weak = Arc::::downgrade(&peer); - peer.peer_connection - .on_negotiation_needed(box move || { - let peer = weak.upgrade().unwrap(); - Box::pin(async { peer.on_negotiation_needed().await }) - }) - .await; + peer.peer_connection.on_negotiation_needed(box move || { + let peer = weak.upgrade().unwrap(); + Box::pin(async { peer.on_negotiation_needed().await }) + }) } { @@ -124,37 +118,34 @@ impl Peer { } }) }) - .await; } { let weak = Arc::::downgrade(&peer); - peer.peer_connection - .on_data_channel(box move |dc| { - let peer = weak.upgrade().unwrap(); - Box::pin(async move { - if let Some(res) = peer - .remote_provided - .read() - .await - .get(&dc.label().to_string()) - { - info!("data channel for ({:?}) '{:?}'", res.id, res.label); - peer.inst - .event_handler - .resource_connected( - peer.clone(), - res, - TransportChannel::DataChannel(dc), - ) - .await; - } else { - warn!("got unassociated data channel; closed connection"); - dc.close().await.unwrap(); - } - }) + peer.peer_connection.on_data_channel(box move |dc| { + let peer = weak.upgrade().unwrap(); + Box::pin(async move { + if let Some(res) = peer + .remote_provided + .read() + .await + .get(&dc.label().to_string()) + { + info!("data channel for ({:?}) '{:?}'", res.id, res.label); + peer.inst + .event_handler + .resource_connected( + peer.clone(), + res, + TransportChannel::DataChannel(dc), + ) + .await; + } else { + warn!("got unassociated data channel; closed connection"); + dc.close().await.unwrap(); + } }) - .await; + }) } peer } @@ -228,10 +219,8 @@ impl Peer { pub async fn on_ice_candidate(&self, candidate: RTCIceCandidate) { debug!("publishing local ICE candidate"); - self.send_relay(RelayMessage::IceCandidate( - candidate.to_json().await.unwrap(), - )) - .await; + self.send_relay(RelayMessage::IceCandidate(candidate.to_json().unwrap())) + .await; } pub async fn on_remote_ice_candidate(&self, candidate: RTCIceCandidateInit) { debug!("adding remote ICE candidate"); diff --git a/client-native-rift/Cargo.toml b/client-native-rift/Cargo.toml index cdc6b3b..ccc0c5c 100644 --- a/client-native-rift/Cargo.toml +++ b/client-native-rift/Cargo.toml @@ -6,12 +6,12 @@ edition = "2021" [dependencies] client-native-lib = { path = "../client-native-lib" } -clap = { version = "4.1.1", features = ["derive"] } +clap = { version = "4.1.4", features = ["derive"] } env_logger = "0.10.0" log = "0.4" -tokio = { version = "1.24", features = ["full"] } -bytes = "1.3.0" +tokio = { version = "1.25", features = ["full"] } +bytes = "1.4.0" indicatif = "0.17.3" humansize = "2.1.3" diff --git a/client-native-rift/src/main.rs b/client-native-rift/src/main.rs index 45f720a..6255fe7 100644 --- a/client-native-rift/src/main.rs +++ b/client-native-rift/src/main.rs @@ -167,8 +167,7 @@ impl EventHandler for Handler { info!("channel opened"); *writer.write().await = Some(s.args.action.create_writer().await) }) - }) - .await; + }); } { let writer = writer.clone(); @@ -183,8 +182,7 @@ impl EventHandler for Handler { exit(0); } }) - }) - .await; + }); } { let writer = writer.clone(); @@ -218,13 +216,11 @@ impl EventHandler for Handler { }) }) } - .await; dc.on_error(box move |err| { Box::pin(async move { error!("data channel errored: {err}"); }) - }) - .await; + }); } } }) @@ -292,27 +288,23 @@ impl LocalResource for FileSender { { let reader = reader.clone(); let reader_factory = reader_factory.clone(); - channel - .on_open(box move || { - let reader = reader.clone(); - Box::pin(async move { - info!("channel open"); - *reader.write().await = Some(reader_factory.create_reader().await); - }) + channel.on_open(box move || { + let reader = reader.clone(); + Box::pin(async move { + info!("channel open"); + *reader.write().await = Some(reader_factory.create_reader().await); }) - .await; + }) } { let reader = reader.clone(); - channel - .on_close(box move || { - let reader = reader.clone(); - Box::pin(async move { - info!("channel closed"); - *reader.write().await = None; - }) + channel.on_close(box move || { + let reader = reader.clone(); + Box::pin(async move { + info!("channel closed"); + *reader.write().await = None; }) - .await; + }) } { channel.set_buffered_amount_low_threshold(1 << 20).await; @@ -354,9 +346,7 @@ impl LocalResource for FileSender { .await; } - channel - .on_error(box move |err| Box::pin(async move { error!("channel error: {err}") })) - .await; + channel.on_error(box move |err| Box::pin(async move { error!("channel error: {err}") })) }) } } diff --git a/server/Cargo.toml b/server/Cargo.toml index 4f29cde..e2b0506 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -5,11 +5,11 @@ edition = "2021" [dependencies] warp = "0.3" -tokio = { version = "1.24", features = ["full"] } +tokio = { version = "1.25", features = ["full"] } log = "0.4" env_logger = "0.10" -futures-util = "0.3.25" +futures-util = "0.3.26" listenfd = "1.0.0" -hyper = "0.14.23" +hyper = "0.14.24" serde = { version = "1.0.152", features = ["derive"] } serde_json = "*" -- cgit v1.2.3-70-g09d2 From 9dfc929b709d4187dc307f68a42fa058eda7a4c1 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 11 Feb 2023 10:29:02 +0100 Subject: standalone binary --- Cargo.lock | 250 ++++++++++++++++++++++++----------------- client-native-rift/src/main.rs | 1 - server/Cargo.toml | 7 +- server/src/assets.rs | 37 ++++++ server/src/main.rs | 9 +- 5 files changed, 195 insertions(+), 109 deletions(-) create mode 100644 server/src/assets.rs (limited to 'server/Cargo.toml') diff --git a/Cargo.lock b/Cargo.lock index 267b1b6..b3e1803 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "ab_glyph" -version = "0.2.19" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5568a4aa5ba8adf5175c5c460b030e27d8893412976cc37bef0e4fbc16cfbba" +checksum = "fe21446ad43aa56417a767f3e2f3d7c4ca522904de1dd640529a76e9c5c3b33c" dependencies = [ "ab_glyph_rasterizer", "owned_ttf_parser", @@ -63,7 +63,7 @@ dependencies = [ "once_cell", "parking_lot", "paste", - "windows 0.42.0", + "windows", ] [[package]] @@ -212,9 +212,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf6ccdb167abbf410dcb915cabd428929d7f6a04980b54a11f26a39f1c7f7107" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", "once_cell", @@ -448,9 +448,9 @@ checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" [[package]] name = "async-trait" -version = "0.1.61" +version = "0.1.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "705339e0e4a9690e2908d2b3d049d85682cf19fbd5782494498fbf7003a6a282" +checksum = "1cd7fce9ba8c3c042128ce72d8b2ddbf3a05747efb67ea0313c635e10bda47a2" dependencies = [ "proc-macro2", "quote", @@ -605,18 +605,18 @@ checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" [[package]] name = "bytemuck" -version = "1.12.3" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaa3a8d9a1ca92e282c96a32d6511b695d7d994d1d102ba85d279f9b2756947f" +checksum = "c041d3eab048880cb0b86b256447da3f18859a163c3b8d8893f4e6368abe6393" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fe233b960f12f8007e3db2d136e3cb1c291bfd7396e384ee76025fc1a3932b4" +checksum = "1aca418a974d83d40a0c1f0c5cba6ff4bc28d8df099109ca459a2118d40b6322" dependencies = [ "proc-macro2", "quote", @@ -937,9 +937,9 @@ checksum = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba" [[package]] name = "crc" -version = "3.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53757d12b596c16c78b83458d732a5d1a17ab3f53f2f7412f6fb57cc8a140ab3" +checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" dependencies = [ "crc-catalog", ] @@ -1112,12 +1112,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0dd3cd20dc6b5a876612a6e5accfe7f3dd883db6d07acfbf14c128f61550dfa" +checksum = "c0808e1bd8671fb44a113a14e13497557533369847788fa2ae912b6ebfce9fa8" dependencies = [ - "darling_core 0.14.2", - "darling_macro 0.14.2", + "darling_core 0.14.3", + "darling_macro 0.14.3", ] [[package]] @@ -1136,9 +1136,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a784d2ccaf7c98501746bf0be29b2022ba41fd62a2e622af997a03e9f972859f" +checksum = "001d80444f28e193f30c2f293455da62dcf9a6b29918a4253152ae2b1de592cb" dependencies = [ "fnv", "ident_case", @@ -1161,11 +1161,11 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7618812407e9402654622dd402b0a89dff9ba93badd6540781526117b92aab7e" +checksum = "b36230598a2d5de7ec1c6f51f72d8a99a9208daff41de2084d06e3fd3ea56685" dependencies = [ - "darling_core 0.14.2", + "darling_core 0.14.3", "quote", "syn", ] @@ -1229,7 +1229,7 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f91d4cfa921f1c05904dc3c57b4a32c38aed3340cce209f3a6fd1478babafc4" dependencies = [ - "darling 0.14.2", + "darling 0.14.3", "proc-macro2", "quote", "syn", @@ -1470,7 +1470,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03e7b551eba279bf0fa88b83a46330168c1560a52a94f5126f892f0b364ab3e0" dependencies = [ - "darling 0.14.2", + "darling 0.14.3", "proc-macro2", "quote", "syn", @@ -1672,9 +1672,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" +checksum = "13e2792b0ff0340399d58445b88fd9770e3489eff258a4cbc1523418f12abf84" dependencies = [ "futures-channel", "futures-core", @@ -1703,9 +1703,9 @@ checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" [[package]] name = "futures-executor" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" +checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e" dependencies = [ "futures-core", "futures-task", @@ -1865,9 +1865,9 @@ dependencies = [ [[package]] name = "gloo-timers" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98c4a8d6391675c6b2ee1a6c8d06e8e2d03605c44cec1270675985a4c2a5500b" +checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" dependencies = [ "futures-channel", "futures-core", @@ -1889,42 +1889,42 @@ dependencies = [ [[package]] name = "glutin" -version = "0.30.3" +version = "0.30.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524d807cd49a0c56a53ef9a6738cd15e7c8c4e9d37a3b7fdb3c250c1cd5bf7a3" +checksum = "373e3fbcfa6b9c313faa03625a08268168ba9be1003d1ecfcebd5266388aa131" dependencies = [ "bitflags", "cfg_aliases", "cgl", - "cocoa", "core-foundation", + "dispatch", "glutin_egl_sys", "glutin_glx_sys", "glutin_wgl_sys", "libloading", - "objc", + "objc2", "once_cell", "raw-window-handle 0.5.0", "wayland-sys 0.30.1", - "windows-sys 0.36.1", + "windows-sys 0.45.0", "x11-dl", ] [[package]] name = "glutin_egl_sys" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3adbb8fec0e18e340f990c78f79f5f0e142d0d83f46b10909aaa7d251c00afdf" +checksum = "e5aaf0abb5c4148685b33101ae326a207946b4d3764d6cdc79f8316cdaa8367d" dependencies = [ "gl_generator", - "windows-sys 0.36.1", + "windows-sys 0.45.0", ] [[package]] name = "glutin_glx_sys" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "947c4850c58211c9627969c2b4e2674764b81ae5b47bab2c9a477d7942f96e0f" +checksum = "1b53cb5fe568964aa066a3ba91eac5ecbac869fb0842cd0dc9e412434f1a1494" dependencies = [ "gl_generator", "x11-dl", @@ -1932,9 +1932,9 @@ dependencies = [ [[package]] name = "glutin_wgl_sys" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20c33975a6c9d49d72c8f032a60079bf8df536954fbf9e4cee90396ace815c57" +checksum = "ef89398e90033fc6bc65e9bd42fd29bbbfd483bda5b56dc5562f455550618165" dependencies = [ "gl_generator", ] @@ -2002,9 +2002,9 @@ dependencies = [ [[package]] name = "heck" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" @@ -2148,6 +2148,25 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "include_dir" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18762faeff7122e89e0857b02f7ce6fcc0d101d5e9ad2ad7846cc01d61b7f19e" +dependencies = [ + "include_dir_macros", +] + +[[package]] +name = "include_dir_macros" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b139284b5cf57ecfa712bcc66950bb635b31aff41c188e8a4cfc758eca374a3f" +dependencies = [ + "proc-macro2", + "quote", +] + [[package]] name = "indexmap" version = "1.9.2" @@ -2266,9 +2285,9 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "js-sys" -version = "0.3.60" +version = "0.3.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" dependencies = [ "wasm-bindgen", ] @@ -2310,6 +2329,7 @@ dependencies = [ "env_logger", "futures-util", "hyper", + "include_dir", "listenfd", "log", "serde", @@ -2628,6 +2648,15 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nom8" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8" +dependencies = [ + "memchr", +] + [[package]] name = "num-bigint" version = "0.4.3" @@ -2670,18 +2699,18 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.5.7" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9" +checksum = "8d829733185c1ca374f17e52b762f24f535ec625d2cc1f070e34c8a9068f341b" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.5.7" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce" +checksum = "2be1598bf1c313dcdd12092e3f1920f463462525a21b7b4e11b4168353d0123e" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2794,9 +2823,9 @@ checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" [[package]] name = "owned_ttf_parser" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a5f3c7ca08b6879e7965fb25e24d1f5eeb32ea73f9ad99b3854778a38c57e93" +checksum = "e25e9fb15717794fae58ab55c26e044103aad13186fbb625893f9a3bbcc24228" dependencies = [ "ttf-parser", ] @@ -3005,13 +3034,12 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro-crate" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" +checksum = "66618389e4ec1c7afe67d51a9bf34ff9236480f8d51e7489b7d5ab0303c13f34" dependencies = [ "once_cell", - "thiserror", - "toml", + "toml_edit", ] [[package]] @@ -3401,9 +3429,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.7.0" +version = "2.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" +checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" dependencies = [ "bitflags", "core-foundation", @@ -3414,9 +3442,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.6.1" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" +checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" dependencies = [ "core-foundation-sys", "libc 0.2.139", @@ -3444,9 +3472,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.91" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" +checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" dependencies = [ "itoa", "ryu", @@ -3547,9 +3575,9 @@ dependencies = [ [[package]] name = "sha256" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e334db67871c14c18fc066ad14af13f9fdf5f9a91c61af432d1e3a39c8c6a141" +checksum = "328169f167261957e83d82be47f9e36629e257c62308129033d7f7e7c173d180" dependencies = [ "hex", "sha2 0.9.9", @@ -3929,12 +3957,20 @@ dependencies = [ ] [[package]] -name = "toml" -version = "0.5.10" +name = "toml_datetime" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5" + +[[package]] +name = "toml_edit" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f" +checksum = "56c59d8dd7d0dcbc6428bf7aa2f0e823e26e43b3c9aca15bbc9475d23e5fa12b" dependencies = [ - "serde", + "indexmap", + "nom8", + "toml_datetime", ] [[package]] @@ -4248,9 +4284,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -4258,9 +4294,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" dependencies = [ "bumpalo", "log", @@ -4273,9 +4309,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.33" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d" +checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" dependencies = [ "cfg-if", "js-sys", @@ -4285,9 +4321,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4295,9 +4331,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", @@ -4308,9 +4344,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" [[package]] name = "wayland-client" @@ -4399,9 +4435,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.60" +version = "0.3.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" +checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" dependencies = [ "js-sys", "wasm-bindgen", @@ -4409,9 +4445,9 @@ dependencies = [ [[package]] name = "webbrowser" -version = "0.8.4" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e74f5ff7786c4c21f61ba8e30ea29c9745f06fca0a4a02d083b3c662583399e8" +checksum = "97d1fa1e5c829b2bf9eb1e28fb950248b797cd6a04866fbdfa8bc31e5eef4c78" dependencies = [ "core-foundation", "dirs", @@ -4422,7 +4458,6 @@ dependencies = [ "raw-window-handle 0.5.0", "url", "web-sys", - "windows 0.43.0", ] [[package]] @@ -4721,21 +4756,6 @@ dependencies = [ "windows_x86_64_msvc 0.42.1", ] -[[package]] -name = "windows" -version = "0.43.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04662ed0e3e5630dfa9b26e4cb823b817f1a9addda855d973a9458c236556244" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.1", - "windows_i686_gnu 0.42.1", - "windows_i686_msvc 0.42.1", - "windows_x86_64_gnu 0.42.1", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.1", -] - [[package]] name = "windows-implement" version = "0.42.0" @@ -4775,6 +4795,30 @@ dependencies = [ "windows_x86_64_msvc 0.42.1", ] +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.1", + "windows_i686_gnu 0.42.1", + "windows_i686_msvc 0.42.1", + "windows_x86_64_gnu 0.42.1", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.1", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.1" @@ -4891,12 +4935,12 @@ dependencies = [ [[package]] name = "x11-dl" -version = "2.20.1" +version = "2.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1536d6965a5d4e573c7ef73a2c15ebcd0b2de3347bdf526c34c297c00ac40f0" +checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f" dependencies = [ - "lazy_static", "libc 0.2.139", + "once_cell", "pkg-config", ] diff --git a/client-native-rift/src/main.rs b/client-native-rift/src/main.rs index 201e91d..1f10b83 100644 --- a/client-native-rift/src/main.rs +++ b/client-native-rift/src/main.rs @@ -23,7 +23,6 @@ use std::{ atomic::{AtomicUsize, Ordering}, Arc, }, - time::Duration, }; use tokio::{ fs::{self, File}, diff --git a/server/Cargo.toml b/server/Cargo.toml index e2b0506..907b8c4 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -12,4 +12,9 @@ futures-util = "0.3.26" listenfd = "1.0.0" hyper = "0.14.24" serde = { version = "1.0.152", features = ["derive"] } -serde_json = "*" +serde_json = "1.0.93" +include_dir = "0.7.3" + +[features] +default = ["standalone"] +standalone = [] diff --git a/server/src/assets.rs b/server/src/assets.rs new file mode 100644 index 0000000..068bc0c --- /dev/null +++ b/server/src/assets.rs @@ -0,0 +1,37 @@ +#[cfg(not(feature = "standalone"))] +#[macro_export] +macro_rules! s_file { + ($path: literal) => { + warp::fs::file($path) + }; +} + +#[cfg(not(feature = "standalone"))] +#[macro_export] +macro_rules! s_asset_dir { + () => { + warp::fs::dir("client-web/public/assets") + }; +} + +#[cfg(feature = "standalone")] +#[macro_export] +macro_rules! s_file { + ($path: literal) => { + warp::get().map(|| include_str!(concat!("../../", $path))) + }; +} + +#[cfg(feature = "standalone")] +#[macro_export] +macro_rules! s_asset_dir { + () => {{ + use include_dir::{include_dir, Dir}; + const DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/../client-web/public/assets"); + warp::path::tail().and_then(|t: warp::path::Tail| async move { + DIR.get_file(t.as_str()) + .map(|f| f.contents_utf8().unwrap()) + .ok_or(warp::reject::not_found()) + }) + }}; +} diff --git a/server/src/main.rs b/server/src/main.rs index 413f23a..518ea99 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -3,6 +3,7 @@ which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2022 metamuffin */ +pub mod assets; pub mod protocol; pub mod room; @@ -41,10 +42,10 @@ async fn run() { .and(warp::ws()) .map(signaling_connect); - let index: _ = warp::path!().and(warp::fs::file("../client-web/public/start.html")); - let room: _ = warp::path!("room").and(warp::fs::file("../client-web/public/app.html")); - let assets: _ = warp::path("assets").and(warp::fs::dir("../client-web/public/assets")); - let sw_script: _ = warp::path("sw.js").and(warp::fs::file("../client-web/public/assets/sw.js")); + let index: _ = warp::path!().and(s_file!("client-web/public/start.html")); + let room: _ = warp::path!("room").and(s_file!("client-web/public/app.html")); + let assets: _ = warp::path("assets").and(s_asset_dir!()); + let sw_script: _ = warp::path("sw.js").and(s_file!("client-web/public/assets/sw.js")); let favicon: _ = warp::path!("favicon.ico").map(|| ""); let old_format_redirect: _ = warp::path!("room" / String).map(|rsecret| { reply::with_header( -- cgit v1.2.3-70-g09d2 From 3096840df9d49a2a53c08314d978d2aa503ade4e Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 11 Feb 2023 10:49:22 +0100 Subject: doc standalone --- readme.md | 4 +++- server/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'server/Cargo.toml') diff --git a/readme.md b/readme.md index 94a1ca0..811e604 100644 --- a/readme.md +++ b/readme.md @@ -37,7 +37,9 @@ When changing code, use `make watch` to re-build things automatically as needed. (run `cargo install systemfd cargo-watch` if needed) The server's bind address can be controlled using the `BIND` environment -variable. +variable. In production you can also activate the `standalone` feature to embed +all assets into the binary; This speeds it up and allows the server to run from +just the binary. If you use this project or have any suggestions, please [contact me](https://metamuffin.org/contact) diff --git a/server/Cargo.toml b/server/Cargo.toml index 907b8c4..4a61294 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -16,5 +16,5 @@ serde_json = "1.0.93" include_dir = "0.7.3" [features] -default = ["standalone"] +default = [] standalone = [] -- cgit v1.2.3-70-g09d2 From 630cd2b82887da49cacb2deb032c6a51b3c2faf7 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 21 Feb 2023 15:12:38 +0100 Subject: server-side client configuration --- .gitignore | 2 ++ Cargo.lock | 48 +++++++++++++++++++++++++++++++++-- client-web/source/index.ts | 38 +++++++++++++++++---------- client-web/source/preferences/decl.ts | 6 +++++ client-web/source/preferences/mod.ts | 1 + client-web/source/room.ts | 2 +- client-web/source/user/remote.ts | 4 +-- server/Cargo.toml | 3 ++- server/src/assets.rs | 4 +-- server/src/config.rs | 20 +++++++++++++++ server/src/main.rs | 14 ++++++++++ 11 files changed, 120 insertions(+), 22 deletions(-) create mode 100644 server/src/config.rs (limited to 'server/Cargo.toml') diff --git a/.gitignore b/.gitignore index ea8c4bf..a37f649 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ /target +/config/client.toml + diff --git a/Cargo.lock b/Cargo.lock index 036d078..5f13e86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2275,6 +2275,7 @@ dependencies = [ "serde", "serde_json", "tokio", + "toml", "warp", ] @@ -2964,7 +2965,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "66618389e4ec1c7afe67d51a9bf34ff9236480f8d51e7489b7d5ab0303c13f34" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.18.1", ] [[package]] @@ -3421,6 +3422,15 @@ dependencies = [ "syn", ] +[[package]] +name = "serde_spanned" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -3887,12 +3897,33 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7afcae9e3f0fe2c370fd4657108972cbb2fa9db1b9f84849cefd80741b01cb6" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime 0.6.1", + "toml_edit 0.19.3", +] + [[package]] name = "toml_datetime" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5" +[[package]] +name = "toml_datetime" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" +dependencies = [ + "serde", +] + [[package]] name = "toml_edit" version = "0.18.1" @@ -3901,7 +3932,20 @@ checksum = "56c59d8dd7d0dcbc6428bf7aa2f0e823e26e43b3c9aca15bbc9475d23e5fa12b" dependencies = [ "indexmap", "nom8", - "toml_datetime", + "toml_datetime 0.5.1", +] + +[[package]] +name = "toml_edit" +version = "0.19.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6a7712b49e1775fb9a7b998de6635b299237f48b404dde71704f2e0e7f37e5" +dependencies = [ + "indexmap", + "nom8", + "serde", + "serde_spanned", + "toml_datetime 0.6.1", ] [[package]] diff --git a/client-web/source/index.ts b/client-web/source/index.ts index 4772f94..4590625 100644 --- a/client-web/source/index.ts +++ b/client-web/source/index.ts @@ -17,18 +17,14 @@ import { Room } from "./room.ts" export const VERSION = "0.1.12" export const ROOM_CONTAINER = esection({ class: "room", aria_label: "user list" }) -export const RTC_CONFIG: RTCConfiguration = { - iceServers: [ - { - urls: [ - "turn:meet.metamuffin.org:16900", - "stun:meet.metamuffin.org:16900" - ], - username: "keksmeet", - credential: "ujCmetg6bm0" - }, - ], - iceCandidatePoolSize: 10, +export interface ClientConfig { + appearance: { accent: string } + webrtc: { + stun: string, + turn?: string, + turn_user?: string, + turn_cred?: string + } } export interface User { @@ -51,7 +47,12 @@ window.onbeforeunload = ev => { let r: Room; export async function main() { document.body.append(LOGGER_CONTAINER) - log("*", "starting up") + log("*", "loading client config") + const config_res = await fetch("/config.json") + if (!config_res.ok) return log({ scope: "*", error: true }, "cannot load config") + const config: ClientConfig = await config_res.json() + log("*", "config loaded. starting") + document.body.querySelectorAll("p").forEach(e => e.remove()) const room_secret = load_params().rsecret @@ -64,7 +65,16 @@ export async function main() { if (PREFS.warn_redirect) log({ scope: "crypto", warn: true }, "You were redirected from the old URL format. The server knows the room secret now - e2ee is insecure!") const conn = await (new SignalingConnection().connect(room_secret)) - r = new Room(conn) + const rtc_config: RTCConfiguration = { + iceCandidatePoolSize: 10, + iceServers: [{ + urls: [config.webrtc.stun, ...(config.webrtc.turn ? [config.webrtc.turn] : [])], + credential: config.webrtc.turn_cred, + username: config.webrtc.turn_user, + }] + } + + r = new Room(conn, rtc_config) setup_keybinds(r) r.on_ready = () => { diff --git a/client-web/source/preferences/decl.ts b/client-web/source/preferences/decl.ts index f3f8e84..68cb9ee 100644 --- a/client-web/source/preferences/decl.ts +++ b/client-web/source/preferences/decl.ts @@ -18,7 +18,13 @@ export const PREF_DECLS = { username: { type: string, default: "guest-" + hex_id(), description: "Username", allow_url: true }, warn_redirect: { type: bool, hidden: true, default: false, description: "Internal option that is set by a server redirect.", allow_url: true }, image_view_popup: { type: bool, default: true, description: "Open image in popup instead of new tab" }, + + // TODO! + /* WEBRTC */ webrtc_debug: { type: bool, default: false, description: "Show additional information for WebRTC related stuff" }, + webrtc_stun: { type: string, default: "stun:meet.metamuffin.org:16900", description: "Custom STUN server (all participants must use the same server)" }, + webrtc_turn: { type: optional(string), default: "turn:meet.metamuffin.org:16900", description: "Custom TURN server (all participants must use the same server)" }, + webrtc_turn_cred: { type: optional(string), description: "TURN server credentials" }, /* MEDIA */ microphone_enabled: { type: bool, default: false, description: "Add one microphone track on startup" }, diff --git a/client-web/source/preferences/mod.ts b/client-web/source/preferences/mod.ts index 04fae2c..8aefb0f 100644 --- a/client-web/source/preferences/mod.ts +++ b/client-web/source/preferences/mod.ts @@ -15,6 +15,7 @@ export interface PrefDecl { optional?: boolean, hidden?: boolean allow_url?: boolean + require_reload?: boolean, } type Type = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"; diff --git a/client-web/source/room.ts b/client-web/source/room.ts index a685f1d..27d2327 100644 --- a/client-web/source/room.ts +++ b/client-web/source/room.ts @@ -20,7 +20,7 @@ export class Room { public on_ready = () => { }; - constructor(public signaling: SignalingConnection) { + constructor(public signaling: SignalingConnection, public rtc_config: RTCConfiguration) { this.signaling.control_handler = (a) => this.control_handler(a) this.signaling.relay_handler = (a, b) => this.relay_handler(a, b) } diff --git a/client-web/source/user/remote.ts b/client-web/source/user/remote.ts index bd89e0e..5e81cf7 100644 --- a/client-web/source/user/remote.ts +++ b/client-web/source/user/remote.ts @@ -7,7 +7,7 @@ import { RelayMessage } from "../../../common/packets.d.ts"; import { notify } from "../helper.ts"; -import { ROOM_CONTAINER, RTC_CONFIG } from "../index.ts" +import { ROOM_CONTAINER } from "../index.ts" import { log } from "../logger.ts" import { PREFS } from "../preferences/mod.ts"; import { new_remote_resource, RemoteResource } from "../resource/mod.ts"; @@ -28,7 +28,7 @@ export class RemoteUser extends User { room.remote_users.set(id, this) log("usermodel", `added remote user: ${this.display_name}`) - this.pc = new RTCPeerConnection(RTC_CONFIG) + this.pc = new RTCPeerConnection(room.rtc_config) this.pc.onicecandidate = ev => { if (!ev.candidate) return room.signaling.send_relay({ ice_candidate: ev.candidate.toJSON() }, this.id) diff --git a/server/Cargo.toml b/server/Cargo.toml index 4a61294..22413a2 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -warp = "0.3" +warp = "0.3.3" tokio = { version = "1.25", features = ["full"] } log = "0.4" env_logger = "0.10" @@ -14,6 +14,7 @@ hyper = "0.14.24" serde = { version = "1.0.152", features = ["derive"] } serde_json = "1.0.93" include_dir = "0.7.3" +toml = "0.7.2" [features] default = [] diff --git a/server/src/assets.rs b/server/src/assets.rs index 320a4e4..51b0025 100644 --- a/server/src/assets.rs +++ b/server/src/assets.rs @@ -2,7 +2,7 @@ #[macro_export] macro_rules! s_file { ($path: literal, $content_type: literal) => { - warp::fs::file($path) + warp::fs::file(concat!("../", $path)) }; } @@ -10,7 +10,7 @@ macro_rules! s_file { #[macro_export] macro_rules! s_asset_dir { () => { - warp::fs::dir("client-web/public/assets") + warp::fs::dir("../client-web/public/assets") }; } diff --git a/server/src/config.rs b/server/src/config.rs new file mode 100644 index 0000000..9d6213c --- /dev/null +++ b/server/src/config.rs @@ -0,0 +1,20 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ClientConfig { + webrtc: ClientWebrtcConfig, + appearance: ClientAppearanceConfig, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ClientWebrtcConfig { + stun: String, + turn: Option, + turn_user: Option, + turn_cred: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ClientAppearanceConfig { + accent: Option, +} diff --git a/server/src/main.rs b/server/src/main.rs index 61c9ad1..8a0e342 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -4,9 +4,11 @@ Copyright (C) 2022 metamuffin */ pub mod assets; +pub mod config; pub mod protocol; pub mod room; +use config::ClientConfig; use hyper::{header, StatusCode}; use listenfd::ListenFd; use log::{debug, error}; @@ -34,6 +36,10 @@ fn main() { async fn run() { env_logger::init_from_env("LOG"); + let client_config: ClientConfig = toml::from_str(include_str!("../../config/client.toml")) + .expect("client configuration invalid"); + let client_config_json = serde_json::to_string(&client_config).unwrap(); + let rooms: _ = Rooms::default(); let rooms: _ = warp::any().map(move || rooms.clone()); @@ -51,6 +57,13 @@ async fn run() { "client-web/public/assets/sw.js", "application/javascript" )); + let client_config: _ = warp::path!("config.json").map(move || { + warp::reply::with_header( + client_config_json.clone(), + "content-type", + "application/json", + ) + }); let favicon: _ = warp::path!("favicon.ico").map(|| ""); let old_format_redirect: _ = warp::path!("room" / String).map(|rsecret| { reply::with_header( @@ -65,6 +78,7 @@ async fn run() { .or(room) .or(index) .or(signaling) + .or(client_config) .or(favicon) .or(sw_script) .or(old_format_redirect) -- cgit v1.2.3-70-g09d2