From 9dfc929b709d4187dc307f68a42fa058eda7a4c1 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 11 Feb 2023 10:29:02 +0100 Subject: standalone binary --- server/src/assets.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 server/src/assets.rs (limited to 'server/src/assets.rs') 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()) + }) + }}; +} -- cgit v1.2.3-70-g09d2 From 389caf52b7a247301af71a61cc6a1259147efff3 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 11 Feb 2023 10:47:25 +0100 Subject: fix standalone version (and avoid a compiler crash) --- Cargo.lock | 800 +++++++++++++++++++++---------------------- client-native-gui/Cargo.toml | 4 +- client-native-lib/Cargo.toml | 2 +- server/src/assets.rs | 23 +- server/src/main.rs | 6 +- 5 files changed, 420 insertions(+), 415 deletions(-) (limited to 'server/src/assets.rs') diff --git a/Cargo.lock b/Cargo.lock index b3e1803..036d078 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,19 +20,15 @@ checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" [[package]] name = "accesskit" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3083ac5a97521e35388ca80cf365b6be5210962cc59f11ee238cd92ac2fa9524" -dependencies = [ - "enumset", - "kurbo", -] +checksum = "4803cf8c252f374ae6bfbb341e49e5a37f7601f2ce74a105927a663eba952c67" [[package]] name = "accesskit_consumer" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f47393f706a2d2f9d1ebd109351f886afd256a09d2308861a6dec0853a625e2" +checksum = "cee8cf1202a4f94d31837f1902ab0a75c77b65bf59719e093703abe83efd74ec" dependencies = [ "accesskit", "parking_lot", @@ -40,9 +36,9 @@ dependencies = [ [[package]] name = "accesskit_macos" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fabafb94d8a4dd6b20fe4112f943756ff8dc9778e3d742fb5478bf7f000a3282" +checksum = "10be25f2b27bc33aa1647072e86b948b41596f1af1ae43a2b4b9be5d2011cbda" dependencies = [ "accesskit", "accesskit_consumer", @@ -51,15 +47,31 @@ dependencies = [ "parking_lot", ] +[[package]] +name = "accesskit_unix" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630e7ee8f93c6246478bf0df6760db899b28d9ad54353a5f2d3157138ba817fc" +dependencies = [ + "accesskit", + "accesskit_consumer", + "async-channel", + "atspi", + "futures-lite", + "parking_lot", + "serde", + "zbus", +] + [[package]] name = "accesskit_windows" -version = "0.10.4" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "662496f45a2e2ddff05e28d0a9fc2b319cc4f886d3664e3469c3d30800598962" +checksum = "a13c462fabdd950ef14308a9390b07fa2e2e3aabccba1f3ea36ea2231bb942ab" dependencies = [ "accesskit", "accesskit_consumer", - "arrayvec 0.7.2", + "arrayvec", "once_cell", "parking_lot", "paste", @@ -68,12 +80,13 @@ dependencies = [ [[package]] name = "accesskit_winit" -version = "0.7.3" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f270416d033ab5b2a8fa72a976dfdad0db1ea194721f16cadbdb45ff219779f" +checksum = "17727888757ec027ec221db33070e226ee07df44425b583bc67684204d35eff9" dependencies = [ "accesskit", "accesskit_macos", + "accesskit_unix", "accesskit_windows", "parking_lot", "winit", @@ -230,6 +243,30 @@ dependencies = [ "memchr", ] +[[package]] +name = "android-activity" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4165a1aef703232031b40a6e8908c2f9e314d495f11aa7f98db75d39a497cc6a" +dependencies = [ + "android-properties", + "bitflags", + "cc", + "jni-sys", + "libc 0.2.139", + "log", + "ndk", + "ndk-context", + "ndk-sys", + "num_enum", +] + +[[package]] +name = "android-properties" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" + [[package]] name = "anyhow" version = "1.0.69" @@ -266,12 +303,6 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" -[[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" - [[package]] name = "arrayvec" version = "0.7.2" @@ -344,6 +375,17 @@ dependencies = [ "syn", ] +[[package]] +name = "async-broadcast" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b19760fa2b7301cf235360ffd6d3558b1ed4249edd16d6cca8d690cee265b95" +dependencies = [ + "event-listener", + "futures-core", + "parking_lot", +] + [[package]] name = "async-channel" version = "1.8.0" @@ -414,6 +456,17 @@ dependencies = [ "futures-lite", ] +[[package]] +name = "async-recursion" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b015a331cc64ebd1774ba119538573603427eaace0a1950c423ab971f903796" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "async-std" version = "1.12.0" @@ -469,6 +522,38 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "857253367827bd9d0fd973f0ef15506a96e79e41b0ad7aa691203a4e3214f6c8" +[[package]] +name = "atspi" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab84c09a770065868da0d713f1f4b35af85d96530a868f1c1a6c249178379187" +dependencies = [ + "async-recursion", + "async-trait", + "atspi-macros", + "enumflags2", + "futures-lite", + "serde", + "tracing", + "zbus", + "zbus_names", +] + +[[package]] +name = "atspi-macros" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3ebc5a6f61f6996eca56a4cece7b3fe7da3b86f0473c7b71ab44e229f3acce4" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "syn", + "zbus", + "zbus_names", + "zvariant", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -653,6 +738,9 @@ name = "cc" version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" +dependencies = [ + "jobserver", +] [[package]] name = "ccm" @@ -789,46 +877,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "cmake" -version = "0.1.49" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db34956e100b30725f2eb215f90d4871051239535632f84fea3bc92722c66b7c" -dependencies = [ - "cc", -] - -[[package]] -name = "cocoa" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f425db7937052c684daec3bd6375c8abe2d146dca4b8b143d6db777c39138f3a" -dependencies = [ - "bitflags", - "block", - "cocoa-foundation", - "core-foundation", - "core-graphics", - "foreign-types 0.3.2", - "libc 0.2.139", - "objc", -] - -[[package]] -name = "cocoa-foundation" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ade49b65d560ca58c403a479bb396592b155c0185eada742ee323d1d68d6318" -dependencies = [ - "bitflags", - "block", - "core-foundation", - "core-graphics-types", - "foreign-types 0.3.2", - "libc 0.2.139", - "objc", -] - [[package]] name = "combine" version = "4.6.6" @@ -892,7 +940,7 @@ dependencies = [ "bitflags", "core-foundation", "core-graphics-types", - "foreign-types 0.3.2", + "foreign-types", "libc 0.2.139", ] @@ -904,19 +952,7 @@ checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b" dependencies = [ "bitflags", "core-foundation", - "foreign-types 0.3.2", - "libc 0.2.139", -] - -[[package]] -name = "core-text" -version = "19.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d74ada66e07c1cefa18f8abfba765b486f250de2e4a999e5727fc0dd4b4a25" -dependencies = [ - "core-foundation", - "core-graphics", - "foreign-types 0.3.2", + "foreign-types", "libc 0.2.139", ] @@ -978,29 +1014,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossfont" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21fd3add36ea31aba1520aa5288714dd63be506106753226d0eb387a93bc9c45" -dependencies = [ - "cocoa", - "core-foundation", - "core-foundation-sys", - "core-graphics", - "core-text", - "dwrote", - "foreign-types 0.5.0", - "freetype-rs", - "libc 0.2.139", - "log", - "objc", - "once_cell", - "pkg-config", - "servo-fontconfig", - "winapi", -] - [[package]] name = "crypto-bigint" version = "0.4.9" @@ -1100,38 +1113,14 @@ dependencies = [ "zeroize", ] -[[package]] -name = "darling" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" -dependencies = [ - "darling_core 0.13.4", - "darling_macro 0.13.4", -] - [[package]] name = "darling" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0808e1bd8671fb44a113a14e13497557533369847788fa2ae912b6ebfce9fa8" dependencies = [ - "darling_core 0.14.3", - "darling_macro 0.14.3", -] - -[[package]] -name = "darling_core" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn", + "darling_core", + "darling_macro", ] [[package]] @@ -1148,24 +1137,13 @@ dependencies = [ "syn", ] -[[package]] -name = "darling_macro" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" -dependencies = [ - "darling_core 0.13.4", - "quote", - "syn", -] - [[package]] name = "darling_macro" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b36230598a2d5de7ec1c6f51f72d8a99a9208daff41de2084d06e3fd3ea56685" dependencies = [ - "darling_core 0.14.3", + "darling_core", "quote", "syn", ] @@ -1214,6 +1192,17 @@ dependencies = [ "rusticata-macros", ] +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "derive_builder" version = "0.11.2" @@ -1229,7 +1218,7 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f91d4cfa921f1c05904dc3c57b4a32c38aed3340cce209f3a6fd1478babafc4" dependencies = [ - "darling 0.14.3", + "darling", "proc-macro2", "quote", "syn", @@ -1317,20 +1306,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" -[[package]] -name = "dwrote" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439a1c2ba5611ad3ed731280541d36d2e9c4ac5e7fb818a27b604bdc5a6aa65b" -dependencies = [ - "lazy_static", - "libc 0.2.139", - "serde", - "serde_derive", - "winapi", - "wio", -] - [[package]] name = "ecdsa" version = "0.14.8" @@ -1345,18 +1320,18 @@ dependencies = [ [[package]] name = "ecolor" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b601108bca3af7650440ace4ca55b2daf52c36f2635be3587d77b16efd8d0691" +checksum = "1f99fe3cac305af9d6d92971af60d0f7ea4d783201ef1673571567b6699964d9" dependencies = [ "bytemuck", ] [[package]] name = "eframe" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea929ec5819fef373728bb0e55003ce921975039cfec3ca8305bb024e5b7b32" +checksum = "d07e59d9d5ba69e1d261c76e6aa88a95601375805ee473de5eb3163bf5a57704" dependencies = [ "bytemuck", "egui", @@ -1364,9 +1339,11 @@ dependencies = [ "egui_glow", "glow", "glutin", + "glutin-winit", "js-sys", "percent-encoding", - "raw-window-handle 0.5.0", + "raw-window-handle", + "thiserror", "tracing", "wasm-bindgen", "wasm-bindgen-futures", @@ -1376,9 +1353,9 @@ dependencies = [ [[package]] name = "egui" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65a5e883a316e53866977450eecfbcac9c48109c2ab3394af29feb83fcde4ea9" +checksum = "6412a21e0bde7c0918f7fb44bbbb86b5e1f88e63c026a4e747cc7af02f76dfbe" dependencies = [ "accesskit", "ahash", @@ -1389,11 +1366,12 @@ dependencies = [ [[package]] name = "egui-winit" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5696bdbe60898b81157f07ae34fe02dbfd522174bd6e620942c269cd7307901f" +checksum = "c13deffe034ab864042f00d0d1fa220b86bb9a230a7362b81844bb8d1dc6b899" dependencies = [ "accesskit_winit", + "android-activity", "arboard", "egui", "instant", @@ -1405,9 +1383,9 @@ dependencies = [ [[package]] name = "egui_glow" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d4b5960cb1bae1c403a6c9027a745210a41913433b10c73b6e7d76a1017f8b4" +checksum = "8257332fb168a965b3dca81d6a344e053153773c889cabdba0b3b76f1629ae81" dependencies = [ "bytemuck", "egui", @@ -1442,9 +1420,9 @@ dependencies = [ [[package]] name = "emath" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5277249c8c3430e7127e4f2c40a77485e7baf11ae132ce9b3253a8ed710df0a0" +checksum = "b8ecd80612937e0267909d5351770fe150004e24dab93954f69ca62eecd3f77e" dependencies = [ "bytemuck", ] @@ -1456,21 +1434,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] -name = "enumset" -version = "1.0.12" +name = "enumflags2" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19be8061a06ab6f3a6cf21106c873578bf01bd42ad15e0311a9c76161cb1c753" +checksum = "e75d4cd21b95383444831539909fbb14b9dc3fdceb2a6f5d36577329a1f55ccb" dependencies = [ - "enumset_derive", + "enumflags2_derive", + "serde", ] [[package]] -name = "enumset_derive" -version = "0.6.1" +name = "enumflags2_derive" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03e7b551eba279bf0fa88b83a46330168c1560a52a94f5126f892f0b364ab3e0" +checksum = "f58dc3c5e468259f19f2d46304a6b28f1c3d034442e14b322d2b850e36f6d5ae" dependencies = [ - "darling 0.14.3", "proc-macro2", "quote", "syn", @@ -1491,9 +1469,9 @@ dependencies = [ [[package]] name = "epaint" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de14b65fe5e423e0058f77a8beb2c863b056d0566d6c4ce0d097aa5814cb705a" +checksum = "12e78b5c58a1f7f621f9d546add2adce20636422c9b251e29f749e8a2f713c95" dependencies = [ "ab_glyph", "ahash", @@ -1542,16 +1520,6 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" -[[package]] -name = "expat-sys" -version = "2.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658f19728920138342f68408b7cf7644d90d4784353d8ebc32e7e8663dbe45fa" -dependencies = [ - "cmake", - "pkg-config", -] - [[package]] name = "fastpbkdf2" version = "0.1.0" @@ -1603,28 +1571,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" dependencies = [ - "foreign-types-shared 0.1.1", -] - -[[package]] -name = "foreign-types" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" -dependencies = [ - "foreign-types-macros", - "foreign-types-shared 0.3.1", -] - -[[package]] -name = "foreign-types-macros" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8469d0d40519bc608ec6863f1cc88f3f1deee15913f2f3b3e573d81ed38cccc" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "foreign-types-shared", ] [[package]] @@ -1633,12 +1580,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" -[[package]] -name = "foreign-types-shared" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" - [[package]] name = "form_urlencoded" version = "1.1.0" @@ -1648,28 +1589,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "freetype-rs" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74eadec9d0a5c28c54bb9882e54787275152a4e36ce206b45d7451384e5bf5fb" -dependencies = [ - "bitflags", - "freetype-sys", - "libc 0.2.139", -] - -[[package]] -name = "freetype-sys" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a37d4011c0cc628dfa766fcc195454f4b068d7afdc2adfd28861191d866e731a" -dependencies = [ - "cmake", - "libc 0.2.139", - "pkg-config", -] - [[package]] name = "futures" version = "0.3.26" @@ -1877,9 +1796,9 @@ dependencies = [ [[package]] name = "glow" -version = "0.11.2" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8bd5877156a19b8ac83a29b2306fe20537429d318f3ff0a1a2119f8d9c61919" +checksum = "8edf6019dff2d92ad27c1e3ff82ad50a0aea5b01370353cc928bfdc33e95925c" dependencies = [ "js-sys", "slotmap", @@ -1904,12 +1823,24 @@ dependencies = [ "libloading", "objc2", "once_cell", - "raw-window-handle 0.5.0", + "raw-window-handle", "wayland-sys 0.30.1", "windows-sys 0.45.0", "x11-dl", ] +[[package]] +name = "glutin-winit" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "629a873fc04062830bfe8f97c03773bcd7b371e23bcc465d0a61448cd1588fa4" +dependencies = [ + "cfg_aliases", + "glutin", + "raw-window-handle", + "winit", +] + [[package]] name = "glutin_egl_sys" version = "0.4.0" @@ -2283,6 +2214,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" +[[package]] +name = "jobserver" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" +dependencies = [ + "libc 0.2.139", +] + [[package]] name = "js-sys" version = "0.3.61" @@ -2344,15 +2284,6 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" -[[package]] -name = "kurbo" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a53776d271cfb873b17c618af0298445c88afc52837f3e948fa3fafd131f449" -dependencies = [ - "arrayvec 0.7.2", -] - [[package]] name = "kv-log-macro" version = "1.0.7" @@ -2559,7 +2490,7 @@ dependencies = [ "jni-sys", "ndk-sys", "num_enum", - "raw-window-handle 0.5.0", + "raw-window-handle", "thiserror", ] @@ -2569,35 +2500,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" -[[package]] -name = "ndk-glue" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0434fabdd2c15e0aab768ca31d5b7b333717f03cf02037d5a0a3ff3c278ed67f" -dependencies = [ - "libc 0.2.139", - "log", - "ndk", - "ndk-context", - "ndk-macro", - "ndk-sys", - "once_cell", - "parking_lot", -] - -[[package]] -name = "ndk-macro" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df7ac00c4672f9d5aece54ee3347520b7e20f158656c7db2e6de01902eb7a6c" -dependencies = [ - "darling 0.13.4", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "ndk-sys" version = "0.4.1+23.1.7779620" @@ -2630,6 +2532,7 @@ dependencies = [ "cfg-if", "libc 0.2.139", "memoffset", + "pin-utils", ] [[package]] @@ -2815,6 +2718,28 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "orbclient" +version = "0.3.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba683f1641c11041c59d5d93689187abcab3c1349dc6d9d70c550c9f9360802f" +dependencies = [ + "cfg-if", + "redox_syscall 0.2.16", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "ordered-stream" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "360a24bdacdb7801a1a6af8500392864791c130ebe8bd9a063158cab00040c90" +dependencies = [ + "futures-core", + "pin-project-lite", +] + [[package]] name = "os_str_bytes" version = "6.4.1" @@ -2876,7 +2801,7 @@ checksum = "ba1ef8814b5c993410bb3adfad7a5ed269563e4a2f90c41f5d85be7fb47133bf" dependencies = [ "cfg-if", "libc 0.2.139", - "redox_syscall", + "redox_syscall 0.2.16", "smallvec", "windows-sys 0.42.0", ] @@ -3129,15 +3054,6 @@ dependencies = [ "getrandom 0.2.8", ] -[[package]] -name = "raw-window-handle" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b800beb9b6e7d2df1fe337c9e3d04e3af22a124460fb4c30fcc22c9117cefb41" -dependencies = [ - "cty", -] - [[package]] name = "raw-window-handle" version = "0.5.0" @@ -3169,6 +3085,15 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_syscall" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb02a9aee8e8c7ad8d86890f1e16b49e0bbbffc9961ff3788c31d57c98bcbf03" +dependencies = [ + "bitflags", +] + [[package]] name = "redox_users" version = "0.4.3" @@ -3176,7 +3101,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ "getrandom 0.2.8", - "redox_syscall", + "redox_syscall 0.2.16", "thiserror", ] @@ -3334,15 +3259,6 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" -[[package]] -name = "safe_arch" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ff3d6d9696af502cc3110dacce942840fb06ff4514cad92236ecc455f2ce05" -dependencies = [ - "bytemuck", -] - [[package]] name = "safemem" version = "0.3.3" @@ -3391,12 +3307,13 @@ dependencies = [ [[package]] name = "sctk-adwaita" -version = "0.4.3" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61270629cc6b4d77ec1907db1033d5c2e1a404c412743621981a871dc9c12339" +checksum = "cc56402866c717f54e48b122eb93c69f709bc5a6359c403598992fd92f017931" dependencies = [ - "crossfont", + "ab_glyph", "log", + "memmap2", "smithay-client-toolkit", "tiny-skia", ] @@ -3459,6 +3376,18 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-xml-rs" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0bf1ba0696ccf0872866277143ff1fd14d22eec235d2b23702f95e6660f7dfa" +dependencies = [ + "log", + "serde", + "thiserror", + "xml-rs", +] + [[package]] name = "serde_derive" version = "1.0.152" @@ -3481,6 +3410,17 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a5ec9fa74a20ebbe5d9ac23dac1fc96ba0ecfe9f50f2843b52e537b10fbcb4e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -3493,27 +3433,6 @@ dependencies = [ "serde", ] -[[package]] -name = "servo-fontconfig" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7e3e22fe5fd73d04ebf0daa049d3efe3eae55369ce38ab16d07ddd9ac5c217c" -dependencies = [ - "libc 0.2.139", - "servo-fontconfig-sys", -] - -[[package]] -name = "servo-fontconfig-sys" -version = "5.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36b879db9892dfa40f95da1c38a835d41634b825fbd8c4c418093d53c24b388" -dependencies = [ - "expat-sys", - "freetype-sys", - "pkg-config", -] - [[package]] name = "sha-1" version = "0.9.8" @@ -3681,12 +3600,24 @@ dependencies = [ "der", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "str-buf" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0" +[[package]] +name = "strict-num" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9df65f20698aeed245efdde3628a6b559ea1239bbb871af1b6e3b58c413b2bd1" + [[package]] name = "strsim" version = "0.10.0" @@ -3759,7 +3690,7 @@ dependencies = [ "cfg-if", "fastrand", "libc 0.2.139", - "redox_syscall", + "redox_syscall 0.2.16", "remove_dir_all", "winapi", ] @@ -3822,27 +3753,27 @@ dependencies = [ [[package]] name = "tiny-skia" -version = "0.7.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "642680569bb895b16e4b9d181c60be1ed136fa0c9c7f11d004daf053ba89bf82" +checksum = "bfef3412c6975196fdfac41ef232f910be2bb37b9dd3313a49a1a6bc815a5bdb" dependencies = [ "arrayref", - "arrayvec 0.5.2", + "arrayvec", "bytemuck", "cfg-if", "png", - "safe_arch", "tiny-skia-path", ] [[package]] name = "tiny-skia-path" -version = "0.7.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c114d32f0c2ee43d585367cb013dfaba967ab9f62b90d9af0d696e955e70fa6c" +checksum = "a4b5edac058fc98f51c935daea4d805b695b38e2f151241cad125ade2a2ac20d" dependencies = [ "arrayref", "bytemuck", + "strict-num", ] [[package]] @@ -3988,9 +3919,21 @@ dependencies = [ "cfg-if", "log", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tracing-core" version = "0.1.30" @@ -4087,6 +4030,16 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +[[package]] +name = "uds_windows" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce65604324d3cce9b966701489fbd0cf318cb1f7bd9dd07ac9a4ee6fb791930d" +dependencies = [ + "tempfile", + "winapi", +] + [[package]] name = "unicase" version = "2.6.0" @@ -4455,7 +4408,7 @@ dependencies = [ "log", "ndk-context", "objc", - "raw-window-handle 0.5.0", + "raw-window-handle", "url", "web-sys", ] @@ -4748,12 +4701,12 @@ checksum = "0286ba339aa753e70765d521bb0242cc48e1194562bfa2a2ad7ac8a6de28f5d5" dependencies = [ "windows-implement", "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_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.1", + "windows_x86_64_msvc", ] [[package]] @@ -4767,19 +4720,6 @@ dependencies = [ "syn", ] -[[package]] -name = "windows-sys" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" -dependencies = [ - "windows_aarch64_msvc 0.36.1", - "windows_i686_gnu 0.36.1", - "windows_i686_msvc 0.36.1", - "windows_x86_64_gnu 0.36.1", - "windows_x86_64_msvc 0.36.1", -] - [[package]] name = "windows-sys" version = "0.42.0" @@ -4787,12 +4727,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" 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_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.1", + "windows_x86_64_msvc", ] [[package]] @@ -4811,12 +4751,12 @@ 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_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.1", + "windows_x86_64_msvc", ] [[package]] @@ -4825,48 +4765,24 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" -[[package]] -name = "windows_aarch64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" - [[package]] name = "windows_aarch64_msvc" version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" -[[package]] -name = "windows_i686_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" - [[package]] name = "windows_i686_gnu" version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" -[[package]] -name = "windows_i686_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" - [[package]] name = "windows_i686_msvc" version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" -[[package]] -name = "windows_x86_64_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" - [[package]] name = "windows_x86_64_gnu" version = "0.42.1" @@ -4879,12 +4795,6 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" -[[package]] -name = "windows_x86_64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" - [[package]] name = "windows_x86_64_msvc" version = "0.42.1" @@ -4893,12 +4803,13 @@ checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" [[package]] name = "winit" -version = "0.27.5" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb796d6fbd86b2fd896c9471e6f04d39d750076ebe5680a3958f00f5ab97657c" +checksum = "0c4755d4ba0e3d30fc7beef2095e246b1e6a6fad0717608bcb87a2df4b003bcf" dependencies = [ + "android-activity", "bitflags", - "cocoa", + "cfg_aliases", "core-foundation", "core-graphics", "dispatch", @@ -4907,32 +4818,24 @@ dependencies = [ "log", "mio", "ndk", - "ndk-glue", - "objc", + "objc2", "once_cell", - "parking_lot", + "orbclient", "percent-encoding", - "raw-window-handle 0.4.3", - "raw-window-handle 0.5.0", + "raw-window-handle", + "redox_syscall 0.3.4", "sctk-adwaita", "smithay-client-toolkit", "wasm-bindgen", "wayland-client", + "wayland-commons", "wayland-protocols", + "wayland-scanner", "web-sys", - "windows-sys 0.36.1", + "windows-sys 0.45.0", "x11-dl", ] -[[package]] -name = "wio" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5" -dependencies = [ - "winapi", -] - [[package]] name = "x11-dl" version = "2.21.0" @@ -5020,6 +4923,69 @@ dependencies = [ "time", ] +[[package]] +name = "zbus" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f1a9e02a5659c712de386c2af5156c51a530fac0668d3ff85fa26a2bc006ba" +dependencies = [ + "async-broadcast", + "async-executor", + "async-io", + "async-lock", + "async-recursion", + "async-task", + "async-trait", + "byteorder", + "derivative", + "dirs", + "enumflags2", + "event-listener", + "futures-core", + "futures-sink", + "futures-util", + "hex", + "nix 0.25.1", + "once_cell", + "ordered-stream", + "rand", + "serde", + "serde-xml-rs", + "serde_repr", + "sha1", + "static_assertions", + "tracing", + "uds_windows", + "winapi", + "zbus_macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zbus_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "414cd9f07964695e00bfef8e589d1752ea0480b8a619f2064cbaccb8a6c2ed59" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "regex", + "syn", +] + +[[package]] +name = "zbus_names" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f34f314916bd89bdb9934154627fab152f4f28acdda03e7c4c68181b214fe7e3" +dependencies = [ + "serde", + "static_assertions", + "zvariant", +] + [[package]] name = "zeroize" version = "1.5.7" @@ -5040,3 +5006,29 @@ dependencies = [ "syn", "synstructure", ] + +[[package]] +name = "zvariant" +version = "3.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "576cc41e65c7f283e5460f5818073e68fb1f1631502b969ef228c2e03c862efb" +dependencies = [ + "byteorder", + "enumflags2", + "libc 0.2.139", + "serde", + "static_assertions", + "zvariant_derive", +] + +[[package]] +name = "zvariant_derive" +version = "3.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fd4aafc0dee96ae7242a24249ce9babf21e1562822f03df650d4e68c20e41ed" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] diff --git a/client-native-gui/Cargo.toml b/client-native-gui/Cargo.toml index 767433c..6d76e15 100644 --- a/client-native-gui/Cargo.toml +++ b/client-native-gui/Cargo.toml @@ -14,8 +14,8 @@ log = "0.4" anyhow = "1.0.69" crossbeam-channel = "0.5.6" -egui = "0.20.1" -eframe = "0.20.1" +egui = "0.21.0" +eframe = "0.21.0" libmpv = { git = "https://github.com/sirno/libmpv-rs.git", branch = "upgrade-libmpv" } diff --git a/client-native-lib/Cargo.toml b/client-native-lib/Cargo.toml index c9b0ea4..c7c36d5 100644 --- a/client-native-lib/Cargo.toml +++ b/client-native-lib/Cargo.toml @@ -18,7 +18,7 @@ log = "0.4" fastpbkdf2 = "0.1.0" aes-gcm = "0.10.1" -sha256 = "1.1.1" +sha256 = "1.1.2" rand = "0.8.5" rand_chacha = "0.3.1" base64 = "0.21.0" diff --git a/server/src/assets.rs b/server/src/assets.rs index 068bc0c..bdd7ef9 100644 --- a/server/src/assets.rs +++ b/server/src/assets.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "standalone"))] #[macro_export] macro_rules! s_file { - ($path: literal) => { + ($path: literal, $content_type: literal) => { warp::fs::file($path) }; } @@ -17,8 +17,14 @@ macro_rules! s_asset_dir { #[cfg(feature = "standalone")] #[macro_export] macro_rules! s_file { - ($path: literal) => { - warp::get().map(|| include_str!(concat!("../../", $path))) + ($path: literal, $content_type: literal) => { + warp::any().map(|| { + warp::reply::with_header( + include_str!(concat!("../../", $path)), + "content-type", + $content_type, + ) + }) }; } @@ -29,8 +35,15 @@ 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()) + let path = t.as_str(); + let content_type = match &path { + _ if path.ends_with(".wasm") => "application/wasm", + _ if path.ends_with(".js") => "application/javascript", + _ if path.ends_with(".css") => "text/css", + _ => "application/octet-stream", + }; + DIR.get_file(path) + .map(|f| warp::reply::with_header(f.contents(), "content-type", content_type)) .ok_or(warp::reject::not_found()) }) }}; diff --git a/server/src/main.rs b/server/src/main.rs index 518ea99..c818eb5 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -42,10 +42,10 @@ async fn run() { .and(warp::ws()) .map(signaling_connect); - 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 index: _ = warp::path!().and(s_file!("client-web/public/start.html", "text/html")); + let room: _ = warp::path!("room").and(s_file!("client-web/public/app.html", "text/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 sw_script: _ = warp::path("sw.js").and(s_file!("client-web/public/assets/sw.js", "application/javascript")); 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 006c683f41fa9a6b7ce0032e3fb25b0b494222e3 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 11 Feb 2023 12:05:30 +0100 Subject: set svg content type --- server/src/assets.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'server/src/assets.rs') diff --git a/server/src/assets.rs b/server/src/assets.rs index bdd7ef9..320a4e4 100644 --- a/server/src/assets.rs +++ b/server/src/assets.rs @@ -40,6 +40,7 @@ macro_rules! s_asset_dir { _ if path.ends_with(".wasm") => "application/wasm", _ if path.ends_with(".js") => "application/javascript", _ if path.ends_with(".css") => "text/css", + _ if path.ends_with(".svg") => "image/svg+xml", _ => "application/octet-stream", }; DIR.get_file(path) -- 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/src/assets.rs') 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