diff --git a/Cargo.lock b/Cargo.lock index 2ac73d24..be7fee11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,211 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "actix-codec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f7b0a21988c1bf877cf4759ef5ddaac04c1c9fe808c9142ecb78ba97d97a28a" +dependencies = [ + "bitflags 2.6.0", + "bytes", + "futures-core", + "futures-sink", + "memchr", + "pin-project-lite", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "actix-files" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0773d59061dedb49a8aed04c67291b9d8cf2fe0b60130a381aab53c6dd86e9be" +dependencies = [ + "actix-http", + "actix-service", + "actix-utils", + "actix-web", + "bitflags 2.6.0", + "bytes", + "derive_more", + "futures-core", + "http-range", + "log", + "mime", + "mime_guess", + "percent-encoding", + "pin-project-lite", + "v_htmlescape", +] + +[[package]] +name = "actix-http" +version = "3.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ae682f693a9cd7b058f2b0b5d9a6d7728a8555779bedbbc35dd88528611d020" +dependencies = [ + "actix-codec", + "actix-rt", + "actix-service", + "actix-utils", + "ahash 0.8.11", + "base64 0.22.1", + "bitflags 2.6.0", + "brotli", + "bytes", + "bytestring", + "derive_more", + "encoding_rs", + "flate2", + "futures-core", + "h2", + "http 0.2.12", + "httparse", + "httpdate", + "itoa", + "language-tags", + "local-channel", + "mime", + "percent-encoding", + "pin-project-lite", + "rand", + "sha1", + "smallvec", + "tokio", + "tokio-util", + "tracing", + "zstd", +] + +[[package]] +name = "actix-macros" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" +dependencies = [ + "quote", + "syn 2.0.70", +] + +[[package]] +name = "actix-router" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d324164c51f63867b57e73ba5936ea151b8a41a1d23d1031eeb9f70d0236f8" +dependencies = [ + "bytestring", + "cfg-if", + "http 0.2.12", + "regex", + "regex-lite", + "serde", + "tracing", +] + +[[package]] +name = "actix-rt" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eda4e2a6e042aa4e55ac438a2ae052d3b5da0ecf83d7411e1a368946925208" +dependencies = [ + "futures-core", + "tokio", +] + +[[package]] +name = "actix-server" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b02303ce8d4e8be5b855af6cf3c3a08f3eff26880faad82bab679c22d3650cb5" +dependencies = [ + "actix-rt", + "actix-service", + "actix-utils", + "futures-core", + "futures-util", + "mio", + "socket2 0.5.7", + "tokio", + "tracing", +] + +[[package]] +name = "actix-service" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b894941f818cfdc7ccc4b9e60fa7e53b5042a2e8567270f9147d5591893373a" +dependencies = [ + "futures-core", + "paste", + "pin-project-lite", +] + +[[package]] +name = "actix-utils" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88a1dcdff1466e3c2488e1cb5c36a71822750ad43839937f85d2f4d9f8b705d8" +dependencies = [ + "local-waker", + "pin-project-lite", +] + +[[package]] +name = "actix-web" +version = "4.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1988c02af8d2b718c05bc4aeb6a66395b7cdf32858c2c71131e5637a8c05a9ff" +dependencies = [ + "actix-codec", + "actix-http", + "actix-macros", + "actix-router", + "actix-rt", + "actix-server", + "actix-service", + "actix-utils", + "actix-web-codegen", + "ahash 0.8.11", + "bytes", + "bytestring", + "cfg-if", + "cookie 0.16.2", + "derive_more", + "encoding_rs", + "futures-core", + "futures-util", + "itoa", + "language-tags", + "log", + "mime", + "once_cell", + "pin-project-lite", + "regex", + "regex-lite", + "serde", + "serde_json", + "serde_urlencoded", + "smallvec", + "socket2 0.5.7", + "time", + "url", +] + +[[package]] +name = "actix-web-codegen" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f591380e2e68490b5dfaf1dd1aa0ebe78d84ba7067078512b4ea6e4492d622b8" +dependencies = [ + "actix-router", + "proc-macro2", + "quote", + "syn 2.0.70", +] + [[package]] name = "addr2line" version = "0.22.0" @@ -56,6 +261,21 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" +[[package]] +name = "alloc-no-stdlib" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" + +[[package]] +name = "alloc-stdlib" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" +dependencies = [ + "alloc-no-stdlib", +] + [[package]] name = "allocator-api2" version = "0.2.18" @@ -270,6 +490,17 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "async-recursion" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.70", +] + [[package]] name = "async-std" version = "1.12.0" @@ -286,7 +517,7 @@ dependencies = [ "futures-core", "futures-io", "futures-lite 1.13.0", - "gloo-timers", + "gloo-timers 0.2.6", "kv-log-macro", "log", "memchr", @@ -351,6 +582,36 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +[[package]] +name = "attribute-derive" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f1ee502851995027b06f99f5ffbeffa1406b38d0b318a1ebfa469332c6cbafd" +dependencies = [ + "attribute-derive-macro", + "derive-where", + "manyhow", + "proc-macro2", + "quote", + "syn 2.0.70", +] + +[[package]] +name = "attribute-derive-macro" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3601467f634cfe36c4780ca9c75dea9a5b34529c1f2810676a337e7e0997f954" +dependencies = [ + "collection_literals", + "interpolator", + "manyhow", + "proc-macro-utils", + "proc-macro2", + "quote", + "quote-use", + "syn 2.0.70", +] + [[package]] name = "autocfg" version = "1.3.0" @@ -368,7 +629,7 @@ dependencies = [ "bitflags 1.3.2", "bytes", "futures-util", - "http", + "http 0.2.12", "http-body", "hyper", "itoa", @@ -394,7 +655,7 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http", + "http 0.2.12", "http-body", "mime", "rustversion", @@ -417,7 +678,7 @@ dependencies = [ "governor", "grpc", "hickory-resolver", - "http", + "http 0.2.12", "ip_network", "k256", "lazy_static", @@ -445,7 +706,7 @@ dependencies = [ "tikv-jemallocator", "tokio", "tokio-stream", - "toml", + "toml 0.7.8", "tonic 0.11.0", "tonic-web", "tower-http", @@ -514,6 +775,21 @@ dependencies = [ "serde", ] +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + [[package]] name = "bitflags" version = "1.3.2" @@ -589,13 +865,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3ef8005764f53cd4dca619f5bf64cafd4664dada50ece25e4d81de54c80cc0b" dependencies = [ "once_cell", - "proc-macro-crate", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", "syn 2.0.70", "syn_derive", ] +[[package]] +name = "brotli" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74f7971dbd9326d58187408ab83117d8ac1bb9c17b085fdacd1cf2f598719b6b" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a45bd2e4095a8b518033b128020dd4a55aab1c0a381ba4404a472630f4bc362" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + [[package]] name = "bstr" version = "1.9.1" @@ -646,11 +943,63 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +[[package]] +name = "bytestring" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d80203ea6b29df88012294f62733de21cfeab47f17b41af3a38bc30a03ee72" +dependencies = [ + "bytes", +] + +[[package]] +name = "cached" +version = "0.45.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90eb5776f28a149524d1d8623035760b4454ec881e8cf3838fa8d7e1b11254b3" +dependencies = [ + "cached_proc_macro", + "cached_proc_macro_types", + "hashbrown 0.13.2", + "instant", + "once_cell", + "thiserror", +] + +[[package]] +name = "cached_proc_macro" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c878c71c2821aa2058722038a59a67583a4240524687c6028571c9b395ded61f" +dependencies = [ + "darling 0.14.4", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "cached_proc_macro_types" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ade8366b8bd5ba243f0a58f036cc0ca8a2f069cff1a2351ef1cac6b083e16fc0" + +[[package]] +name = "camino" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0ec6b951b160caa93cc0c7b209e5a3bff7aae9062213451ac99493cd844c239" + [[package]] name = "cc" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaff6f8ce506b9773fa786672d63fc7a191ffea1be33f72bbd4aeacefca9ffc8" +dependencies = [ + "jobserver", + "libc", + "once_cell", +] [[package]] name = "cfg-if" @@ -698,6 +1047,33 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "ciborium" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" + +[[package]] +name = "ciborium-ll" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" +dependencies = [ + "ciborium-io", + "half", +] + [[package]] name = "clap" version = "4.5.9" @@ -744,6 +1120,12 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" +[[package]] +name = "collection_literals" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "186dce98367766de751c42c4f03970fc60fc012296e706ccbb9d5df9b6c1e271" + [[package]] name = "colorchoice" version = "1.0.1" @@ -760,10 +1142,54 @@ dependencies = [ ] [[package]] -name = "const-oid" -version = "0.9.6" +name = "config" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +checksum = "7328b20597b53c2454f0b1919720c25c7339051c02b72b7e05409e00b14132be" +dependencies = [ + "convert_case 0.6.0", + "lazy_static", + "nom", + "pathdiff", + "serde", + "toml 0.8.14", +] + +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "const_format" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a214c7af3d04997541b18d432afaff4c455e79e2029079647e72fc2bd27673" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f6ff08fd20f4f299298a28e2dfa8a8ba1036e6cd2460ac1de7b425d76f2500" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] [[package]] name = "convert_case" @@ -771,6 +1197,37 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "cookie" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" +dependencies = [ + "percent-encoding", + "time", + "version_check", +] + +[[package]] +name = "cookie" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ddef33a339a91ea89fb53151bd0a4689cfce27055c291dfa69945475d22c747" +dependencies = [ + "percent-encoding", + "time", + "version_check", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -811,6 +1268,15 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + [[package]] name = "crossbeam-channel" version = "0.5.13" @@ -835,6 +1301,12 @@ version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "crypto-bigint" version = "0.5.5" @@ -873,8 +1345,18 @@ version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" dependencies = [ - "darling_core", - "darling_macro", + "darling_core 0.14.4", + "darling_macro 0.14.4", +] + +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core 0.20.10", + "darling_macro 0.20.10", ] [[package]] @@ -891,17 +1373,42 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.11.1", + "syn 2.0.70", +] + [[package]] name = "darling_macro" version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" dependencies = [ - "darling_core", + "darling_core 0.14.4", "quote", "syn 1.0.109", ] +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core 0.20.10", + "quote", + "syn 2.0.70", +] + [[package]] name = "dashmap" version = "5.5.3" @@ -921,6 +1428,18 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" +[[package]] +name = "default-struct-builder" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fa90da96b8fd491f5754d1f7a731f73921e3b7aa0ce333c821a0e43666ac14" +dependencies = [ + "darling 0.20.10", + "proc-macro2", + "quote", + "syn 2.0.70", +] + [[package]] name = "der" version = "0.7.9" @@ -953,6 +1472,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive-where" +version = "1.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62d671cc41a825ebabc75757b62d3d168c577f9149b2d49ece1dad1f72119d25" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.70", +] + [[package]] name = "derive_builder" version = "0.12.0" @@ -968,7 +1498,7 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f" dependencies = [ - "darling", + "darling 0.14.4", "proc-macro2", "quote", "syn 1.0.109", @@ -990,7 +1520,7 @@ version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ - "convert_case", + "convert_case 0.4.0", "proc-macro2", "quote", "rustc_version", @@ -1015,6 +1545,12 @@ version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" +[[package]] +name = "drain_filter_polyfill" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "669a445ee724c5c69b1b06fe0b63e70a1c84bc9bb7d9696cd4f4e3ec45050408" + [[package]] name = "ecdsa" version = "0.16.9" @@ -1174,6 +1710,16 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "fancy-regex" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2" +dependencies = [ + "bit-set", + "regex", +] + [[package]] name = "fastrand" version = "1.9.0" @@ -1217,6 +1763,16 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "flate2" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "flume" version = "0.11.0" @@ -1258,6 +1814,43 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "frontend" +version = "0.1.0" +dependencies = [ + "actix-files", + "actix-web", + "anyhow", + "cfg-if", + "console_error_panic_hook", + "gloo", + "grpc", + "http 0.2.12", + "js-sys", + "leptos", + "leptos-use", + "leptos_actix", + "leptos_meta", + "leptos_router", + "prost 0.12.6", + "pulldown-cmark", + "serde", + "serde_qs 0.12.0", + "syntect", + "thiserror", + "tokio", + "toml 0.7.8", + "tonic 0.11.0", + "tonic-build", + "tonic-web-wasm-client", + "tracing", + "tracing-subscriber", + "tracing-web", + "uuid", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "funty" version = "2.0.0" @@ -1431,6 +2024,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "getopts" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" +dependencies = [ + "unicode-width", +] + [[package]] name = "getrandom" version = "0.2.15" @@ -1438,8 +2040,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] @@ -1454,6 +2058,133 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "gloo" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d15282ece24eaf4bd338d73ef580c6714c8615155c4190c781290ee3fa0fd372" +dependencies = [ + "gloo-console", + "gloo-dialogs", + "gloo-events", + "gloo-file", + "gloo-history", + "gloo-net", + "gloo-render", + "gloo-storage", + "gloo-timers 0.3.0", + "gloo-utils", + "gloo-worker", +] + +[[package]] +name = "gloo-console" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a17868f56b4a24f677b17c8cb69958385102fa879418052d60b50bc1727e261" +dependencies = [ + "gloo-utils", + "js-sys", + "serde", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "gloo-dialogs" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4748e10122b01435750ff530095b1217cf6546173459448b83913ebe7815df" +dependencies = [ + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "gloo-events" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27c26fb45f7c385ba980f5fa87ac677e363949e065a083722697ef1b2cc91e41" +dependencies = [ + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "gloo-file" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97563d71863fb2824b2e974e754a81d19c4a7ec47b09ced8a0e6656b6d54bd1f" +dependencies = [ + "gloo-events", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "gloo-history" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "903f432be5ba34427eac5e16048ef65604a82061fe93789f2212afc73d8617d6" +dependencies = [ + "getrandom", + "gloo-events", + "gloo-utils", + "serde", + "serde-wasm-bindgen", + "serde_urlencoded", + "thiserror", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "gloo-net" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43aaa242d1239a8822c15c645f02166398da4f8b5c4bae795c1f5b44e9eee173" +dependencies = [ + "futures-channel", + "futures-core", + "futures-sink", + "gloo-utils", + "http 0.2.12", + "js-sys", + "pin-project", + "serde", + "serde_json", + "thiserror", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "gloo-render" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56008b6744713a8e8d98ac3dcb7d06543d5662358c9c805b4ce2167ad4649833" +dependencies = [ + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "gloo-storage" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbc8031e8c92758af912f9bc08fbbadd3c6f3cfcbf6b64cdf3d6a81f0139277a" +dependencies = [ + "gloo-utils", + "js-sys", + "serde", + "serde_json", + "thiserror", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "gloo-timers" version = "0.2.6" @@ -1466,6 +2197,62 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "gloo-timers" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "gloo-utils" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5555354113b18c547c1d3a98fbf7fb32a9ff4f6fa112ce823a21641a0ba3aa" +dependencies = [ + "js-sys", + "serde", + "serde_json", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "gloo-worker" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "085f262d7604911c8150162529cefab3782e91adb20202e8658f7275d2aefe5d" +dependencies = [ + "bincode", + "futures", + "gloo-utils", + "gloo-worker-macros", + "js-sys", + "pinned", + "serde", + "thiserror", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "gloo-worker-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "956caa58d4857bc9941749d55e4bd3000032d8212762586fa5705632967140e7" +dependencies = [ + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 2.0.70", +] + [[package]] name = "governor" version = "0.6.3" @@ -1523,7 +2310,7 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.12", "indexmap 2.2.6", "slab", "tokio", @@ -1531,6 +2318,16 @@ dependencies = [ "tracing", ] +[[package]] +name = "half" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" +dependencies = [ + "cfg-if", + "crunchy", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -1540,6 +2337,12 @@ dependencies = [ "ahash 0.7.8", ] +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" + [[package]] name = "hashbrown" version = "0.14.5" @@ -1675,6 +2478,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "html-escape" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d1ad449764d627e22bfd7cd5e8868264fc9236e07c752972b4080cd351cb476" +dependencies = [ + "utf8-width", +] + [[package]] name = "http" version = "0.2.12" @@ -1686,6 +2498,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -1693,10 +2516,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.12", "pin-project-lite", ] +[[package]] +name = "http-range" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573" + [[package]] name = "http-range-header" version = "0.3.1" @@ -1732,7 +2561,7 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", + "http 0.2.12", "http-body", "httparse", "httpdate", @@ -1752,7 +2581,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", - "http", + "http 0.2.12", "hyper", "rustls 0.21.12", "tokio", @@ -1860,6 +2689,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "interpolator" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71dd52191aae121e8611f1e8dc3e324dd0dd1dee1e6dd91d10ee07a3cfb4d9d8" + [[package]] name = "inventory" version = "0.3.15" @@ -1931,93 +2766,366 @@ dependencies = [ ] [[package]] -name = "itertools" -version = "0.12.1" +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "jobserver" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +dependencies = [ + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "judger" +version = "0.1.0" +dependencies = [ + "async-stream", + "bytes", + "cgroups-rs", + "derive_builder", + "env_logger", + "fuse3", + "futures-core", + "grpc", + "lazy_static", + "libc", + "log", + "prost 0.12.6", + "prost-types", + "rustix 0.38.34", + "serde", + "spin", + "tar", + "tempfile", + "thiserror", + "tikv-jemallocator", + "tokio", + "tokio-stream", + "toml 0.7.8", + "tonic 0.11.0", + "tower", + "tower-layer", + "uuid", +] + +[[package]] +name = "k256" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "once_cell", + "serdect", + "sha2", + "signature", +] + +[[package]] +name = "kv-log-macro" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" +dependencies = [ + "log", +] + +[[package]] +name = "language-tags" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +dependencies = [ + "spin", +] + +[[package]] +name = "leptos" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5fae88b21265cbb847c891d7cf660e284a1282da15459691992be9358e906fb" +dependencies = [ + "cfg-if", + "leptos_config", + "leptos_dom", + "leptos_macro", + "leptos_reactive", + "leptos_server", + "server_fn", + "tracing", + "typed-builder", + "typed-builder-macro", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "leptos-use" +version = "0.10.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3272d90b77cdbb99e9060f90eb6f5738e56128b2f912db57a50efb006a26e262" +dependencies = [ + "actix-web", + "async-trait", + "cfg-if", + "cookie 0.18.1", + "default-struct-builder", + "futures-util", + "gloo-timers 0.3.0", + "gloo-utils", + "http 0.2.12", + "js-sys", + "lazy_static", + "leptos", + "leptos_actix", + "paste", + "serde", + "serde_json", + "thiserror", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "leptos_actix" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e1c8b5dd701f0354f61997d9efb05c08e7d81077f3b4021a8f2d08ef8738d95" +dependencies = [ + "actix-http", + "actix-web", + "futures", + "leptos", + "leptos_integration_utils", + "leptos_macro", + "leptos_meta", + "leptos_router", + "parking_lot", + "regex", + "serde_json", + "server_fn", + "tokio", + "tracing", +] + +[[package]] +name = "leptos_config" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec33b6f994829469ba7c62bfd5fb572a639071d0de715a41c2aa0df86301a4fa" +dependencies = [ + "config", + "regex", + "serde", + "thiserror", + "typed-builder", +] + +[[package]] +name = "leptos_dom" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "867d2afc153cc0f1d6f775872d5dfc409385f4d8544831ee45f720d88f363e6b" +dependencies = [ + "async-recursion", + "cfg-if", + "drain_filter_polyfill", + "futures", + "getrandom", + "html-escape", + "indexmap 2.2.6", + "itertools 0.12.1", + "js-sys", + "leptos_reactive", + "once_cell", + "pad-adapter", + "paste", + "rustc-hash", + "serde", + "serde_json", + "server_fn", + "smallvec", + "tracing", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "leptos_hot_reload" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec5ce56051f2eff2c4736b7a2056177e67be19597b767ff72fbab20917a7422d" +dependencies = [ + "anyhow", + "camino", + "indexmap 2.2.6", + "parking_lot", + "proc-macro2", + "quote", + "rstml", + "serde", + "syn 2.0.70", + "walkdir", +] + +[[package]] +name = "leptos_integration_utils" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +checksum = "2ea6256cc3c42b516ee6a7f5885c6e4dcfc66ec84d1ae725dea17e3d22a3803d" dependencies = [ - "either", + "futures", + "leptos", + "leptos_config", + "leptos_hot_reload", + "leptos_meta", + "tracing", ] [[package]] -name = "itoa" -version = "1.0.11" +name = "leptos_macro" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "019016cc0193831660a7794aa046e4c01617d97ccb2f403a5c10b21744391a71" +dependencies = [ + "attribute-derive", + "cfg-if", + "convert_case 0.6.0", + "html-escape", + "itertools 0.12.1", + "leptos_hot_reload", + "prettyplease", + "proc-macro-error", + "proc-macro2", + "quote", + "rstml", + "server_fn_macro", + "syn 2.0.70", + "tracing", + "uuid", +] [[package]] -name = "js-sys" -version = "0.3.68" +name = "leptos_meta" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" +checksum = "873ec368535d9971df4848ca21e91aa96fa00a6884258ab8f926db69ea97f547" dependencies = [ + "cfg-if", + "indexmap 2.2.6", + "leptos", + "tracing", "wasm-bindgen", + "web-sys", ] [[package]] -name = "judger" -version = "0.1.0" +name = "leptos_reactive" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "076064e3c84e3aa12d4bad283e82ba5968675f5f9714d04a5c38f169cd4f26b5" dependencies = [ - "async-stream", - "bytes", - "cgroups-rs", - "derive_builder", - "env_logger", - "fuse3", - "futures-core", - "grpc", - "lazy_static", - "libc", - "log", - "prost 0.12.6", - "prost-types", - "rustix 0.38.34", + "base64 0.22.1", + "cfg-if", + "futures", + "indexmap 2.2.6", + "js-sys", + "oco_ref", + "paste", + "pin-project", + "rustc-hash", + "self_cell", "serde", - "spin", - "tar", - "tempfile", + "serde-wasm-bindgen", + "serde_json", + "slotmap", "thiserror", - "tikv-jemallocator", "tokio", - "tokio-stream", - "toml", - "tonic 0.11.0", - "tower", - "tower-layer", - "uuid", + "tracing", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", ] [[package]] -name = "k256" -version = "0.13.3" +name = "leptos_router" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" +checksum = "d66db10225f0caf60b0183935b288791ac3494ca6e1306d415ea97287b6c2db5" dependencies = [ + "cached", "cfg-if", - "ecdsa", - "elliptic-curve", + "gloo-net", + "itertools 0.12.1", + "js-sys", + "lazy_static", + "leptos", + "leptos_integration_utils", + "leptos_meta", + "linear-map", + "lru", "once_cell", - "serdect", - "sha2", - "signature", -] - -[[package]] -name = "kv-log-macro" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" -dependencies = [ - "log", + "percent-encoding", + "regex", + "send_wrapper", + "serde", + "serde_json", + "serde_qs 0.13.0", + "thiserror", + "tracing", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", ] [[package]] -name = "lazy_static" -version = "1.5.0" +name = "leptos_server" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +checksum = "603064a2d7ac46dba4b3ed5397a475076f9738918dd605670869dfe877d5966c" dependencies = [ - "spin", + "inventory", + "lazy_static", + "leptos_macro", + "leptos_reactive", + "serde", + "server_fn", + "thiserror", + "tracing", ] [[package]] @@ -2043,6 +3151,16 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "linear-map" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfae20f6b19ad527b550c223fddc3077a547fc70cda94b9b566575423fd303ee" +dependencies = [ + "serde", + "serde_test", +] + [[package]] name = "linked-hash-map" version = "0.5.6" @@ -2061,6 +3179,23 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "local-channel" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6cbc85e69b8df4b8bb8b89ec634e7189099cea8927a276b7384ce5488e53ec8" +dependencies = [ + "futures-core", + "futures-sink", + "local-waker", +] + +[[package]] +name = "local-waker" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d873d7c67ce09b42110d801813efbc9364414e356be9935700d368351657487" + [[package]] name = "lock_api" version = "0.4.12" @@ -2080,6 +3215,15 @@ dependencies = [ "value-bag", ] +[[package]] +name = "lru" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a83fb7698b3643a0e34f9ae6f2e8f0178c0fd42f8b59d493aa271ff3a5bf21" +dependencies = [ + "hashbrown 0.14.5", +] + [[package]] name = "lru-cache" version = "0.1.2" @@ -2089,6 +3233,29 @@ dependencies = [ "linked-hash-map", ] +[[package]] +name = "manyhow" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91ea592d76c0b6471965708ccff7e6a5d277f676b90ab31f4d3f3fc77fade64" +dependencies = [ + "manyhow-macros", + "proc-macro2", + "quote", + "syn 2.0.70", +] + +[[package]] +name = "manyhow-macros" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c64621e2c08f2576e4194ea8be11daf24ac01249a4f53cd8befcbb7077120ead" +dependencies = [ + "proc-macro-utils", + "proc-macro2", + "quote", +] + [[package]] name = "match_cfg" version = "0.1.0" @@ -2186,6 +3353,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", + "log", "wasi", "windows-sys 0.48.0", ] @@ -2352,6 +3520,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "oco_ref" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c51ebcefb2f0b9a5e0bea115532c8ae4215d1b01eff176d0f4ba4192895c2708" +dependencies = [ + "serde", + "thiserror", +] + [[package]] name = "once_cell" version = "1.19.0" @@ -2426,7 +3604,7 @@ checksum = "f24cda83b20ed2433c68241f918d0f6fdec8b1d43b7a9590ab4420c5095ca930" dependencies = [ "async-trait", "futures-core", - "http", + "http 0.2.12", "opentelemetry", "opentelemetry-proto", "opentelemetry-semantic-conventions", @@ -2543,6 +3721,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "pad-adapter" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56d80efc4b6721e8be2a10a5df21a30fa0b470f1539e53d8b4e6e75faf938b63" + [[package]] name = "parking" version = "2.2.0" @@ -2578,6 +3762,12 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "pathdiff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" + [[package]] name = "pem-rfc7468" version = "0.7.0" @@ -2635,6 +3825,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pinned" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a829027bd95e54cfe13e3e258a1ae7b645960553fb82b75ff852c29688ee595b" +dependencies = [ + "futures", + "rustversion", + "thiserror", +] + [[package]] name = "piper" version = "0.2.3" @@ -2673,6 +3874,19 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +[[package]] +name = "plist" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42cf17e9a1800f5f396bc67d193dc9411b59012a5876445ef450d449881e1016" +dependencies = [ + "base64 0.22.1", + "indexmap 2.2.6", + "quick-xml", + "serde", + "time", +] + [[package]] name = "polling" version = "2.8.0" @@ -2743,6 +3957,16 @@ dependencies = [ "syn 2.0.70", ] +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit 0.19.15", +] + [[package]] name = "proc-macro-crate" version = "3.1.0" @@ -2776,6 +4000,17 @@ dependencies = [ "version_check", ] +[[package]] +name = "proc-macro-utils" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f59e109e2f795a5070e69578c4dc101068139f74616778025ae1011d4cd41a8" +dependencies = [ + "proc-macro2", + "quote", + "smallvec", +] + [[package]] name = "proc-macro2" version = "1.0.86" @@ -2785,6 +4020,19 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "proc-macro2-diagnostics" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.70", + "version_check", + "yansi", +] + [[package]] name = "prost" version = "0.11.9" @@ -2927,6 +4175,25 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "pulldown-cmark" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76979bea66e7875e7509c4ec5300112b316af87fa7a252ca91c448b32dfe3993" +dependencies = [ + "bitflags 2.6.0", + "getopts", + "memchr", + "pulldown-cmark-escape", + "unicase", +] + +[[package]] +name = "pulldown-cmark-escape" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd348ff538bc9caeda7ee8cad2d1d48236a1f443c1fa3913c6a02fe0043b1dd3" + [[package]] name = "quanta" version = "0.12.3" @@ -2948,6 +4215,15 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" +[[package]] +name = "quick-xml" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d3a6e5838b60e0e8fa7a43f22ade549a37d61f8bdbe636d0d7816191de969c2" +dependencies = [ + "memchr", +] + [[package]] name = "quick_cache" version = "0.4.2" @@ -2969,6 +4245,29 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "quote-use" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e96ac59974192a2fa6ee55a41211cf1385c5b2a8636a4c3068b3b3dd599ece" +dependencies = [ + "quote", + "quote-use-macros", +] + +[[package]] +name = "quote-use-macros" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c57308e9dde4d7be9af804f6deeaa9951e1de1d5ffce6142eb964750109f7e" +dependencies = [ + "derive-where", + "proc-macro-utils", + "proc-macro2", + "quote", + "syn 2.0.70", +] + [[package]] name = "radium" version = "0.7.0" @@ -3073,6 +4372,12 @@ dependencies = [ "regex-syntax 0.8.4", ] +[[package]] +name = "regex-lite" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" + [[package]] name = "regex-syntax" version = "0.6.29" @@ -3106,7 +4411,7 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", + "http 0.2.12", "http-body", "hyper", "hyper-rustls", @@ -3276,6 +4581,20 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rstml" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe542870b8f59dd45ad11d382e5339c9a1047cde059be136a7016095bbdefa77" +dependencies = [ + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn 2.0.70", + "syn_derive", + "thiserror", +] + [[package]] name = "rust_decimal" version = "1.35.0" @@ -3298,6 +4617,12 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc_version" version = "0.4.0" @@ -3418,6 +4743,15 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "schannel" version = "0.1.23" @@ -3665,12 +4999,27 @@ dependencies = [ "libc", ] +[[package]] +name = "self_cell" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d369a96f978623eb3dc28807c4852d6cc617fed53da5d3c400feff1ef34a714a" + [[package]] name = "semver" version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +[[package]] +name = "send_wrapper" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" +dependencies = [ + "futures-core", +] + [[package]] name = "serde" version = "1.0.204" @@ -3680,6 +5029,17 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-wasm-bindgen" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8302e169f0eddcc139c70f139d19d6467353af16f9fce27e8c30158036a1e16b" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + [[package]] name = "serde_derive" version = "1.0.204" @@ -3702,6 +5062,28 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_qs" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0431a35568651e363364210c91983c1da5eb29404d9f0928b67d4ebcfa7d330c" +dependencies = [ + "percent-encoding", + "serde", + "thiserror", +] + +[[package]] +name = "serde_qs" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd34f36fe4c5ba9654417139a9b3a20d2e1de6012ee678ad14d240c22c78d8d6" +dependencies = [ + "percent-encoding", + "serde", + "thiserror", +] + [[package]] name = "serde_spanned" version = "0.6.6" @@ -3711,6 +5093,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_test" +version = "1.0.176" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a2f49ace1498612d14f7e0b8245519584db8299541dfe31a06374a828d620ab" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -3733,6 +5124,61 @@ dependencies = [ "serde", ] +[[package]] +name = "server_fn" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b06e6e5467a2cd93ce1accfdfd8b859404f0b3b2041131ffd774fabf666b8219" +dependencies = [ + "actix-web", + "bytes", + "ciborium", + "const_format", + "dashmap", + "futures", + "gloo-net", + "http 1.1.0", + "inventory", + "js-sys", + "once_cell", + "send_wrapper", + "serde", + "serde_json", + "serde_qs 0.12.0", + "server_fn_macro_default", + "thiserror", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", + "xxhash-rust", +] + +[[package]] +name = "server_fn_macro" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09c216bb1c1ac890151397643c663c875a1836adf0b269be4e389cb1b48c173c" +dependencies = [ + "const_format", + "convert_case 0.6.0", + "proc-macro2", + "quote", + "syn 2.0.70", + "xxhash-rust", +] + +[[package]] +name = "server_fn_macro_default" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00783df297ec85ea605779f2fef9cbec98981dffe2e01e1a9845c102ee1f1ae6" +dependencies = [ + "server_fn_macro", + "syn 2.0.70", +] + [[package]] name = "sha1" version = "0.10.6" @@ -3798,6 +5244,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slotmap" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbff4acf519f630b3a3ddcfaea6c06b42174d9a44bc70c620e9ed1649d58b82a" +dependencies = [ + "serde", + "version_check", +] + [[package]] name = "smallvec" version = "1.13.2" @@ -4163,6 +5619,28 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "syntect" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "874dcfa363995604333cf947ae9f751ca3af4522c60886774c4963943b4746b1" +dependencies = [ + "bincode", + "bitflags 1.3.2", + "fancy-regex", + "flate2", + "fnv", + "once_cell", + "plist", + "regex-syntax 0.8.4", + "serde", + "serde_derive", + "serde_json", + "thiserror", + "walkdir", + "yaml-rust", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -4416,6 +5894,18 @@ dependencies = [ "toml_edit 0.19.15", ] +[[package]] +name = "toml" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.22.15", +] + [[package]] name = "toml_datetime" version = "0.6.6" @@ -4435,7 +5925,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.5.40", ] [[package]] @@ -4446,7 +5936,20 @@ checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ "indexmap 2.2.6", "toml_datetime", - "winnow", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.22.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59a3a72298453f564e2b111fa896f8d07fabb36f51f06d7e875fc5e0b5a3ef1" +dependencies = [ + "indexmap 2.2.6", + "serde", + "serde_spanned", + "toml_datetime", + "winnow 0.6.13", ] [[package]] @@ -4462,7 +5965,7 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", + "http 0.2.12", "http-body", "hyper", "hyper-timeout", @@ -4489,7 +5992,7 @@ dependencies = [ "base64 0.21.7", "bytes", "h2", - "http", + "http 0.2.12", "http-body", "hyper", "hyper-timeout", @@ -4528,7 +6031,7 @@ checksum = "dc3b0e1cedbf19fdfb78ef3d672cb9928e0a91a9cb4629cc0c916e8cff8aaaa1" dependencies = [ "base64 0.21.7", "bytes", - "http", + "http 0.2.12", "http-body", "hyper", "pin-project", @@ -4540,6 +6043,30 @@ dependencies = [ "tracing", ] +[[package]] +name = "tonic-web-wasm-client" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79bb296fba9974fbc7ea2f1364a661c0e7acb7ebfca648343e5a4ac44ec9a0ec" +dependencies = [ + "base64 0.21.7", + "byteorder", + "bytes", + "futures-util", + "http 0.2.12", + "http-body", + "httparse", + "js-sys", + "pin-project", + "thiserror", + "tonic 0.11.0", + "tower-service", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", +] + [[package]] name = "tower" version = "0.4.13" @@ -4570,7 +6097,7 @@ dependencies = [ "bytes", "futures-core", "futures-util", - "http", + "http 0.2.12", "http-body", "http-range-header", "pin-project-lite", @@ -4684,6 +6211,19 @@ dependencies = [ "tracing-serde", ] +[[package]] +name = "tracing-web" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e6a141feebd51f8d91ebfd785af50fca223c570b86852166caa3b141defe7c" +dependencies = [ + "js-sys", + "tracing-core", + "tracing-subscriber", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "trait-make" version = "0.1.0" @@ -4701,6 +6241,26 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "typed-builder" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77739c880e00693faef3d65ea3aad725f196da38b22fdc7ea6ded6e1ce4d3add" +dependencies = [ + "typed-builder-macro", +] + +[[package]] +name = "typed-builder-macro" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f718dfaf347dcb5b983bfc87608144b0bad87970aebcbea5ce44d2a30c08e63" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.70", +] + [[package]] name = "typeid" version = "1.0.0" @@ -4779,6 +6339,18 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +[[package]] +name = "unicode-width" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "unicode_categories" version = "0.1.1" @@ -4808,6 +6380,12 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" +[[package]] +name = "utf8-width" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" + [[package]] name = "utf8parse" version = "0.2.2" @@ -4823,8 +6401,15 @@ dependencies = [ "getrandom", "rand", "serde", + "wasm-bindgen", ] +[[package]] +name = "v_htmlescape" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e8257fbc510f0a46eb602c10215901938b5c2a7d5e70fc11483b1d3c9b5b18c" + [[package]] name = "valuable" version = "0.1.0" @@ -4855,6 +6440,16 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "317211a0dc0ceedd78fb2ca9a44aed3d7b9b26f81870d485c07122b4350673b7" +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "want" version = "0.3.1" @@ -4942,6 +6537,19 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +[[package]] +name = "wasm-streams" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "web-sys" version = "0.3.68" @@ -5184,6 +6792,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.50.0" @@ -5220,6 +6837,27 @@ dependencies = [ "rustix 0.38.34", ] +[[package]] +name = "xxhash-rust" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63658493314859b4dfdf3fb8c1defd61587839def09582db50b8a4e93afca6bb" + +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" + [[package]] name = "zerocopy" version = "0.7.35" @@ -5245,3 +6883,31 @@ name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zstd" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "7.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa556e971e7b568dc775c136fc9de8c779b1c2fc3a63defaafadffdbd3181afa" +dependencies = [ + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.12+zstd.1.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a4e40c320c3cb459d9a9ff6de98cff88f4751ee9275d140e2be94a2b74e4c13" +dependencies = [ + "cc", + "pkg-config", +] diff --git a/Cargo.toml b/Cargo.toml index ee5b2f01..642f49d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [workspace] resolver = "2" members = [ -# "frontend", + "frontend", "backend", "judger", # "testsuit", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index cb6b382e..9fb2cd5c 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -50,7 +50,7 @@ features = [ "judger", "transport", "serde", - "extra_trait", + "extra_trait" ] [dependencies.postcard] diff --git a/backend/src/init/config.rs b/backend/src/config.rs similarity index 94% rename from backend/src/init/config.rs rename to backend/src/config.rs index 7e4c6107..12883cd9 100644 --- a/backend/src/init/config.rs +++ b/backend/src/config.rs @@ -1,10 +1,13 @@ use std::{path::PathBuf, str::FromStr}; -use super::Error; +use crate::server; +use crate::server::InitError; use ip_network::IpNetwork; use serde::{Deserialize, Serialize}; use tokio::{fs, io::AsyncReadExt}; +pub use crate::server::PACKAGE_NAME; + lazy_static::lazy_static! { pub static ref CONFIG_PATH: PathBuf=PathBuf::from_str( &std::env::var("CONFIG_PATH").unwrap_or("config.toml".to_string())) @@ -130,7 +133,7 @@ impl Default for Imgur { } } -pub async fn init() -> super::Result { +pub async fn init() -> server::Result { let config_path = CONFIG_PATH.as_path(); if fs::metadata(config_path).await.is_ok() { let mut buf = Vec::new(); @@ -140,10 +143,10 @@ pub async fn init() -> super::Result { config .read_to_end(&mut buf) .await - .map_err(Error::ConfigRead)?; + .map_err(InitError::ConfigRead)?; let config = std::str::from_utf8(&buf).expect("Config file may container non-utf8 character"); - let config: GlobalConfig = toml::from_str(config).map_err(Error::ConfigParse)?; + let config: GlobalConfig = toml::from_str(config).map_err(InitError::ConfigParse)?; Ok(config) } else { println!( @@ -155,7 +158,7 @@ pub async fn init() -> super::Result { let config_txt = toml::to_string(&config).unwrap(); fs::write(config_path, config_txt) .await - .map_err(Error::ConfigWrite)?; + .map_err(InitError::ConfigWrite)?; println!( "Config generated, please edit {:?} before restart", diff --git a/backend/src/controller/crypto.rs b/backend/src/controller/crypto.rs index 434aaffb..bf6ba3c7 100644 --- a/backend/src/controller/crypto.rs +++ b/backend/src/controller/crypto.rs @@ -3,7 +3,7 @@ use rand::{rngs::OsRng, Rng}; use serde::{de::DeserializeOwned, Serialize}; use tracing::Span; -use crate::init::config::GlobalConfig; +use crate::config::GlobalConfig; use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine}; use blake2::{Blake2b512, Digest}; diff --git a/backend/src/controller/imgur.rs b/backend/src/controller/imgur.rs index 43759fdb..05b7d886 100644 --- a/backend/src/controller/imgur.rs +++ b/backend/src/controller/imgur.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use reqwest::{multipart, Client}; use tracing::instrument; -use crate::{init::config, report_internal}; +use crate::{config, report_internal}; #[derive(Debug, thiserror::Error)] pub enum Error { diff --git a/backend/src/controller/judger/mod.rs b/backend/src/controller/judger/mod.rs index 7be77391..fbcab2e5 100644 --- a/backend/src/controller/judger/mod.rs +++ b/backend/src/controller/judger/mod.rs @@ -12,8 +12,8 @@ use std::{ use tokio_stream::StreamExt; use crate::{ - init::{config, logger::PACKAGE_NAME}, report_internal, TonicStream, + {config, config::PACKAGE_NAME}, }; use grpc::backend::StateCode as BackendCode; use opentelemetry::{global, metrics::ObservableGauge}; diff --git a/backend/src/controller/judger/route/direct.rs b/backend/src/controller/judger/route/direct.rs index ec070ef3..07171268 100644 --- a/backend/src/controller/judger/route/direct.rs +++ b/backend/src/controller/judger/route/direct.rs @@ -1,5 +1,5 @@ use super::{ConnectionDetail, Error, Routable, RouteStatus}; -use crate::init::config::Judger; +use crate::config::Judger; use tonic::transport::Uri; /// Upstream source for static(only emit once) diff --git a/backend/src/controller/judger/route/mod.rs b/backend/src/controller/judger/route/mod.rs index bb63fdac..96f9131a 100644 --- a/backend/src/controller/judger/route/mod.rs +++ b/backend/src/controller/judger/route/mod.rs @@ -17,7 +17,7 @@ use tonic::{service::Interceptor, *}; use tracing::{debug_span, instrument, span, Instrument, Level, Span}; use uuid::Uuid; -use crate::init::config::{self, Judger as JudgerConfig}; +use crate::config::{self, Judger as JudgerConfig}; use grpc::judger::{judger_client::*, *}; // TODO: add tracing diff --git a/backend/src/controller/judger/route/swarm.rs b/backend/src/controller/judger/route/swarm.rs index 73343472..a21b099e 100644 --- a/backend/src/controller/judger/route/swarm.rs +++ b/backend/src/controller/judger/route/swarm.rs @@ -1,7 +1,7 @@ use std::{collections::HashSet, net::IpAddr, time::Duration}; use super::{ConnectionDetail, Error}; -use crate::init::config; +use crate::config; use hickory_resolver::TokioAsyncResolver; use super::{Routable, RouteStatus}; diff --git a/backend/src/controller/metrics.rs b/backend/src/controller/metrics.rs index 7bd1ad4d..94f30a1e 100644 --- a/backend/src/controller/metrics.rs +++ b/backend/src/controller/metrics.rs @@ -7,7 +7,7 @@ use opentelemetry::{ }; use opentelemetry_sdk::metrics::MeterProvider as SdkMeterProvider; -use crate::init::logger::PACKAGE_NAME; +use crate::config::PACKAGE_NAME; macro_rules! impl_metrics { ($n:expr) => { diff --git a/backend/src/endpoint/announcement.rs b/backend/src/endpoint/announcement.rs index c463473e..a95ddc6b 100644 --- a/backend/src/endpoint/announcement.rs +++ b/backend/src/endpoint/announcement.rs @@ -116,10 +116,9 @@ impl Announcement for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; - check_length!(SHORT_ART_SIZE, req.info, title); - check_length!(LONG_ART_SIZE, req.info, content); + req.check_with_error()?; let uuid = Uuid::parse_str(&req.request_id).map_err(Error::InvaildUUID)?; if let Some(x) = self.dup.check::(user_id, uuid) { @@ -157,10 +156,9 @@ impl Announcement for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (user_id, _perm) = auth.ok_or_default()?; + let (user_id, _perm) = auth.auth_or_guest()?; - check_exist_length!(SHORT_ART_SIZE, req.info, title); - check_exist_length!(LONG_ART_SIZE, req.info, content); + req.check_with_error()?; let uuid = Uuid::parse_str(&req.request_id).map_err(Error::InvaildUUID)?; if let Some(x) = self.dup.check::<()>(user_id, uuid) { @@ -219,7 +217,7 @@ impl Announcement for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; if !perm.super_user() { return Err(Error::RequirePermission(RoleLv::Super).into()); diff --git a/backend/src/endpoint/chat.rs b/backend/src/endpoint/chat.rs index 27a0ac4a..4a430fc8 100644 --- a/backend/src/endpoint/chat.rs +++ b/backend/src/endpoint/chat.rs @@ -24,9 +24,9 @@ impl Chat for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (user_id, _) = auth.ok_or_default()?; + let (user_id, _) = auth.auth_or_guest()?; - check_length!(LONG_ART_SIZE, req, message); + req.check_with_error()?; let uuid = Uuid::parse_str(&req.request_id).map_err(Error::InvaildUUID)?; if let Some(x) = self.dup.check::(user_id, uuid) { diff --git a/backend/src/endpoint/contest.rs b/backend/src/endpoint/contest.rs index 5a98d4a2..4c489754 100644 --- a/backend/src/endpoint/contest.rs +++ b/backend/src/endpoint/contest.rs @@ -80,10 +80,9 @@ impl Contest for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; - check_length!(SHORT_ART_SIZE, req.info, title, tags); - check_length!(LONG_ART_SIZE, req.info, content); + req.check_with_error()?; let uuid = Uuid::parse_str(&req.request_id).map_err(Error::InvaildUUID)?; if let Some(x) = self.dup.check::(user_id, uuid) { @@ -129,10 +128,9 @@ impl Contest for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; - check_exist_length!(SHORT_ART_SIZE, req.info, title, tags); - check_exist_length!(LONG_ART_SIZE, req.info, content); + req.check_with_error()?; let uuid = Uuid::parse_str(&req.request_id).map_err(Error::InvaildUUID)?; if let Some(x) = self.dup.check::<()>(user_id, uuid) { @@ -149,7 +147,6 @@ impl Contest for ArcServer { .map_err(Into::::into)? .ok_or(Error::NotInDB)?; - check_exist_length!(SHORT_ART_SIZE, req.info, password); if let Some(src) = req.info.password { if let Some(tar) = model.password.as_ref() { if perm.root() || self.crypto.hash_eq(&src, tar) { @@ -212,7 +209,7 @@ impl Contest for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; let model = Entity::read_filter(Entity::find_by_id(req.id), &auth)? .one(self.db.deref()) diff --git a/backend/src/endpoint/education.rs b/backend/src/endpoint/education.rs index 4b6861e7..132eb5a6 100644 --- a/backend/src/endpoint/education.rs +++ b/backend/src/endpoint/education.rs @@ -40,10 +40,9 @@ impl Education for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; - check_length!(SHORT_ART_SIZE, req.info, title); - check_length!(LONG_ART_SIZE, req.info, content); + req.check_with_error()?; let uuid = Uuid::parse_str(&req.request_id).map_err(Error::InvaildUUID)?; if let Some(x) = self.dup.check::(user_id, uuid) { @@ -79,10 +78,9 @@ impl Education for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (user_id, _perm) = auth.ok_or_default()?; + let (user_id, _perm) = auth.auth_or_guest()?; - check_exist_length!(SHORT_ART_SIZE, req.info, title); - check_exist_length!(LONG_ART_SIZE, req.info, content); + req.check_with_error()?; let uuid = Uuid::parse_str(&req.request_id).map_err(Error::InvaildUUID)?; if let Some(x) = self.dup.check::<()>(user_id, uuid) { @@ -142,7 +140,7 @@ impl Education for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; let (problem, model) = tokio::try_join!( problem::Entity::read_by_id(req.problem_id, &auth)? diff --git a/backend/src/endpoint/imgur.rs b/backend/src/endpoint/imgur.rs index 53d490f1..a4fe57a6 100644 --- a/backend/src/endpoint/imgur.rs +++ b/backend/src/endpoint/imgur.rs @@ -11,7 +11,7 @@ impl Image for ArcServer { req: Request, ) -> Result, Status> { let (auth, req) = self.parse_request_n(req, crate::NonZeroU32!(5)).await?; - let (user_id, _) = auth.ok_or_default()?; + let (user_id, _) = auth.auth_or_guest()?; let uuid = Uuid::parse_str(&req.request_id).map_err(Error::InvaildUUID)?; if let Some(x) = self.dup.check::(user_id, uuid) { diff --git a/backend/src/endpoint/mod.rs b/backend/src/endpoint/mod.rs index 1a011b01..66a28d1a 100644 --- a/backend/src/endpoint/mod.rs +++ b/backend/src/endpoint/mod.rs @@ -16,10 +16,6 @@ mod token; mod user; mod tools { - /// longest allowed size for short string - pub const SHORT_ART_SIZE: usize = 128; - /// longest allowed size for long string - pub const LONG_ART_SIZE: usize = 262144; pub use crate::NonZeroU32; pub use grpc::backend::Id; pub use sea_orm::*; @@ -34,12 +30,13 @@ mod tools { }; pub use crate::util::{ auth::RoleLv, + bound::BoundCheck, error::{atomic_fail, Error}, time::*, }; pub use crate::{ - check_exist_length, check_length, fill_active_model, fill_exist_active_model, - parse_pager_param, server::ArcServer, TonicStream, + fill_active_model, fill_exist_active_model, parse_pager_param, server::ArcServer, + TonicStream, }; } diff --git a/backend/src/endpoint/problem.rs b/backend/src/endpoint/problem.rs index f4765788..3217e37a 100644 --- a/backend/src/endpoint/problem.rs +++ b/backend/src/endpoint/problem.rs @@ -71,17 +71,16 @@ impl Problem for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; - check_length!(SHORT_ART_SIZE, req.info, title, tags); - check_length!(LONG_ART_SIZE, req.info, content); + req.check_with_error()?; let uuid = Uuid::parse_str(&req.request_id).map_err(Error::InvaildUUID)?; if let Some(x) = self.dup.check::(user_id, uuid) { return Ok(Response::new(x)); }; - if !(perm.super_user()) { + if !perm.super_user() { return Err(Error::RequirePermission(RoleLv::Super).into()); } @@ -116,10 +115,9 @@ impl Problem for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (user_id, _perm) = auth.ok_or_default()?; + let (user_id, _perm) = auth.auth_or_guest()?; - check_exist_length!(SHORT_ART_SIZE, req.info, title, tags); - check_exist_length!(LONG_ART_SIZE, req.info, content); + req.check_with_error()?; let uuid = Uuid::parse_str(&req.request_id).map_err(Error::InvaildUUID)?; if let Some(x) = self.dup.check::<()>(user_id, uuid) { @@ -179,7 +177,7 @@ impl Problem for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; if !perm.admin() { return Err(Error::RequirePermission(RoleLv::Root).into()); @@ -255,7 +253,7 @@ impl Problem for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (_, perm) = auth.ok_or_default()?; + let (_, perm) = auth.auth_or_guest()?; tracing::debug!(id = req.id); @@ -290,7 +288,7 @@ impl Problem for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (_, perm) = auth.ok_or_default()?; + let (_, perm) = auth.auth_or_guest()?; tracing::debug!(id = req.id); diff --git a/backend/src/endpoint/submit.rs b/backend/src/endpoint/submit.rs index 3067548d..1c34fdb8 100644 --- a/backend/src/endpoint/submit.rs +++ b/backend/src/endpoint/submit.rs @@ -77,11 +77,9 @@ impl Submit for ArcServer { #[instrument(skip_all, level = "debug")] async fn create(&self, req: Request) -> Result, Status> { let (auth, req) = self.parse_request_n(req, crate::NonZeroU32!(15)).await?; - let (user_id, _) = auth.ok_or_default()?; + let (user_id, _) = auth.auth_or_guest()?; - if req.code.len() > SUBMIT_CODE_LEN { - return Err(Error::BufferTooLarge("info.code").into()); - } + req.check_with_error()?; let lang = Uuid::parse_str(req.lang.as_str()).map_err(Into::::into)?; @@ -182,7 +180,7 @@ impl Submit for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; let submit_id = req.submit_id; diff --git a/backend/src/endpoint/testcase.rs b/backend/src/endpoint/testcase.rs index f967a5a1..40964ab7 100644 --- a/backend/src/endpoint/testcase.rs +++ b/backend/src/endpoint/testcase.rs @@ -40,9 +40,9 @@ impl Testcase for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; - check_length!(LONG_ART_SIZE, req.info, input, output); + req.check_with_error()?; let uuid = Uuid::parse_str(&req.request_id).map_err(Error::InvaildUUID)?; if let Some(x) = self.dup.check::(user_id, uuid) { @@ -78,9 +78,9 @@ impl Testcase for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (user_id, _perm) = auth.ok_or_default()?; + let (user_id, _perm) = auth.auth_or_guest()?; - check_exist_length!(LONG_ART_SIZE, req.info, input, output); + req.check_with_error()?; let uuid = Uuid::parse_str(&req.request_id).map_err(Error::InvaildUUID)?; if let Some(x) = self.dup.check::<()>(user_id, uuid) { @@ -139,7 +139,7 @@ impl Testcase for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; if !perm.super_user() { return Err(Error::RequirePermission(RoleLv::Super).into()); @@ -212,7 +212,7 @@ impl Testcase for ArcServer { tracing::debug!(problem_id = req.problem_id, testcase_id = req.testcase_id); - let (_, perm) = auth.ok_or_default()?; + let (_, perm) = auth.auth_or_guest()?; if !perm.admin() { return Err(Error::RequirePermission(RoleLv::Root).into()); diff --git a/backend/src/endpoint/token.rs b/backend/src/endpoint/token.rs index 51572ddc..65fce876 100644 --- a/backend/src/endpoint/token.rs +++ b/backend/src/endpoint/token.rs @@ -27,7 +27,7 @@ impl Token for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; if req.id != user_id && !perm.root() { return Err(Error::Unauthenticated.into()); @@ -128,7 +128,7 @@ impl Token for ArcServer { async fn logout(&self, req: Request<()>) -> Result, Status> { // FIXME: handle rate limiting logic let (auth, _) = self.parse_auth(&req).in_current_span().await?; - auth.ok_or_default()?; + auth.auth_or_guest()?; if let Some(x) = req.metadata().get("token") { let token = x.to_str().unwrap(); diff --git a/backend/src/endpoint/user.rs b/backend/src/endpoint/user.rs index dd68fc83..b6b41c48 100644 --- a/backend/src/endpoint/user.rs +++ b/backend/src/endpoint/user.rs @@ -37,11 +37,11 @@ impl User for ArcServer { .in_current_span() .await?; - check_length!(SHORT_ART_SIZE, req.info, username); + req.check_with_error()?; let uuid = Uuid::parse_str(&req.request_id).map_err(Error::InvaildUUID)?; - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; if let Some(x) = self.dup.check::(user_id, uuid) { return Ok(Response::new(x)); @@ -110,7 +110,9 @@ impl User for ArcServer { .in_current_span() .await?; - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; + + req.check_with_error()?; let uuid = Uuid::parse_str(&req.request_id).map_err(Error::InvaildUUID)?; if let Some(x) = self.dup.check::<()>(user_id, uuid) { @@ -192,7 +194,7 @@ impl User for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (user_id, _) = auth.ok_or_default()?; + let (user_id, _) = auth.auth_or_guest()?; let model = user::Entity::find() .filter(user::Column::Username.eq(req.username)) @@ -226,7 +228,7 @@ impl User for ArcServer { .parse_request_n(req, NonZeroU32!(5)) .in_current_span() .await?; - let (user_id, _) = auth.ok_or_default()?; + let (user_id, _) = auth.auth_or_guest()?; let model = Entity::find_by_id(user_id) .one(self.db.deref()) diff --git a/backend/src/entity/announcement.rs b/backend/src/entity/announcement.rs index 81797c30..5329a6f4 100644 --- a/backend/src/entity/announcement.rs +++ b/backend/src/entity/announcement.rs @@ -72,7 +72,7 @@ impl ActiveModelBehavior for ActiveModel {} impl super::Filter for Entity { #[instrument(skip_all, level = "debug")] fn read_filter(query: S, auth: &Auth) -> Result { - if let Ok((user_id, perm)) = auth.ok_or_default() { + if let Ok((user_id, perm)) = auth.auth_or_guest() { if perm.admin() { return Ok(query); } @@ -82,7 +82,7 @@ impl super::Filter for Entity { } #[instrument(skip_all, level = "debug")] fn write_filter(query: S, auth: &Auth) -> Result { - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; if perm.admin() { return Ok(query); } diff --git a/backend/src/entity/contest.rs b/backend/src/entity/contest.rs index 0c4d8cf0..43f8e58b 100644 --- a/backend/src/entity/contest.rs +++ b/backend/src/entity/contest.rs @@ -171,7 +171,7 @@ impl super::ParentalTrait for Entity { impl super::Filter for Entity { #[instrument(skip_all, level = "debug")] fn read_filter(query: S, auth: &Auth) -> Result { - if let Ok((user_id, perm)) = auth.ok_or_default() { + if let Ok((user_id, perm)) = auth.auth_or_guest() { if perm.admin() { return Ok(query); } @@ -181,7 +181,7 @@ impl super::Filter for Entity { } #[instrument(skip_all, level = "debug")] fn write_filter(query: S, auth: &Auth) -> Result { - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; if perm.admin() { return Ok(query); } diff --git a/backend/src/entity/education.rs b/backend/src/entity/education.rs index 0b44ccb3..017f1019 100644 --- a/backend/src/entity/education.rs +++ b/backend/src/entity/education.rs @@ -62,7 +62,7 @@ impl ActiveModelBehavior for ActiveModel {} impl super::Filter for Entity { #[instrument(skip_all, level = "debug")] fn read_filter(query: S, auth: &Auth) -> Result { - if let Ok((user_id, perm)) = auth.ok_or_default() { + if let Ok((user_id, perm)) = auth.auth_or_guest() { if perm.admin() { return Ok(query); } @@ -72,7 +72,7 @@ impl super::Filter for Entity { } #[instrument(skip_all, level = "debug")] fn write_filter(query: S, auth: &Auth) -> Result { - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; if perm.admin() { return Ok(query); } diff --git a/backend/src/entity/problem.rs b/backend/src/entity/problem.rs index 1c176c6b..b1f1685d 100644 --- a/backend/src/entity/problem.rs +++ b/backend/src/entity/problem.rs @@ -205,7 +205,7 @@ impl super::ParentalTrait for Entity { impl super::Filter for Entity { #[instrument(skip_all, level = "debug")] fn read_filter(query: S, auth: &Auth) -> Result { - if let Ok((user_id, perm)) = auth.ok_or_default() { + if let Ok((user_id, perm)) = auth.auth_or_guest() { if perm.admin() { return Ok(query); } @@ -215,7 +215,7 @@ impl super::Filter for Entity { } #[instrument(skip_all, level = "debug")] fn write_filter(query: S, auth: &Auth) -> Result { - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; if perm.admin() { return Ok(query); } diff --git a/backend/src/entity/test.rs b/backend/src/entity/test.rs index 6edb9a0a..e09ded67 100644 --- a/backend/src/entity/test.rs +++ b/backend/src/entity/test.rs @@ -54,7 +54,7 @@ impl ActiveModelBehavior for ActiveModel {} impl super::Filter for Entity { #[instrument(skip_all, level = "debug")] fn read_filter(query: S, auth: &Auth) -> Result { - if let Ok((user_id, perm)) = auth.ok_or_default() { + if let Ok((user_id, perm)) = auth.auth_or_guest() { if perm.admin() { return Ok(query); } @@ -64,7 +64,7 @@ impl super::Filter for Entity { } #[instrument(skip_all, level = "debug")] fn write_filter(query: S, auth: &Auth) -> Result { - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; if perm.admin() { return Ok(query); } diff --git a/backend/src/entity/user.rs b/backend/src/entity/user.rs index 332fe3f9..81ad714c 100644 --- a/backend/src/entity/user.rs +++ b/backend/src/entity/user.rs @@ -24,7 +24,7 @@ impl Model { /// /// Be careful never save it pub fn new_with_auth(auth: &Auth) -> Option { - auth.ok_or_default().ok().map(|(id, permission)| Self { + auth.auth_or_guest().ok().map(|(id, permission)| Self { id, permission: permission as i32, score: Default::default(), @@ -146,7 +146,7 @@ impl super::Filter for Entity { #[instrument(skip_all, level = "debug")] fn write_filter(query: S, auth: &Auth) -> Result { - let (user_id, perm) = auth.ok_or_default()?; + let (user_id, perm) = auth.auth_or_guest()?; if perm.admin() { return Ok(query.filter( Column::Permission diff --git a/backend/src/init/mod.rs b/backend/src/init/mod.rs deleted file mode 100644 index 7e8c96b1..00000000 --- a/backend/src/init/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! Procedural for initialization -//! -//! This module is heavily couple with crate::server and require refactor - -pub mod config; -pub mod db; -pub mod error; -pub mod logger; - -pub use error::Error; -pub type Result = std::result::Result; diff --git a/backend/src/macro_tool.rs b/backend/src/macro_tool.rs index 0ba33272..54f8d437 100644 --- a/backend/src/macro_tool.rs +++ b/backend/src/macro_tool.rs @@ -45,42 +45,6 @@ macro_rules! report_internal { }}; } -/// Check length of user inputted buffer -#[macro_export] -macro_rules! check_length { - ($target:expr,$src:expr,$field:ident) => { - paste::paste!{ - if $target<$src.$field.len(){ - return Err(Error::BufferTooLarge(stringify!($field)).into()); - } - } - }; - ($target:expr,$src:expr, $field:ident, $($ext:ident),+) => { - check_length!($target,$src, $field); - check_length!($target,$src, $($ext),+); - }; -} - -/// Check length of user inputted buffer if it buffer is Some -/// -/// It's useful because user may not input all fields -#[macro_export] -macro_rules! check_exist_length { - ($target:expr,$src:expr,$field:ident) => { - paste::paste!{ - if let Some(x)=$src.$field.as_ref(){ - if $target { - check_exist_length!($target,$src, $field); - check_exist_length!($target,$src, $($ext),+); - }; -} - /// Fill many optional fields of active model at single line /// /// This is useful when you want to update a model(user might not update all fields) diff --git a/backend/src/main.rs b/backend/src/main.rs index 2fae9bfb..7a1c9762 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -1,7 +1,7 @@ +pub mod config; pub mod controller; pub mod endpoint; pub mod entity; -pub mod init; pub mod macro_tool; pub mod server; pub mod util; diff --git a/backend/src/init/db.rs b/backend/src/server/db.rs similarity index 85% rename from backend/src/init/db.rs rename to backend/src/server/db.rs index 430bbb22..e5199ed2 100644 --- a/backend/src/init/db.rs +++ b/backend/src/server/db.rs @@ -3,10 +3,10 @@ use sea_orm::{ DatabaseConnection, EntityTrait, PaginatorTrait, Statement, }; -use super::Error; +use super::InitError; use tracing::{debug_span, instrument, Instrument, Span}; -use super::config::{self}; +use crate::config::{self}; use crate::{controller::crypto::CryptoController, util::auth::RoleLv}; #[instrument(skip_all, name = "construct_db",parent=span)] @@ -26,7 +26,7 @@ pub async fn init( let mut opt = ConnectOptions::new(uri); opt.sqlx_logging_level(log::LevelFilter::Trace); - let db = Database::connect(opt).await.map_err(Error::InitConn)?; + let db = Database::connect(opt).await.map_err(InitError::InitConn)?; db.execute(Statement::from_string( DatabaseBackend::Sqlite, @@ -34,7 +34,7 @@ pub async fn init( )) .instrument(debug_span!("db_optimize")) .await - .map_err(Error::OptimizeDB)?; + .map_err(InitError::OptimizeDB)?; #[cfg(feature = "standalone")] if config.migrate == Some(true) { @@ -49,14 +49,14 @@ pub async fn init( #[cfg(feature = "standalone")] /// Run migration async fn migrate(db: &DatabaseConnection) -> super::Result<()> { - sea_orm_migration::run_migrate( + sea_orm_migration::cli::run_migrate( ::migration::Migrator, db, - Some(MigrateSubcommands::Up { num: None }), + Some(sea_orm_cli::cli::MigrateSubcommands::Up { num: None }), false, ) .await - .map_err(Error::AutoMigrate)?; + .map_err(InitError::AutoMigrate)?; Ok(()) } @@ -78,7 +78,7 @@ async fn init_user(db: &DatabaseConnection, crypto: &CryptoController) -> super: } .insert(db) .await - .map_err(Error::UserCreation)?; + .map_err(InitError::UserCreation)?; Ok(()) } diff --git a/backend/src/init/error.rs b/backend/src/server/error.rs similarity index 93% rename from backend/src/init/error.rs rename to backend/src/server/error.rs index 96fddedc..ccdd4097 100644 --- a/backend/src/init/error.rs +++ b/backend/src/server/error.rs @@ -1,14 +1,14 @@ use opentelemetry::{metrics::MetricsError, trace::TraceError}; #[derive(Debug, thiserror::Error)] -pub enum Error { +pub enum InitError { #[error("Fail to create initial connection: `{0}`")] InitConn(sea_orm::DbErr), #[error("Fail to optimize database: `{0}`")] OptimizeDB(sea_orm::DbErr), #[cfg(feature = "standalone")] #[error("Fail to run auto migration: `{0}`")] - AutoMigrate(Box), + AutoMigrate(Box), #[error("Fail to create initial user: `{0}`")] UserCreation(sea_orm::DbErr), #[error("Fail to create config dictionary: `{0}`")] diff --git a/backend/src/init/logger.rs b/backend/src/server/logger.rs similarity index 99% rename from backend/src/init/logger.rs rename to backend/src/server/logger.rs index 31b69471..eb3cecd4 100644 --- a/backend/src/init/logger.rs +++ b/backend/src/server/logger.rs @@ -19,7 +19,7 @@ use tracing::Level; use tracing_opentelemetry::{MetricsLayer, OpenTelemetryLayer}; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; -use crate::init::config::GlobalConfig; +use crate::config::GlobalConfig; pub static PACKAGE_NAME: &str = "mdoj-backend"; diff --git a/backend/src/server.rs b/backend/src/server/mod.rs similarity index 93% rename from backend/src/server.rs rename to backend/src/server/mod.rs index bb80c2e9..df922afe 100644 --- a/backend/src/server.rs +++ b/backend/src/server/mod.rs @@ -1,13 +1,16 @@ +pub mod db; +pub mod error; +pub mod logger; + +pub use error::InitError; +pub use logger::PACKAGE_NAME; +pub type Result = std::result::Result; + use std::{ops::Deref, sync::Arc}; -use crate::{ - controller::*, - init::{ - config::{self, GlobalConfig}, - logger::{self, OtelGuard}, - Error, - }, -}; +use crate::{config, controller::*}; + +use crate::config::GlobalConfig; use grpc::backend::{ announcement_server::AnnouncementServer, chat_server::ChatServer, contest_server::ContestServer, education_server::EducationServer, @@ -15,6 +18,7 @@ use grpc::backend::{ token_server::TokenServer, user_server::UserServer, }; use http::header::HeaderName; +use logger::OtelGuard; use sea_orm::DatabaseConnection; use spin::Mutex; use tonic::transport::{self, Identity, ServerTlsConfig}; @@ -73,14 +77,14 @@ impl Server { /// 4. Other Controller /// /// Also of note, private/public `*.pem` is loaded during [`Server::start`] instead of this function - pub async fn new() -> Result, Error> { + pub async fn new() -> Result> { let config = config::init().await?; let otel_guard = logger::init(&config)?; let span = span!(Level::INFO, "server_construct"); let crypto = crypto::CryptoController::new(&config, &span); let db = Arc::new( - crate::init::db::init(&config.database, &crypto, &span) + db::init(&config.database, &crypto, &span) .in_current_span() .await?, ); @@ -94,8 +98,8 @@ impl Server { .as_ref() .expect("public pem should set if private pem is set"); - let cert = std::fs::read_to_string(public_pem).map_err(Error::ReadPem)?; - let key = std::fs::read_to_string(private_pem).map_err(Error::ReadPem)?; + let cert = std::fs::read_to_string(public_pem).map_err(InitError::ReadPem)?; + let key = std::fs::read_to_string(private_pem).map_err(InitError::ReadPem)?; identity = Some(Identity::from_pem(cert, key)); } diff --git a/backend/src/util/auth.rs b/backend/src/util/auth.rs index cf8bd428..693c0e59 100644 --- a/backend/src/util/auth.rs +++ b/backend/src/util/auth.rs @@ -122,11 +122,11 @@ impl Auth { } } /// short hand for `self.into_inner().ok_or(err)` - pub fn ok_or(&self, err: Error) -> Result<(i32, RoleLv), Error> { + pub fn auth_or_error(&self, err: Error) -> Result<(i32, RoleLv), Error> { self.into_inner().ok_or(err) } /// short hand for `self.into_inner().ok_or(Error::PermissionDeny)` - pub fn ok_or_default(&self) -> Result<(i32, RoleLv), Error> { + pub fn auth_or_guest(&self) -> Result<(i32, RoleLv), Error> { self.into_inner().ok_or(Error::PermissionDeny( "Only signed in user is allow in this endpoint", )) diff --git a/backend/src/util/bound.rs b/backend/src/util/bound.rs new file mode 100644 index 00000000..995a7b54 --- /dev/null +++ b/backend/src/util/bound.rs @@ -0,0 +1,159 @@ +use super::error::Error; +use grpc::backend::*; +pub trait BoundCheck { + /// return true if fail + fn check(&self) -> bool; + fn check_with_error(&self) -> Result<(), tonic::Status> { + if self.check() { + Err(Error::NumberTooLarge.into()) + } else { + Ok(()) + } + } +} + +macro_rules! impl_basic_bound_check { + ($n:ident) => { + paste::paste! { + impl BoundCheck for [] { + fn check(&self) -> bool { + self.info.content.len() > 128 * 1024 || self.info.title.len() > 128 + } + } + impl BoundCheck for [] { + fn check(&self) -> bool { + self.info + .content + .as_ref() + .map(String::len) + .unwrap_or_default() + > 128 * 1024 + || self + .info + .title + .as_ref() + .map(String::len) + .unwrap_or_default() + > 128 + } + } + } + }; +} + +impl_basic_bound_check!(Announcement); +impl_basic_bound_check!(Education); + +impl BoundCheck for CreateChatRequest { + fn check(&self) -> bool { + self.message.len() > 8 * 1024 + } +} + +impl BoundCheck for CreateContestRequest { + fn check(&self) -> bool { + self.info.title.len() > 128 + || self.info.tags.len() > 1024 + || self.info.content.len() > 128 * 1024 + || self + .info + .password + .as_ref() + .map(String::len) + .unwrap_or_default() + > 256 + } +} +impl BoundCheck for UpdateContestRequest { + fn check(&self) -> bool { + self.info + .title + .as_ref() + .map(String::len) + .unwrap_or_default() + > 128 + || self.info.tags.as_ref().map(String::len).unwrap_or_default() > 1024 + || self + .info + .content + .as_ref() + .map(String::len) + .unwrap_or_default() + > 128 * 1024 + || self + .info + .password + .as_ref() + .map(String::len) + .unwrap_or_default() + > 256 + } +} +impl BoundCheck for CreateProblemRequest { + fn check(&self) -> bool { + self.info.title.len() > 128 + || self.info.tags.len() > 1024 + || self.info.content.len() > 128 * 1024 + } +} +impl BoundCheck for UpdateProblemRequest { + fn check(&self) -> bool { + self.info + .title + .as_ref() + .map(String::len) + .unwrap_or_default() + > 128 + || self.info.tags.as_ref().map(String::len).unwrap_or_default() > 1024 + || self + .info + .content + .as_ref() + .map(String::len) + .unwrap_or_default() + > 128 * 1024 + } +} + +impl BoundCheck for CreateSubmitRequest { + fn check(&self) -> bool { + self.code.len() > 64 * 1024 + } +} + +impl BoundCheck for CreateTestcaseRequest { + fn check(&self) -> bool { + self.info.input.len() > 256 * 1024 || self.info.output.len() > 256 * 1024 + } +} + +impl BoundCheck for UpdateTestcaseRequest { + fn check(&self) -> bool { + self.info.input.as_ref().map(Vec::len).unwrap_or_default() > 256 * 1024 + || self.info.output.as_ref().map(Vec::len).unwrap_or_default() > 256 * 1024 + } +} + +impl BoundCheck for CreateUserRequest { + fn check(&self) -> bool { + self.info.username.len() > 256 || self.info.password.len() > 256 + } +} + +impl BoundCheck for UpdateUserRequest { + fn check(&self) -> bool { + self.info + .username + .as_ref() + .map(String::len) + .unwrap_or_default() + > 256 + || self + .info + .password + .as_ref() + .map(String::len) + .unwrap_or_default() + > 256 + } +} diff --git a/backend/src/util/error.rs b/backend/src/util/error.rs index b0bd71d2..88efca9b 100644 --- a/backend/src/util/error.rs +++ b/backend/src/util/error.rs @@ -7,6 +7,8 @@ use uuid::Uuid; use super::auth::RoleLv; +pub type Result = std::result::Result; + /// Centralized Error for endpoint, usually calling with `Into::into()` /// to tramsform it into `Status` immediately #[derive(Debug, thiserror::Error)] @@ -31,8 +33,8 @@ pub enum Error { Unreachable(&'static str), #[error("Number too large(or small)")] NumberTooLarge, - #[error("Buffer `{0}` too large")] - BufferTooLarge(&'static str), + // #[error("Buffer `{0}` too large")] + // BufferTooLarge(&'static str), #[error("Already exist")] AlreadyExist(String), #[error("You need to own `{0}` to add thing onto it")] @@ -79,7 +81,7 @@ impl From for Status { } Error::Unreachable(x) => report_internal!(error, "{}", x), Error::NumberTooLarge => Status::invalid_argument("number too large"), - Error::BufferTooLarge(x) => Status::invalid_argument(format!("{} too large", x)), + // Error::BufferTooLarge(x) => Status::invalid_argument(format!("{} too large", x)), Error::AlreadyExist(x) => { tracing::trace!(username = x, "entity_exist"); Status::already_exists(format!("{} already exist", x)) diff --git a/backend/src/util/mod.rs b/backend/src/util/mod.rs index d673ca6d..caeaf085 100644 --- a/backend/src/util/mod.rs +++ b/backend/src/util/mod.rs @@ -1,4 +1,5 @@ pub mod auth; +pub mod bound; pub mod code; pub mod error; pub mod parse; diff --git a/grpc/src/backend.rs b/grpc/src/backend.rs index aabfbff3..5755057f 100644 --- a/grpc/src/backend.rs +++ b/grpc/src/backend.rs @@ -3,4 +3,4 @@ mod backend { tonic::include_proto!("oj.backend"); } -pub use backend::*; \ No newline at end of file +pub use backend::*;