diff --git a/Cargo.lock b/Cargo.lock index c52f6767b..279e4a67d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -743,6 +743,24 @@ dependencies = [ "ahash", ] +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashlink" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d452c155cb93fecdfb02a73dd57b5d8e442c2063bd7aac72f1bc5e4263a43086" +dependencies = [ + "hashbrown 0.12.3", +] + [[package]] name = "headers" version = "0.3.7" @@ -871,7 +889,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.11.2", "serde 1.0.137", ] @@ -964,10 +982,11 @@ dependencies = [ [[package]] name = "libsqlite3-sys" -version = "0.18.0" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e704a02bcaecd4a08b93a23f6be59d0bd79cd161e0963e9499165a0a35df7bd" +checksum = "9f0455f2c1bc9a7caa792907026e469c1d91761fb0ea37cbb16427c77280cf35" dependencies = [ + "cc", "pkg-config", "vcpkg", ] @@ -1014,16 +1033,7 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ea2d928b485416e8908cff2d97d621db22b27f7b3b6729e438bcf42c671ba91" dependencies = [ - "hashbrown", -] - -[[package]] -name = "lru-cache" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" -dependencies = [ - "linked-hash-map", + "hashbrown 0.11.2", ] [[package]] @@ -1319,9 +1329,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.40" +version = "0.10.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb81a6430ac911acb25fe5ac8f1d2af1b4ea8a4fdfda0f1ee4292af2e2d8eb0e" +checksum = "618febf65336490dfcf20b73f885f5651a0c89c64c2d4a8c3662585a70bf5bd0" dependencies = [ "bitflags", "cfg-if", @@ -1349,15 +1359,25 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "111.22.0+1.1.1q" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f31f0d509d1c1ae9cada2f9539ff8f37933831fd5098879e482aa687d659853" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" -version = "0.9.73" +version = "0.9.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5fd19fb3e0a8191c1e34935718976a3e70c112ab9a24af6d7cadccd9d90bc0" +checksum = "e5f9bd0c2710541a3cda73d6f9ac4f1b240de4ae261065d309dbe73d9dceb42f" dependencies = [ "autocfg", "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] @@ -1370,17 +1390,7 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", - "parking_lot_core 0.8.5", -] - -[[package]] -name = "parking_lot" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" -dependencies = [ - "lock_api", - "parking_lot_core 0.9.3", + "parking_lot_core", ] [[package]] @@ -1397,19 +1407,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "parking_lot_core" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-sys", -] - [[package]] name = "peeking_take_while" version = "0.1.2" @@ -1514,7 +1511,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "545c5bc2b880973c9c10e4067418407a0ccaa3091781d1671d46eb35107cb26f" dependencies = [ "log", - "parking_lot 0.11.2", + "parking_lot", "scheduled-thread-pool", ] @@ -1530,9 +1527,9 @@ dependencies = [ [[package]] name = "r2d2_sqlite" -version = "0.16.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed60ebe88b27ac28c0563bc0fbeaecd302ff53e3a01e5ddc2ec9f4e6c707d929" +checksum = "b4f5d0337e99cd5cacd91ffc326c6cc9d8078def459df560c4f9bf9ba4a51034" dependencies = [ "r2d2", "rusqlite", @@ -1626,18 +1623,16 @@ dependencies = [ [[package]] name = "rusqlite" -version = "0.23.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45d0fd62e1df63d254714e6cb40d0a0e82e7a1623e7a27f679d851af092ae58b" +checksum = "01e213bc3ecb39ac32e81e51ebe31fd888a940515173e3a18a35f8c6e896422a" dependencies = [ "bitflags", "fallible-iterator", "fallible-streaming-iterator", + "hashlink", "libsqlite3-sys", - "lru-cache", - "memchr", "smallvec", - "time 0.1.44", ] [[package]] @@ -1728,7 +1723,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc6f74fd1204073fa02d5d5d68bec8021be4c38690b61264b2fdb48083d0e7d7" dependencies = [ - "parking_lot 0.11.2", + "parking_lot", ] [[package]] @@ -2243,7 +2238,6 @@ dependencies = [ "mio", "num_cpus", "once_cell", - "parking_lot 0.12.0", "pin-project-lite", "signal-hook-registry", "socket2", @@ -2253,9 +2247,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" +checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" dependencies = [ "proc-macro2", "quote", @@ -2348,6 +2342,7 @@ dependencies = [ "futures", "hex", "log", + "openssl", "percent-encoding", "r2d2", "r2d2_mysql", @@ -2714,49 +2709,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" -dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" - -[[package]] -name = "windows_i686_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" - -[[package]] -name = "windows_i686_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" - [[package]] name = "wyz" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 554ba940d..9d21ed7d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ lto = "fat" strip = true [dependencies] -tokio = { version = "1.7", features = ["full"] } +tokio = { version = "1.7", features = ["rt-multi-thread", "net", "sync", "macros", "signal"] } serde = { version = "1.0", features = ["derive"] } serde_bencode = "^0.2.3" @@ -29,6 +29,8 @@ hex = "0.4.3" percent-encoding = "2.1.0" binascii = "0.1" +openssl = { version = "0.10.41", features = ["vendored"] } + warp = { version = "0.3", features = ["tls"] } config = "0.11" @@ -40,7 +42,7 @@ chrono = "0.4" r2d2 = "0.8.8" r2d2_mysql = "21.0.0" -r2d2_sqlite = "0.16.0" +r2d2_sqlite = { version = "0.21.0", features = ["bundled"] } rand = "0.8.4" derive_more = "0.99" diff --git a/src/databases/sqlite.rs b/src/databases/sqlite.rs index e1659d897..143029ec2 100644 --- a/src/databases/sqlite.rs +++ b/src/databases/sqlite.rs @@ -4,7 +4,6 @@ use async_trait::async_trait; use log::debug; use r2d2::Pool; use r2d2_sqlite::SqliteConnectionManager; -use r2d2_sqlite::rusqlite::NO_PARAMS; use crate::{InfoHash}; use crate::databases::database::{Database, Error}; @@ -50,9 +49,9 @@ impl Database for SqliteDatabase { let conn = self.pool.get().map_err(|_| database::Error::DatabaseError)?; - conn.execute(&create_whitelist_table, NO_PARAMS) - .and_then(|_| conn.execute(&create_keys_table, NO_PARAMS)) - .and_then(|_| conn.execute(&create_torrents_table, NO_PARAMS)) + conn.execute(&create_whitelist_table, []) + .and_then(|_| conn.execute(&create_keys_table, [])) + .and_then(|_| conn.execute(&create_torrents_table, [])) .map_err(|_| database::Error::InvalidQuery) .map(|_| ()) } @@ -62,7 +61,7 @@ impl Database for SqliteDatabase { let mut stmt = conn.prepare("SELECT info_hash, completed FROM torrents")?; - let torrent_iter = stmt.query_map(NO_PARAMS, |row| { + let torrent_iter = stmt.query_map([], |row| { let info_hash_string: String = row.get(0)?; let info_hash = InfoHash::from_str(&info_hash_string).unwrap(); let completed: u32 = row.get(1)?; @@ -79,7 +78,7 @@ impl Database for SqliteDatabase { let mut stmt = conn.prepare("SELECT key, valid_until FROM keys")?; - let keys_iter = stmt.query_map(NO_PARAMS, |row| { + let keys_iter = stmt.query_map([], |row| { let key = row.get(0)?; let valid_until: i64 = row.get(1)?; @@ -99,7 +98,7 @@ impl Database for SqliteDatabase { let mut stmt = conn.prepare("SELECT info_hash FROM whitelist")?; - let info_hash_iter = stmt.query_map(NO_PARAMS, |row| { + let info_hash_iter = stmt.query_map([], |row| { let info_hash: String = row.get(0)?; Ok(InfoHash::from_str(&info_hash).unwrap()) @@ -113,7 +112,7 @@ impl Database for SqliteDatabase { async fn save_persistent_torrent(&self, info_hash: &InfoHash, completed: u32) -> Result<(), database::Error> { let conn = self.pool.get().map_err(|_| database::Error::DatabaseError)?; - match conn.execute("INSERT INTO torrents (info_hash, completed) VALUES (?1, ?2) ON CONFLICT(info_hash) DO UPDATE SET completed = ?2", &[info_hash.to_string(), completed.to_string()]) { + match conn.execute("INSERT INTO torrents (info_hash, completed) VALUES (?1, ?2) ON CONFLICT(info_hash) DO UPDATE SET completed = ?2", [info_hash.to_string(), completed.to_string()]) { Ok(updated) => { if updated > 0 { return Ok(()); } Err(database::Error::QueryReturnedNoRows) @@ -144,7 +143,7 @@ impl Database for SqliteDatabase { async fn add_info_hash_to_whitelist(&self, info_hash: InfoHash) -> Result { let conn = self.pool.get().map_err(|_| database::Error::DatabaseError)?; - match conn.execute("INSERT INTO whitelist (info_hash) VALUES (?)", &[info_hash.to_string()]) { + match conn.execute("INSERT INTO whitelist (info_hash) VALUES (?)", [info_hash.to_string()]) { Ok(updated) => { if updated > 0 { return Ok(updated); } Err(database::Error::QueryReturnedNoRows) @@ -159,7 +158,7 @@ impl Database for SqliteDatabase { async fn remove_info_hash_from_whitelist(&self, info_hash: InfoHash) -> Result { let conn = self.pool.get().map_err(|_| database::Error::DatabaseError)?; - match conn.execute("DELETE FROM whitelist WHERE info_hash = ?", &[info_hash.to_string()]) { + match conn.execute("DELETE FROM whitelist WHERE info_hash = ?", [info_hash.to_string()]) { Ok(updated) => { if updated > 0 { return Ok(updated); } Err(database::Error::QueryReturnedNoRows) @@ -175,7 +174,7 @@ impl Database for SqliteDatabase { let conn = self.pool.get().map_err(|_| database::Error::DatabaseError)?; let mut stmt = conn.prepare("SELECT key, valid_until FROM keys WHERE key = ?")?; - let mut rows = stmt.query(&[key.to_string()])?; + let mut rows = stmt.query([key.to_string()])?; if let Some(row) = rows.next()? { let key: String = row.get(0).unwrap(); @@ -194,7 +193,7 @@ impl Database for SqliteDatabase { let conn = self.pool.get().map_err(|_| database::Error::DatabaseError)?; match conn.execute("INSERT INTO keys (key, valid_until) VALUES (?1, ?2)", - &[auth_key.key.to_string(), auth_key.valid_until.unwrap().to_string()], + [auth_key.key.to_string(), auth_key.valid_until.unwrap().to_string()], ) { Ok(updated) => { if updated > 0 { return Ok(updated); }