diff --git a/CHANGELOG.md b/CHANGELOG.md index 8946c92..059089d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 2.2.4 | TBD + +- Added a message for if the Spotify AP connection drops +- Added additional timeouts to credential retrieval +- Removed multiple points of failure in `librespot` that could shut down the bot +- Fixed an issue where non-premium users could crash the bot for everyone (See point 3) + ## 2.2.3 | September 20th 2024 - Made backend changes to librespot to prevent deadlocking by not waiting for thread shutdowns diff --git a/Cargo.lock b/Cargo.lock index a8579b0..b2fadc7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -168,9 +168,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.82" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", @@ -205,9 +205,36 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "aws-lc-rs" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f95446d919226d587817a7d21379e6eb099b97b45110a7f272a444ca5c54070" +dependencies = [ + "aws-lc-sys", + "mirai-annotations", + "paste", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3ddc4a5b231dd6958b140ff3151b6412b3f4321fab354f399eec8f14b06df62" +dependencies = [ + "bindgen", + "cc", + "cmake", + "dunce", + "fs_extra", + "libc", + "paste", +] [[package]] name = "backtrace" @@ -248,6 +275,29 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[package]] +name = "bindgen" +version = "0.69.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" +dependencies = [ + "bitflags 2.6.0", + "cexpr", + "clang-sys", + "itertools", + "lazy_static", + "lazycell", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash 1.1.0", + "shlex", + "syn 2.0.77", + "which", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -332,13 +382,24 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.21" +version = "1.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" +checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0" dependencies = [ + "jobserver", + "libc", "shlex", ] +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -371,6 +432,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "cmake" version = "0.1.51" @@ -649,12 +721,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2658621297f2cf68762a6f7dc0bb7e1ff2cfd6583daef8ee0fed6f7ec468ec0" dependencies = [ "darling 0.10.2", - "derive_builder_core", + "derive_builder_core 0.9.0", "proc-macro2", "quote", "syn 1.0.109", ] +[[package]] +name = "derive_builder" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd33f37ee6a119146a1781d3356a7c26028f83d779b2e04ecd45fdc75c76877b" +dependencies = [ + "derive_builder_macro", +] + [[package]] name = "derive_builder_core" version = "0.9.0" @@ -667,6 +748,28 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_builder_core" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7431fa049613920234f22c47fdc33e6cf3ee83067091ea4277a3f8c4587aae38" +dependencies = [ + "darling 0.20.10", + "proc-macro2", + "quote", + "syn 2.0.77", +] + +[[package]] +name = "derive_builder_macro" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4abae7035bf79b9877b779505d8cf3749285b80c43941eda66604841889451dc" +dependencies = [ + "derive_builder_core 0.20.1", + "syn 2.0.77", +] + [[package]] name = "derive_more" version = "0.99.18" @@ -796,6 +899,12 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + [[package]] name = "either" version = "1.13.0" @@ -891,9 +1000,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.33" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" dependencies = [ "crc32fast", "miniz_oxide", @@ -944,6 +1053,12 @@ dependencies = [ "hashmap_derive", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "futures" version = "0.3.30" @@ -1250,7 +1365,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b906521a5b0e6d2ec07ea0bb855d92a1db30b48812744a645a3b2a1405cb8159" dependencies = [ - "derive_builder", + "derive_builder 0.9.0", "derive_more", "hex", "shorthand", @@ -1471,7 +1586,9 @@ dependencies = [ "http 1.1.0", "hyper 1.4.1", "hyper-util", + "log", "rustls 0.23.13", + "rustls-native-certs 0.8.0", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -1481,9 +1598,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" +checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" dependencies = [ "bytes", "futures-channel", @@ -1494,7 +1611,6 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", - "tower", "tower-service", "tracing", ] @@ -1510,7 +1626,7 @@ dependencies = [ "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows-core", + "windows-core 0.52.0", ] [[package]] @@ -1579,12 +1695,30 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +[[package]] +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.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.70" @@ -1603,6 +1737,12 @@ dependencies = [ "spin 0.9.8", ] +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "levenshtein" version = "1.0.5" @@ -1611,9 +1751,9 @@ checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760" [[package]] name = "lexical-core" -version = "0.8.5" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cde5de06e8d4c2faabc400238f9ae1c74d5412d03a7bd067645ccbc47070e46" +checksum = "0431c65b318a590c1de6b8fd6e72798c92291d27762d94c9e6c37ed7a73d8458" dependencies = [ "lexical-parse-float", "lexical-parse-integer", @@ -1624,9 +1764,9 @@ dependencies = [ [[package]] name = "lexical-parse-float" -version = "0.8.5" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683b3a5ebd0130b8fb52ba0bdc718cc56815b6a097e28ae5a6997d0ad17dc05f" +checksum = "eb17a4bdb9b418051aa59d41d65b1c9be5affab314a872e5ad7f06231fb3b4e0" dependencies = [ "lexical-parse-integer", "lexical-util", @@ -1635,9 +1775,9 @@ dependencies = [ [[package]] name = "lexical-parse-integer" -version = "0.8.6" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d0994485ed0c312f6d965766754ea177d07f9c00c9b82a5ee62ed5b47945ee9" +checksum = "5df98f4a4ab53bf8b175b363a34c7af608fe31f93cc1fb1bf07130622ca4ef61" dependencies = [ "lexical-util", "static_assertions", @@ -1645,18 +1785,18 @@ dependencies = [ [[package]] name = "lexical-util" -version = "0.8.5" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5255b9ff16ff898710eb9eb63cb39248ea8a5bb036bea8085b1a767ff6c4e3fc" +checksum = "85314db53332e5c192b6bca611fb10c114a80d1b831ddac0af1e9be1b9232ca0" dependencies = [ "static_assertions", ] [[package]] name = "lexical-write-float" -version = "0.8.5" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accabaa1c4581f05a3923d1b4cfd124c329352288b7b9da09e766b0668116862" +checksum = "6e7c3ad4e37db81c1cbe7cf34610340adc09c322871972f74877a712abc6c809" dependencies = [ "lexical-util", "lexical-write-integer", @@ -1665,9 +1805,9 @@ dependencies = [ [[package]] name = "lexical-write-integer" -version = "0.8.5" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1b6f3d1f4422866b68192d62f77bc5c700bee84f3069f2469d7bc8c77852446" +checksum = "eb89e9f6958b83258afa3deed90b5de9ef68eef090ad5086c791cd2345610162" dependencies = [ "lexical-util", "static_assertions", @@ -1675,9 +1815,19 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.158" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" + +[[package]] +name = "libloading" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" +dependencies = [ + "cfg-if", + "windows-targets 0.52.6", +] [[package]] name = "libm" @@ -1706,7 +1856,7 @@ dependencies = [ [[package]] name = "librespot" version = "0.5.0-dev" -source = "git+https://github.com/SpoticordMusic/librespot.git#47069dee2c5fdb705f0484cdbd3cd28f3bb949b5" +source = "git+https://github.com/SpoticordMusic/librespot.git#32d17580fcf785062f10a6634d6735d29e5304cc" dependencies = [ "data-encoding", "env_logger", @@ -1717,6 +1867,7 @@ dependencies = [ "librespot-core", "librespot-discovery", "librespot-metadata", + "librespot-oauth", "librespot-playback", "librespot-protocol", "log", @@ -1732,7 +1883,7 @@ dependencies = [ [[package]] name = "librespot-audio" version = "0.5.0-dev" -source = "git+https://github.com/SpoticordMusic/librespot.git#47069dee2c5fdb705f0484cdbd3cd28f3bb949b5" +source = "git+https://github.com/SpoticordMusic/librespot.git#32d17580fcf785062f10a6634d6735d29e5304cc" dependencies = [ "aes", "byteorder", @@ -1754,7 +1905,7 @@ dependencies = [ [[package]] name = "librespot-connect" version = "0.5.0-dev" -source = "git+https://github.com/SpoticordMusic/librespot.git#47069dee2c5fdb705f0484cdbd3cd28f3bb949b5" +source = "git+https://github.com/SpoticordMusic/librespot.git#32d17580fcf785062f10a6634d6735d29e5304cc" dependencies = [ "form_urlencoded", "futures-util", @@ -1774,7 +1925,7 @@ dependencies = [ [[package]] name = "librespot-core" version = "0.5.0-dev" -source = "git+https://github.com/SpoticordMusic/librespot.git#47069dee2c5fdb705f0484cdbd3cd28f3bb949b5" +source = "git+https://github.com/SpoticordMusic/librespot.git#32d17580fcf785062f10a6634d6735d29e5304cc" dependencies = [ "aes", "base64 0.22.1", @@ -1791,8 +1942,9 @@ dependencies = [ "httparse", "hyper 1.4.1", "hyper-proxy2", - "hyper-rustls 0.26.0", + "hyper-rustls 0.27.3", "hyper-util", + "librespot-oauth", "librespot-protocol", "log", "nonzero_ext", @@ -1821,13 +1973,13 @@ dependencies = [ "tokio-util", "url", "uuid", - "vergen", + "vergen-gitcl", ] [[package]] name = "librespot-discovery" version = "0.5.0-dev" -source = "git+https://github.com/SpoticordMusic/librespot.git#47069dee2c5fdb705f0484cdbd3cd28f3bb949b5" +source = "git+https://github.com/SpoticordMusic/librespot.git#32d17580fcf785062f10a6634d6735d29e5304cc" dependencies = [ "aes", "base64 0.22.1", @@ -1854,7 +2006,7 @@ dependencies = [ [[package]] name = "librespot-metadata" version = "0.5.0-dev" -source = "git+https://github.com/SpoticordMusic/librespot.git#47069dee2c5fdb705f0484cdbd3cd28f3bb949b5" +source = "git+https://github.com/SpoticordMusic/librespot.git#32d17580fcf785062f10a6634d6735d29e5304cc" dependencies = [ "async-trait", "byteorder", @@ -1869,10 +2021,21 @@ dependencies = [ "uuid", ] +[[package]] +name = "librespot-oauth" +version = "0.5.0-dev" +source = "git+https://github.com/SpoticordMusic/librespot.git#32d17580fcf785062f10a6634d6735d29e5304cc" +dependencies = [ + "log", + "oauth2", + "thiserror", + "url", +] + [[package]] name = "librespot-playback" version = "0.5.0-dev" -source = "git+https://github.com/SpoticordMusic/librespot.git#47069dee2c5fdb705f0484cdbd3cd28f3bb949b5" +source = "git+https://github.com/SpoticordMusic/librespot.git#32d17580fcf785062f10a6634d6735d29e5304cc" dependencies = [ "byteorder", "futures-util", @@ -1893,7 +2056,7 @@ dependencies = [ [[package]] name = "librespot-protocol" version = "0.5.0-dev" -source = "git+https://github.com/SpoticordMusic/librespot.git#47069dee2c5fdb705f0484cdbd3cd28f3bb949b5" +source = "git+https://github.com/SpoticordMusic/librespot.git#32d17580fcf785062f10a6634d6735d29e5304cc" dependencies = [ "protobuf", "protobuf-codegen", @@ -2003,6 +2166,12 @@ dependencies = [ "triomphe", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.8.0" @@ -2024,6 +2193,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "mirai-annotations" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9be0862c1b3f26a88803c4a49de6889c10e608b3ee9344e6ef5b45fb37ad3d1" + [[package]] name = "multimap" version = "0.10.0" @@ -2066,6 +2241,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "nonzero_ext" version = "0.3.0" @@ -2194,6 +2379,26 @@ dependencies = [ "libc", ] +[[package]] +name = "oauth2" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c38841cdd844847e3e7c8d29cef9dcfed8877f8f56f9071f77843ecf3baf937f" +dependencies = [ + "base64 0.13.1", + "chrono", + "getrandom", + "http 0.2.12", + "rand", + "reqwest 0.11.27", + "serde", + "serde_json", + "serde_path_to_error", + "sha2", + "thiserror", + "url", +] + [[package]] name = "object" version = "0.36.4" @@ -2262,6 +2467,12 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + [[package]] name = "patricia_tree" version = "0.8.0" @@ -2379,9 +2590,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "pnet_base" @@ -2455,9 +2666,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" +checksum = "d30538d42559de6b034bc76fd6dd4c38961b1ee5c6c56e3808c50128fdbc22ce" [[package]] name = "postgres-protocol" @@ -2512,6 +2723,16 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "prettyplease" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" +dependencies = [ + "proc-macro2", + "syn 2.0.77", +] + [[package]] name = "primal-check" version = "0.3.4" @@ -2523,9 +2744,9 @@ dependencies = [ [[package]] name = "priority-queue" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "560bcab673ff7f6ca9e270c17bf3affd8a05e3bd9207f123b0d45076fd8197e8" +checksum = "714c75db297bc88a63783ffc6ab9f830698a6705aa0201416931759ef4c8183d" dependencies = [ "autocfg", "equivalent", @@ -2605,9 +2826,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.32.0" +version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d3a6e5838b60e0e8fa7a43f22ade549a37d61f8bdbe636d0d7816191de969c2" +checksum = "f7649a7b4df05aed9ea7ec6f628c67c9953a43869b8bc50929569b2999d443fe" dependencies = [ "memchr", "serde", @@ -2623,7 +2844,7 @@ dependencies = [ "pin-project-lite", "quinn-proto", "quinn-udp", - "rustc-hash", + "rustc-hash 2.0.0", "rustls 0.23.13", "socket2", "thiserror", @@ -2640,7 +2861,7 @@ dependencies = [ "bytes", "rand", "ring 0.17.8", - "rustc-hash", + "rustc-hash 2.0.0", "rustls 0.23.13", "slab", "thiserror", @@ -2712,9 +2933,9 @@ dependencies = [ [[package]] name = "realfft" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953d9f7e5cdd80963547b456251296efc2626ed4e3cbf36c869d9564e0220571" +checksum = "390252372b7f2aac8360fc5e72eba10136b166d6faeed97e6d0c8324eb99b2b1" dependencies = [ "rustfft", ] @@ -2734,9 +2955,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.4" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" +checksum = "355ae415ccd3a04315d3f8246e86d67689ea74d88d915576e1589a351062a13b" dependencies = [ "bitflags 2.6.0", ] @@ -2924,9 +3145,9 @@ dependencies = [ [[package]] name = "ringbuf" -version = "0.4.4" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46f7f1b88601a8ee13cabf203611ccdf64345dc1c5d24de8b11e1a678ee619b6" +checksum = "fb0d14419487131a897031a7e81c3b23d092296984fac4eb6df48cc4e3b2f3c5" dependencies = [ "crossbeam-utils", ] @@ -3048,6 +3269,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-hash" version = "2.0.0" @@ -3135,6 +3362,8 @@ version = "0.23.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" dependencies = [ + "aws-lc-rs", + "log", "once_cell", "ring 0.17.8", "rustls-pki-types", @@ -3222,6 +3451,7 @@ version = "0.102.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ + "aws-lc-rs", "ring 0.17.8", "rustls-pki-types", "untrusted 0.9.0", @@ -3336,9 +3566,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.1" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" dependencies = [ "core-foundation-sys", "libc", @@ -3415,6 +3645,16 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_path_to_error" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6" +dependencies = [ + "itoa", + "serde", +] + [[package]] name = "serde_repr" version = "0.1.19" @@ -3573,9 +3813,9 @@ dependencies = [ [[package]] name = "simd-json" -version = "0.13.10" +version = "0.13.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "570c430b3d902ea083097e853263ae782dfe40857d93db019a12356c8e8143fa" +checksum = "a0228a564470f81724e30996bbc2b171713b37b15254a6440c7e2d5449b95691" dependencies = [ "getrandom", "halfbrown", @@ -3589,9 +3829,9 @@ dependencies = [ [[package]] name = "simdutf8" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" [[package]] name = "siphasher" @@ -3722,13 +3962,14 @@ dependencies = [ [[package]] name = "spoticord" -version = "2.2.3" +version = "2.2.4" dependencies = [ "anyhow", "dotenvy", "env_logger", "log", "poise", + "rustls 0.23.13", "serenity", "songbird", "spoticord_config", @@ -3742,7 +3983,7 @@ dependencies = [ [[package]] name = "spoticord_audio" -version = "2.2.3" +version = "2.2.4" dependencies = [ "librespot", "songbird", @@ -3752,7 +3993,7 @@ dependencies = [ [[package]] name = "spoticord_config" -version = "2.2.3" +version = "2.2.4" dependencies = [ "rspotify", "serenity", @@ -3760,7 +4001,7 @@ dependencies = [ [[package]] name = "spoticord_database" -version = "2.2.3" +version = "2.2.4" dependencies = [ "chrono", "diesel", @@ -3774,7 +4015,7 @@ dependencies = [ [[package]] name = "spoticord_player" -version = "2.2.3" +version = "2.2.4" dependencies = [ "anyhow", "hex", @@ -3789,7 +4030,7 @@ dependencies = [ [[package]] name = "spoticord_session" -version = "2.2.3" +version = "2.2.4" dependencies = [ "anyhow", "base64 0.22.1", @@ -3807,14 +4048,14 @@ dependencies = [ [[package]] name = "spoticord_stats" -version = "2.2.3" +version = "2.2.4" dependencies = [ "redis", ] [[package]] name = "spoticord_utils" -version = "2.2.3" +version = "2.2.4" dependencies = [ "anyhow", "base64 0.22.1", @@ -4079,16 +4320,15 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.30.13" +version = "0.31.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a5b4ddaee55fb2bea2bf0e5000747e5f5c0de765e5a5ff87f4cd106439f4bb3" +checksum = "355dbe4f8799b304b05e1b0f05fc59b2a18d36645cf169607da45bde2f69a1be" dependencies = [ - "cfg-if", "core-foundation-sys", "libc", + "memchr", "ntapi", - "once_cell", - "windows 0.52.0", + "windows 0.57.0", ] [[package]] @@ -4133,18 +4373,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", @@ -4401,27 +4641,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tower" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" -dependencies = [ - "futures-core", - "futures-util", - "pin-project", - "pin-project-lite", - "tokio", - "tower-layer", - "tower-service", -] - -[[package]] -name = "tower-layer" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" - [[package]] name = "tower-service" version = "0.3.3" @@ -4804,14 +5023,40 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vergen" -version = "8.3.2" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2990d9ea5967266ea0ccf413a4aa5c42a93dbcfda9cb49a97de6931726b12566" +checksum = "349ed9e45296a581f455bc18039878f409992999bc1d5da12a6800eb18c8752f" dependencies = [ "anyhow", - "cfg-if", + "derive_builder 0.20.1", "rustversion", "time", + "vergen-lib", +] + +[[package]] +name = "vergen-gitcl" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a3a7f91caabecefc3c249fd864b11d4abe315c166fbdb568964421bccfd2b7a" +dependencies = [ + "anyhow", + "derive_builder 0.20.1", + "rustversion", + "time", + "vergen", + "vergen-lib", +] + +[[package]] +name = "vergen-lib" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "229eaddb0050920816cf051e619affaf18caa3dd512de8de5839ccbc8e53abb0" +dependencies = [ + "anyhow", + "derive_builder 0.20.1", + "rustversion", ] [[package]] @@ -5035,7 +5280,17 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" dependencies = [ - "windows-core", + "windows-core 0.52.0", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143" +dependencies = [ + "windows-core 0.57.0", "windows-targets 0.52.6", ] @@ -5048,17 +5303,60 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-core" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-result 0.1.2", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-implement" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + +[[package]] +name = "windows-interface" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "windows-registry" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" dependencies = [ - "windows-result", + "windows-result 0.2.0", "windows-strings", "windows-targets 0.52.6", ] +[[package]] +name = "windows-result" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-result" version = "0.2.0" @@ -5074,7 +5372,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" dependencies = [ - "windows-result", + "windows-result 0.2.0", "windows-targets 0.52.6", ] diff --git a/Cargo.toml b/Cargo.toml index de2fc02..0b780a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spoticord" -version = "2.2.3" +version = "2.2.4" edition = "2021" rust-version = "1.80.0" @@ -39,6 +39,7 @@ poise = "0.6.1" serenity = "0.12.2" songbird = { version = "0.4.3", features = ["simd-json"] } tokio = { version = "1.39.3", features = ["full"] } +rustls = { version = "0.23.13", features = ["aws-lc-rs"] } [profile.release] opt-level = 3 diff --git a/spoticord_audio/Cargo.toml b/spoticord_audio/Cargo.toml index 53d0ceb..5a61a3b 100644 --- a/spoticord_audio/Cargo.toml +++ b/spoticord_audio/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spoticord_audio" -version = "2.2.3" +version = "2.2.4" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/spoticord_config/Cargo.toml b/spoticord_config/Cargo.toml index 5065259..fa21abe 100644 --- a/spoticord_config/Cargo.toml +++ b/spoticord_config/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spoticord_config" -version = "2.2.3" +version = "2.2.4" edition = "2021" [dependencies] diff --git a/spoticord_database/Cargo.toml b/spoticord_database/Cargo.toml index 0fd9e65..c8d8b0c 100644 --- a/spoticord_database/Cargo.toml +++ b/spoticord_database/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spoticord_database" -version = "2.2.3" +version = "2.2.4" edition = "2021" [dependencies] diff --git a/spoticord_player/Cargo.toml b/spoticord_player/Cargo.toml index 01fd22c..ac0b178 100644 --- a/spoticord_player/Cargo.toml +++ b/spoticord_player/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spoticord_player" -version = "2.2.3" +version = "2.2.4" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/spoticord_session/Cargo.toml b/spoticord_session/Cargo.toml index 1a1c702..e9a6c91 100644 --- a/spoticord_session/Cargo.toml +++ b/spoticord_session/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spoticord_session" -version = "2.2.3" +version = "2.2.4" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/spoticord_session/src/lib.rs b/spoticord_session/src/lib.rs index b0c1761..4332d80 100644 --- a/spoticord_session/src/lib.rs +++ b/spoticord_session/src/lib.rs @@ -106,7 +106,7 @@ impl Session { Err(why) => { error!("Failed to retrieve credentials: {why}"); - return Err(why.into()); + return Err(why); } }; let device_name = match session_manager.database().get_user(owner.to_string()).await { @@ -616,7 +616,7 @@ async fn retrieve_credentials(database: &Database, owner: impl AsRef) -> Re None => { let access_token = database.get_access_token(&account.user_id).await?; let credentials = spotify::request_session_token(Credentials { - username: account.username.clone(), + username: Some(account.username.to_string()), auth_type: AuthenticationType::AUTHENTICATION_SPOTIFY_TOKEN, auth_data: access_token.into_bytes(), }) @@ -632,7 +632,7 @@ async fn retrieve_credentials(database: &Database, owner: impl AsRef) -> Re }; Ok(Credentials { - username: account.username, + username: Some(account.username), auth_type: AuthenticationType::AUTHENTICATION_STORED_SPOTIFY_CREDENTIALS, auth_data: BASE64.decode(token)?, }) diff --git a/spoticord_stats/Cargo.toml b/spoticord_stats/Cargo.toml index aaf21cb..ee330c0 100644 --- a/spoticord_stats/Cargo.toml +++ b/spoticord_stats/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spoticord_stats" -version = "2.2.3" +version = "2.2.4" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/spoticord_utils/Cargo.toml b/spoticord_utils/Cargo.toml index f7e42b3..0ab8c3c 100644 --- a/spoticord_utils/Cargo.toml +++ b/spoticord_utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spoticord_utils" -version = "2.2.3" +version = "2.2.4" edition = "2021" [dependencies] diff --git a/spoticord_utils/src/spotify.rs b/spoticord_utils/src/spotify.rs index 4cdf2de..f9b0333 100644 --- a/spoticord_utils/src/spotify.rs +++ b/spoticord_utils/src/spotify.rs @@ -1,9 +1,9 @@ use anyhow::Result; use base64::{engine::general_purpose::STANDARD as BASE64, Engine}; use librespot::{ - core::{connection::AuthenticationError, Session, SessionConfig}, + core::{Session, SessionConfig}, discovery::Credentials, - protocol::{authentication::AuthenticationType, keyexchange::ErrorCode}, + protocol::authentication::AuthenticationType, }; use log::debug; use std::time::Duration; @@ -15,17 +15,17 @@ pub async fn validate_token( let auth_data = BASE64.decode(token.into())?; let credentials = Credentials { - username: username.into(), + username: Some(username.into()), auth_type: AuthenticationType::AUTHENTICATION_STORED_SPOTIFY_CREDENTIALS, auth_data, }; - debug!("Validating session token for {}", credentials.username); + debug!("Validating session token for {:?}", credentials.username); let new_credentials = request_session_token(credentials.clone()).await?; if credentials.auth_data != new_credentials.auth_data { - debug!("New session token retrieved for {}", credentials.username); + debug!("New session token retrieved for {:?}", credentials.username); return Ok(Some(BASE64.encode(new_credentials.auth_data))); } @@ -34,54 +34,45 @@ pub async fn validate_token( } pub async fn request_session_token(credentials: Credentials) -> Result { - debug!("Requesting session token for {}", credentials.username); + debug!("Requesting session token for {:?}", credentials.username); let session = Session::new(SessionConfig::default(), None); let mut tries = 0; Ok(loop { - let (host, port) = session.apresolver().resolve("accesspoint").await?; - - let mut transport = match librespot::core::connection::connect(&host, port, None).await { - Ok(transport) => transport, - Err(why) => { - // Retry - + match connect(&session, credentials.clone()).await { + Ok(creds) => break creds, + Err(e) => { tries += 1; if tries > 3 { - return Err(why.into()); + return Err(e); } tokio::time::sleep(Duration::from_millis(100)).await; - - continue; } - }; + } + }) +} - match librespot::core::connection::authenticate( +/// Wrapper around session connecting that times out if an operation is still busy after 3 seconds +async fn connect(session: &Session, credentials: Credentials) -> Result { + const TIMEOUT: Duration = Duration::from_secs(3); + + let (host, port) = + tokio::time::timeout(TIMEOUT, session.apresolver().resolve("accesspoint")).await??; + + // `connect` already has a 3 second timeout internally + let mut transport = librespot::core::connection::connect(&host, port, None).await?; + + let creds = tokio::time::timeout( + TIMEOUT, + librespot::core::connection::authenticate( &mut transport, credentials.clone(), &session.config().device_id, - ) - .await - { - Ok(creds) => break creds, - Err(e) => { - if let Some(AuthenticationError::LoginFailed(ErrorCode::TryAnotherAP)) = - e.error.downcast_ref::() - { - tries += 1; - if tries > 3 { - return Err(e.into()); - } + ), + ) + .await??; - tokio::time::sleep(Duration::from_millis(100)).await; - - continue; - } else { - return Err(e.into()); - } - } - }; - }) + Ok(creds) } diff --git a/src/main.rs b/src/main.rs index 7a761b7..7599770 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,5 @@ mod bot; mod commands; -// mod session; -// mod utils; use log::{error, info}; use poise::Framework; @@ -11,6 +9,11 @@ use spoticord_database::Database; #[tokio::main] async fn main() { + // Force aws-lc-rs as default crypto provider + // Since multiple dependencies either enable aws_lc_rs or ring, they cause a clash, so we have to + // explicitly tell rustls to use the aws-lc-rs provider + _ = rustls::crypto::aws_lc_rs::default_provider().install_default(); + // Setup logging if std::env::var("RUST_LOG").is_err() { #[cfg(debug_assertions)]