From dabe176e0e051709640c048b41b03d8c7180c09e Mon Sep 17 00:00:00 2001 From: shiroyashik Date: Mon, 19 Aug 2024 22:54:45 +0300 Subject: [PATCH] =?UTF-8?q?(*=E2=89=A7=CF=89=E2=89=A6*)=20Preparing=20for?= =?UTF-8?q?=200.3.0=20release!=20~=20README=20revised=20~=20updated=20Dock?= =?UTF-8?q?er=20files=20+=20all=20const=20are=20placed=20in=20a=20separate?= =?UTF-8?q?=20file=20+=20auto=20creation=20for=20avatars=20folder=20+=20au?= =?UTF-8?q?tomatic=20retrieval=20of=20the=20latest=20Figura=20version=20fo?= =?UTF-8?q?r=20version=20request=20in=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CREDITS | 3 + Cargo.lock | 352 +++++++++++++++++++------------------ Cargo.toml | 2 +- Dockerfile | 1 + README.md | 82 ++++++--- docker-compose.example.yml | 3 +- src/api/figura/info.rs | 28 ++- src/api/figura/profile.rs | 4 +- src/auth/auth.rs | 8 +- src/consts.rs | 12 ++ src/main.rs | 27 ++- src/utils/check_updates.rs | 55 +++++- src/utils/mod.rs | 2 +- 13 files changed, 355 insertions(+), 224 deletions(-) create mode 100644 src/consts.rs diff --git a/CREDITS b/CREDITS index 40b70f1..95bff71 100644 --- a/CREDITS +++ b/CREDITS @@ -3,5 +3,8 @@ PoolloverNathan (https://github.com/PoolloverNathan) Martinz64 (https://github.com/Martinz64) for their work on which Sculptor was developed. +IntelMiner (https://github.com/IntelMiner) +for bug hunting and feature suggestions. + Contributors: korewaChino (https://github.com/korewaChino) \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 05f9338..d050139 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,7 +55,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.75", ] [[package]] @@ -149,7 +149,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.75", ] [[package]] @@ -214,15 +214,18 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.1" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "cc" -version = "1.1.6" +version = "1.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" +checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -232,9 +235,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cfg_aliases" -version = "0.1.1" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chrono" @@ -248,7 +251,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets 0.52.6", + "windows-targets", ] [[package]] @@ -321,15 +324,15 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" dependencies = [ "libc", ] @@ -392,12 +395,12 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.4.4" +version = "3.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "672465ae37dc1bc6380a6547a8883d5dd397b0f1faaad4f265726cc7042a5345" +checksum = "90eeab0aa92f3f9b4e87f258c72b139c207d251f9cbc1080a0086b86a8870dd3" dependencies = [ - "nix 0.28.0", - "windows-sys 0.52.0", + "nix 0.29.0", + "windows-sys 0.59.0", ] [[package]] @@ -467,9 +470,9 @@ checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" [[package]] name = "dunce" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "either" @@ -618,9 +621,9 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "h2" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" dependencies = [ "atomic-waker", "bytes", @@ -628,7 +631,7 @@ dependencies = [ "futures-core", "futures-sink", "http", - "indexmap 2.2.6", + "indexmap 2.4.0", "slab", "tokio", "tokio-util", @@ -785,9 +788,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" +checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" dependencies = [ "bytes", "futures-channel", @@ -854,9 +857,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown 0.14.5", @@ -882,9 +885,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ "wasm-bindgen", ] @@ -897,9 +900,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "libredox" @@ -971,9 +974,9 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ "hermit-abi 0.3.9", "libc", @@ -1011,9 +1014,9 @@ dependencies = [ [[package]] name = "nix" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -1084,7 +1087,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.75", ] [[package]] @@ -1146,7 +1149,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets 0.52.6", + "windows-targets", ] [[package]] @@ -1172,7 +1175,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.75", ] [[package]] @@ -1201,9 +1204,12 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "proc-macro-error" @@ -1288,9 +1294,9 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", @@ -1299,9 +1305,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.5" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", @@ -1343,9 +1349,9 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "reqwest" -version = "0.12.5" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" +checksum = "b6f6ddd79dc661ade721873783d159ec87d91d556ce92933e342bae8b87c48c0" dependencies = [ "base64 0.22.1", "bytes", @@ -1381,7 +1387,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "winreg", + "windows-registry", ] [[package]] @@ -1442,9 +1448,9 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" dependencies = [ "base64 0.22.1", "rustls-pki-types", @@ -1452,9 +1458,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" +checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" [[package]] name = "rustls-webpki" @@ -1514,7 +1520,7 @@ dependencies = [ "serde_json", "thiserror", "tokio", - "toml 0.8.16", + "toml 0.8.19", "tower-http", "tracing", "tracing-appender", @@ -1554,22 +1560,22 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.204" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.75", ] [[package]] @@ -1583,11 +1589,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.120" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -1655,6 +1662,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -1730,9 +1743,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.72" +version = "2.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9" dependencies = [ "proc-macro2", "quote", @@ -1750,23 +1763,26 @@ name = "sync_wrapper" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +dependencies = [ + "futures-core", +] [[package]] name = "system-configuration" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +checksum = "658bc6ee10a9b4fcf576e9b0819d95ec16f4d2c02d39fd83ac1c8789785c4a42" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", "core-foundation", "system-configuration-sys", ] [[package]] name = "system-configuration-sys" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" dependencies = [ "core-foundation-sys", "libc", @@ -1774,14 +1790,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.10.1" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1816,7 +1833,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.75", ] [[package]] @@ -1877,9 +1894,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.2" +version = "1.39.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" +checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" dependencies = [ "backtrace", "bytes", @@ -1901,7 +1918,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.75", ] [[package]] @@ -1961,9 +1978,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.16" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81967dd0dd2c1ab0bc3468bd7caecc32b8a4aa47d0c8c695d8c2b2108168d62c" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ "serde", "serde_spanned", @@ -1973,20 +1990,20 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8fb9f64314842840f1d940ac544da178732128f1c78c21772e876579e0da1db" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.17" +version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d9f8729f5aea9562aac1cc0441f5d6de3cff1ee0c5d67293eeca5eb36ee7c16" +checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2028,15 +2045,15 @@ dependencies = [ [[package]] name = "tower-layer" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -2070,7 +2087,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.75", ] [[package]] @@ -2242,34 +2259,35 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.75", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.42" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" dependencies = [ "cfg-if", "js-sys", @@ -2279,9 +2297,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2289,28 +2307,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.75", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "web-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" dependencies = [ "js-sys", "wasm-bindgen", @@ -2346,11 +2364,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2365,16 +2383,37 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.6", + "windows-targets", ] [[package]] -name = "windows-sys" -version = "0.48.0" +name = "windows-registry" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" dependencies = [ - "windows-targets 0.48.5", + "windows-result", + "windows-strings", + "windows-targets", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets", ] [[package]] @@ -2383,22 +2422,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.6", + "windows-targets", ] [[package]] -name = "windows-targets" -version = "0.48.5" +name = "windows-sys" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows-targets", ] [[package]] @@ -2407,46 +2440,28 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -2459,48 +2474,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -2509,21 +2500,32 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.16" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b480ae9340fc261e6be3e95a1ba86d54ae3f9171132a73ce8d4bbaf68339507c" +checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" dependencies = [ "memchr", ] [[package]] -name = "winreg" -version = "0.52.0" +name = "zerocopy" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "cfg-if", - "windows-sys 0.48.0", + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.75", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 0c8b5b2..785662b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ dashmap = "6.0.1" hex = "0.4.3" uuid = { version = "1.8.0", features = ["serde"] } base64 = "0.22.1" -reqwest = { version = "0.12.4", features = ["json"] } +reqwest = { version = "0.12.6", features = ["json"] } dotenvy = "0.15.7" semver = "1.0.23" diff --git a/Dockerfile b/Dockerfile index abebd2a..1fd1aa6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,7 @@ WORKDIR /app COPY --from=builder /build/target/release/sculptor /app/sculptor VOLUME [ "/app/avatars" ] +VOLUME [ "/app/logs" ] EXPOSE 6665/tcp CMD ["./sculptor"] \ No newline at end of file diff --git a/README.md b/README.md index 6e109ca..3ab5761 100644 --- a/README.md +++ b/README.md @@ -4,36 +4,52 @@ Unofficial backend V2 for the Minecraft mod [Figura](https://github.com/FiguraMC/Figura). -Implements Ping transmission functionality via Websocket and full avatar upload and download functionality. Currently incomplete and under active development +Is a worthy replacement for the official version. Realized all the functionality that can be used during the game. -And also a distinctive feature is the possibility of player identification through the third-party authorization system [Ely.By](https://ely.by/) +And also a distinctive feature is the possibility of player identification through third-party authentication providers (such as [Ely.By](https://ely.by/)) -## Usage +## Launch -### Docker +To run it you will need a configured reverse proxy server. -You will need an already configured Docker with Traefik (you can use any reverse proxy) - -1. Create avatars folder (it will store player avatars) -2. Copy Config.example.toml and rename it to Config.toml -3. Copy docker-compose.example.yml and rename to docker-compose.yml -4. Open docker.compose.yml and uncomment the "labels" to work with Traefik and add the container to the network with Traefik. -5. `docker compose up -d` this will build and run the container with - -### Native - -Running this way you won't need WSL when running on Windows, but.... - -To do this, you will need to reverse proxy port 6665 to your domain with SSL - -1. Create avatars folder (it will store player avatars) -2. Copy Config.example.toml and rename it to Config.toml -3. Set up your reverse proxy server -4. `cargo run` +Make sure that the reverse proxy you are using supports WebSocket and valid certificates are used for HTTPS connections. > [!IMPORTANT] > NGINX requires additional configuration to work with websocket! +### Docker + +For the template you can use [docker-compose.example.yml](docker-compose.example.yml) + +It assumes you will be using Traefik as a reverse proxy, if so uncomment the lines and add Sculptor to the network with Traefik. + +Copy [Config.example.toml](Config.example.toml) change the settings as desired and rename to Config.toml + +That's enough to start Sculptor. + +### Pre-Built + +See the [pre-built archives](https://github.com/shiroyashik/sculptor/releases/latest) + +### Build from source + +A pre-installed Rust will be required for the build + +```sh +# Clone the latest release +git clone https://github.com/shiroyashik/sculptor.git +# or a dev release +git clone --branch dev https://github.com/shiroyashik/sculptor.git +# Enter the folder +cd sculptor +# Copy Sculptor configuration file +cp Config.example.toml Config.toml +# Edit configuration file for your needs +nano Config.toml +# Build it in release mode for better performance +cargo build --release +``` + ## Public server [![Server status](https://up.shsr.ru/api/badge/1/status?upLabel=Online&downLabel=Offline&label=Server+status)](https://up.shsr.ru/status/pub) @@ -45,3 +61,25 @@ You can use it if running your own Sculptor instance is difficult for you. > figura.shsr.ru For reasons beyond my control, the server is not available in some countries. + +## Contributing + +If you have ideas for new features, have found a bug, or want to suggest improvements, +please create an [issue](https://github.com/shiroyashik/sculptor/issues) +or contact me directly via Discord (@shiroyashik). + +If you are a Rust developer, you can modify the code yourself and request a Pull Request: + +1. Fork the repository. +2. Create a new branch for your features or fixes. +3. Submit a PR. + +Glad for any help from ideas to PRs. + +#### P.S. + +The [“master”](https://github.com/shiroyashik/sculptor/tree/master) branch contains the source code of the latest release. A [“dev”](https://github.com/shiroyashik/sculptor/tree/dev) branch is used for development. + +## License + +The Sculptor is licensed under [GPL-3.0](LICENSE) diff --git a/docker-compose.example.yml b/docker-compose.example.yml index 0aebf07..bbe70e5 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -15,8 +15,9 @@ services: volumes: - ./Config.toml:/app/Config.toml:ro - ./avatars:/app/avatars + - ./logs:/app/logs environment: - - RUST_LOG=sculptor=info + - RUST_LOG=info ## Recommended for use with reverse proxy. # networks: # - traefik diff --git a/src/api/figura/info.rs b/src/api/figura/info.rs index 52ff8bd..a04df81 100644 --- a/src/api/figura/info.rs +++ b/src/api/figura/info.rs @@ -1,13 +1,29 @@ use axum::{extract::State, Json}; use serde_json::{json, Value}; +use tracing::error; -use crate::{utils::get_motd, AppState}; +use crate::{ + utils::{get_figura_versions, get_motd, FiguraVersions}, AppState, FIGURA_DEFAULT_VERSION +}; -pub async fn version() -> Json { - Json(json!({ - "release": "0.1.4", - "prerelease": "0.1.4" - })) +pub async fn version(State(state): State) -> Json { + let res = state.figura_versions.read().await.clone(); + if let Some(res) = res { + Json(res) + } else { + let actual = get_figura_versions().await; + if let Ok(res) = actual { + let mut stored = state.figura_versions.write().await; + *stored = Some(res); + return Json(stored.clone().unwrap()) + } else { + error!("get_figura_versions: {:?}", actual.unwrap_err()); + } + Json(FiguraVersions { + release: FIGURA_DEFAULT_VERSION.to_string(), + prerelease: FIGURA_DEFAULT_VERSION.to_string() + }) + } } pub async fn motd(State(state): State) -> String { diff --git a/src/api/figura/profile.rs b/src/api/figura/profile.rs index 1cf46c1..9281edc 100644 --- a/src/api/figura/profile.rs +++ b/src/api/figura/profile.rs @@ -13,7 +13,9 @@ use tokio::{ use uuid::Uuid; use crate::{ - api::errors::internal_and_log, auth::Token, utils::{calculate_file_sha256, format_uuid}, ApiError, ApiResult, AppState + api::errors::internal_and_log, + auth::Token, utils::{calculate_file_sha256, format_uuid}, + ApiError, ApiResult, AppState }; use super::types::S2CMessage; diff --git a/src/auth/auth.rs b/src/auth/auth.rs index d58c0eb..78a950e 100644 --- a/src/auth/auth.rs +++ b/src/auth/auth.rs @@ -1,4 +1,4 @@ -use std::{sync::Arc, time::Duration}; +use std::sync::Arc; use anyhow::anyhow; use axum::{ @@ -8,12 +8,10 @@ use dashmap::DashMap; use tracing::{debug, error, trace}; use uuid::Uuid; -use crate::{ApiError, ApiResult, AppState}; +use crate::{ApiError, ApiResult, AppState, TIMEOUT, USER_AGENT}; use super::types::*; -const TIMEOUT: Duration = Duration::from_secs(5); - // It's an extractor that pulls a token from the Header. #[derive(PartialEq, Debug)] pub struct Token(pub String); @@ -63,7 +61,7 @@ async fn fetch_json( server_id: &str, username: &str, ) -> anyhow::Result> { - let client = reqwest::Client::builder().timeout(TIMEOUT).build().unwrap(); + let client = reqwest::Client::builder().timeout(TIMEOUT).user_agent(USER_AGENT).build().unwrap(); let url = auth_provider.url.clone(); let res = client diff --git a/src/consts.rs b/src/consts.rs new file mode 100644 index 0000000..68da6e8 --- /dev/null +++ b/src/consts.rs @@ -0,0 +1,12 @@ +pub const LOGGER_ENV: &'static str = "RUST_LOG"; +pub const CONFIG_ENV: &'static str = "RUST_CONFIG"; +pub const LOGS_ENV: &'static str = "LOGS_FOLDER"; + +pub const SCULPTOR_VERSION: &'static str = env!("CARGO_PKG_VERSION"); +pub const REPOSITORY: &'static str = "shiroyashik/sculptor"; + +pub const USER_AGENT: &'static str = "reqwest"; +pub const TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10); + +pub const FIGURA_RELEASES_URL: &'static str = "https://api.github.com/repos/figuramc/figura/releases"; +pub const FIGURA_DEFAULT_VERSION: &'static str = "0.1.4"; \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 9925c09..e2e50b9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,12 +5,16 @@ use axum::{ use dashmap::DashMap; use tracing_panic::panic_hook; use tracing_subscriber::{fmt::{self, time::ChronoLocal}, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; -use std::sync::Arc; -use tokio::{sync::{broadcast, mpsc, RwLock}, time::Instant}; +use std::{path::PathBuf, sync::Arc}; +use tokio::{fs, sync::{broadcast, mpsc, RwLock}, time::Instant}; use tower_http::trace::TraceLayer; use tracing::info; use uuid::Uuid; +// Consts +mod consts; +pub use consts::*; + // Errors pub use api::errors::{ApiResult, ApiError}; @@ -31,7 +35,7 @@ use state::Config; // Utils mod utils; -use utils::{check_updates, get_log_file, update_advanced_users, update_bans_from_minecraft}; +use utils::{check_updates, get_log_file, update_advanced_users, update_bans_from_minecraft, FiguraVersions}; #[derive(Debug, Clone)] pub struct AppState { @@ -45,14 +49,10 @@ pub struct AppState { broadcasts: Arc>>>, /// Current configuration config: Arc>, + /// Figura Versions + figura_versions: Arc>>, } -const LOGGER_ENV: &'static str = "RUST_LOG"; -const CONFIG_ENV: &'static str = "RUST_CONFIG"; -const LOGS_ENV: &'static str = "LOGS_FOLDER"; -const SCULPTOR_VERSION: &'static str = env!("CARGO_PKG_VERSION"); -const REPOSITORY: &'static str = "shiroyashik/sculptor"; - #[tokio::main] async fn main() -> Result<()> { let _ = dotenvy::dotenv(); @@ -92,6 +92,14 @@ async fn main() -> Result<()> { // })); info!("The Sculptor v{}{}", SCULPTOR_VERSION, check_updates(REPOSITORY, &SCULPTOR_VERSION).await?); + + { + let path = PathBuf::from("avatars"); + if !path.exists() { + fs::create_dir(path).await.expect("Can't create avatars folder!"); + info!("Created avatars directory"); + } + } // Config let config = Arc::new(RwLock::new(Config::parse(config_file.clone().into()))); @@ -103,6 +111,7 @@ async fn main() -> Result<()> { user_manager: Arc::new(UManager::new()), session: Arc::new(DashMap::new()), broadcasts: Arc::new(DashMap::new()), + figura_versions: Arc::new(RwLock::new(None)), config, }; diff --git a/src/utils/check_updates.rs b/src/utils/check_updates.rs index a5c731b..fcabf61 100644 --- a/src/utils/check_updates.rs +++ b/src/utils/check_updates.rs @@ -1,9 +1,11 @@ use anyhow::anyhow; use reqwest::Client; use semver::Version; -use serde::Deserialize; +use serde::{Deserialize, Serialize}; use tracing::error; +use crate::{FIGURA_RELEASES_URL, TIMEOUT, USER_AGENT}; + #[derive(Deserialize, Debug)] struct Tag { name: String @@ -11,8 +13,8 @@ struct Tag { async fn get_latest_version(repo: &str, current_version: Version) -> anyhow::Result> { let url = format!("https://api.github.com/repos/{repo}/tags"); - let client = Client::new(); - let response = client.get(&url).header("User-Agent", "reqwest").send().await?; + let client = Client::builder().timeout(TIMEOUT).user_agent(USER_AGENT).build().unwrap(); + let response = client.get(&url).send().await?; if response.status().is_success() { let tags: Vec = response.json().await?; @@ -55,3 +57,50 @@ pub async fn check_updates(repo: &str, current_version: &str) -> anyhow::Result< } } +// Figura + +#[derive(Deserialize, Debug)] +struct Release { + tag_name: String, + prerelease: bool +} + +pub async fn get_figura_versions() -> anyhow::Result { + let client = Client::builder().timeout(TIMEOUT).user_agent(USER_AGENT).build().unwrap(); + let response = client.get(FIGURA_RELEASES_URL).send().await?; + + let mut release_ver = Version::new(0, 0, 0); + let mut prerelease_ver = Version::new(0, 0, 0); + + if response.status().is_success() { + let multiple_releases: Vec = response.json().await?; + for release in multiple_releases { + let tag_ver = if let Ok(res) = Version::parse(&release.tag_name) { res } else { + error!("Incorrect tag name! {release:?}"); + continue; + }; + if release.prerelease { + if tag_ver > prerelease_ver { + prerelease_ver = tag_ver + } + } else { + if tag_ver > release_ver { + release_ver = tag_ver + } + } + } + if release_ver > prerelease_ver { + prerelease_ver = release_ver.clone(); + } + // Stop + Ok(FiguraVersions { release: release_ver.to_string(), prerelease: prerelease_ver.to_string() }) + } else { + Err(anyhow!("Response status code: {}", response.status().as_u16())) + } +} + +#[derive(Serialize, Debug, Clone)] +pub struct FiguraVersions { + pub release: String, + pub prerelease: String +} \ No newline at end of file diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 05f72f6..171ee7e 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -4,4 +4,4 @@ mod motd; pub use utils::*; pub use motd::*; -pub use check_updates::check_updates; \ No newline at end of file +pub use check_updates::*; \ No newline at end of file