From 552176ed31f6e20b4e3391e37a035b556500d6f2 Mon Sep 17 00:00:00 2001 From: Vika Date: Mon, 10 May 2021 15:56:20 +0300 Subject: Removed openssl dependency - now the code is pure Rust --- Cargo.lock | 360 +++++++++++++++++++++++-------------------------------------- Cargo.toml | 5 +- flake.nix | 8 +- 3 files changed, 140 insertions(+), 233 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f3f99d7..766fd5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -306,6 +306,19 @@ dependencies = [ "winapi", ] +[[package]] +name = "async-tls" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d85a97c4a0ecce878efd3f945f119c78a646d8975340bca0398f9bb05c30cc52" +dependencies = [ + "futures-core", + "futures-io", + "rustls", + "webpki", + "webpki-roots", +] + [[package]] name = "async-trait" version = "0.1.50" @@ -433,12 +446,6 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" -[[package]] -name = "bytes" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" - [[package]] name = "bytes" version = "1.0.1" @@ -509,7 +516,7 @@ version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc4369b5e4c0cddf64ad8981c0111e7df4f7078f4d6ba98fb31f2e17c4c57b7e" dependencies = [ - "bytes 1.0.1", + "bytes", "futures-util", "memchr", "pin-project-lite 0.2.6", @@ -525,6 +532,17 @@ dependencies = [ "cache-padded", ] +[[package]] +name = "config" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b076e143e1d9538dde65da30f8481c2a6c44040edb8e02b9bf1351edb92ce3" +dependencies = [ + "lazy_static", + "nom", + "serde", +] + [[package]] name = "const_fn" version = "0.4.7" @@ -659,37 +677,6 @@ dependencies = [ "cipher", ] -[[package]] -name = "curl" -version = "0.4.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0bac9f84ca0977c4d9b8db998689de55b9e976656a6bc87fada2ca710d504c7" -dependencies = [ - "curl-sys", - "libc", - "openssl-probe", - "openssl-sys", - "schannel", - "socket2", - "winapi", -] - -[[package]] -name = "curl-sys" -version = "0.4.42+curl-7.76.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4636d8d6109c842707018a104051436bffb8991ea20b2d1293db70b6e0ee4c7c" -dependencies = [ - "cc", - "libc", - "libnghttp2-sys", - "libz-sys", - "openssl-sys", - "pkg-config", - "vcpkg", - "winapi", -] - [[package]] name = "dashmap" version = "4.0.2" @@ -706,6 +693,20 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" +[[package]] +name = "deadpool" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d126179d86aee4556e54f5f3c6bf6d9884e7cc52cef82f77ee6f90a7747616d" +dependencies = [ + "async-trait", + "config", + "crossbeam-queue", + "num_cpus", + "serde", + "tokio", +] + [[package]] name = "derive_more" version = "0.99.13" @@ -827,23 +828,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "flume" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bebadab126f8120d410b677ed95eee4ba6eb7c6dd8e34a5ec88a08050e26132" -dependencies = [ - "futures-core", - "futures-sink", - "spinning_top", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - [[package]] name = "form_urlencoded" version = "1.0.1" @@ -1100,29 +1084,21 @@ dependencies = [ "syn", ] -[[package]] -name = "http" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "527e8c9ac747e28542699a951517aa9a6945af506cd1f2e1b53a576c17b6cc11" -dependencies = [ - "bytes 1.0.1", - "fnv", - "itoa", -] - [[package]] name = "http-client" version = "6.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5566ecc26bc6b04e773e680d66141fced78e091ad818e420d726c152b05a64ff" dependencies = [ + "async-h1", "async-std", + "async-tls", "async-trait", "cfg-if 1.0.0", "dashmap", + "deadpool", + "futures", "http-types", - "isahc", "log", ] @@ -1186,29 +1162,6 @@ dependencies = [ "cfg-if 1.0.0", ] -[[package]] -name = "isahc" -version = "0.9.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2948a0ce43e2c2ef11d7edf6816508998d99e13badd1150be0914205df9388a" -dependencies = [ - "bytes 0.5.6", - "crossbeam-utils", - "curl", - "curl-sys", - "flume", - "futures-lite", - "http", - "log", - "once_cell", - "slab", - "sluice", - "tracing", - "tracing-futures", - "url", - "waker-fn", -] - [[package]] name = "itoa" version = "0.4.7" @@ -1284,41 +1237,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] -name = "libc" -version = "0.2.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" - -[[package]] -name = "libnghttp2-sys" -version = "0.1.6+1.43.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0af55541a8827e138d59ec9e5877fb6095ece63fb6f4da45e7491b4fbd262855" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "libz-sys" -version = "1.1.3" +name = "lexical-core" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66" +checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe" dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", + "arrayvec", + "bitflags", + "cfg-if 1.0.0", + "ryu", + "static_assertions", ] [[package]] -name = "lock_api" -version = "0.4.4" +name = "libc" +version = "0.2.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" -dependencies = [ - "scopeguard", -] +checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" [[package]] name = "log" @@ -1472,6 +1407,17 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" +[[package]] +name = "nom" +version = "5.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" +dependencies = [ + "lexical-core", + "memchr", + "version_check", +] + [[package]] name = "num-integer" version = "0.1.44" @@ -1513,25 +1459,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "openssl-probe" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" - -[[package]] -name = "openssl-sys" -version = "0.9.62" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa52160d45fa2e7608d504b7c3a3355afed615e6d8b627a74458634ba21b69bd" -dependencies = [ - "autocfg", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "parking" version = "2.0.0" @@ -1642,12 +1569,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d15b6607fa632996eb8a17c9041cb6071cb75ac057abd45dece578723ea8c7c0" -[[package]] -name = "pkg-config" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" - [[package]] name = "polling" version = "2.0.3" @@ -1850,7 +1771,7 @@ checksum = "1a6ddfecac9391fed21cce10e83c65fa4abafd77df05c98b1c647c65374ce9b3" dependencies = [ "async-std", "async-trait", - "bytes 1.0.1", + "bytes", "combine", "dtoa", "futures-util", @@ -1901,6 +1822,21 @@ dependencies = [ "rand 0.8.3", ] +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi", +] + [[package]] name = "route-recognizer" version = "0.2.0" @@ -1916,6 +1852,19 @@ dependencies = [ "semver", ] +[[package]] +name = "rustls" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d1126dcf58e93cee7d098dbda643b5f92ed724f1f6a63007c1116eed6700c81" +dependencies = [ + "base64 0.12.3", + "log", + "ring", + "sct", + "webpki", +] + [[package]] name = "ryu" version = "1.0.5" @@ -1923,21 +1872,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] -name = "schannel" -version = "0.1.19" +name = "sct" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" +checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" dependencies = [ - "lazy_static", - "winapi", + "ring", + "untrusted", ] -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - [[package]] name = "selectors" version = "0.22.0" @@ -2097,17 +2040,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" -[[package]] -name = "sluice" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fa0333a60ff2e3474a6775cc611840c2a55610c831dd366503474c02f1a28f5" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", -] - [[package]] name = "smallvec" version = "1.6.1" @@ -2125,13 +2057,10 @@ dependencies = [ ] [[package]] -name = "spinning_top" -version = "0.2.3" +name = "spin" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bd0ab6b8c375d2d963503b90d3770010d95bc3b5f98036f948dee24bf4e8879" -dependencies = [ - "lock_api", -] +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] name = "stable_deref_trait" @@ -2148,6 +2077,12 @@ dependencies = [ "version_check", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "stdweb" version = "0.4.20" @@ -2243,7 +2178,6 @@ dependencies = [ "http-types", "log", "mime_guess", - "once_cell", "pin-project-lite 0.2.6", "serde", "serde_json", @@ -2429,7 +2363,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83f0c8e7c0addab50b663055baf787d0af7f413a46e6e7fb9559a4e4db7137a5" dependencies = [ "autocfg", - "bytes 1.0.1", + "bytes", "memchr", "num_cpus", "pin-project-lite 0.2.6", @@ -2441,7 +2375,7 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "940a12c99365c31ea8dd9ba04ec1be183ffe4920102bb7122c2f515437601e8e" dependencies = [ - "bytes 1.0.1", + "bytes", "futures-core", "futures-sink", "log", @@ -2449,49 +2383,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tracing" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" -dependencies = [ - "cfg-if 1.0.0", - "log", - "pin-project-lite 0.2.6", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing-core" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "tracing-futures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" -dependencies = [ - "pin-project", - "tracing", -] - [[package]] name = "typenum" version = "1.13.0" @@ -2547,6 +2438,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + [[package]] name = "url" version = "2.2.1" @@ -2576,12 +2473,6 @@ dependencies = [ "sval", ] -[[package]] -name = "vcpkg" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbdbff6266a24120518560b5dc983096efb98462e51d0d68169895b237be3e5d" - [[package]] name = "version_check" version = "0.9.3" @@ -2684,6 +2575,25 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki" +version = "0.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webpki-roots" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f20dea7535251981a9670857150d571846545088359b28e4951d350bdaf179f" +dependencies = [ + "webpki", +] + [[package]] name = "wepoll-sys" version = "3.0.1" diff --git a/Cargo.toml b/Cargo.toml index 83ff9ab..de17d38 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,6 @@ newbase60 = "0.1.3" # A library that implements Tantek Çelik's New Base retainer = "0.2.2" # Minimal async cache in Rust with support for key expirations serde_json = "1.0.64" # A JSON serialization file format serde_urlencoded = "0.7.0" # `x-www-form-urlencoded` meets Serde -surf = "2.2.0" # Surf the web - HTTP client framework tide = "0.16.0" # A minimal and pragmatic Rust web application framework built for rapid development [dependencies.async-std] # Async version of the Rust standard library version = "1.9.0" @@ -43,6 +42,10 @@ default-features = false [dependencies.serde] # A generic serialization/deserialization framework version = "1.0.125" features = ["derive"] +[dependencies.surf] # Surf the web - HTTP client framework +version = "2.2.0" +default-features = false +features = ["h1-client-rustls", "encoding", "middleware-logger"] [dependencies.url] # URL library for Rust, based on the WHATWG URL Standard version = "2.2.1" features = ["serde"] diff --git a/flake.nix b/flake.nix index 0cf7d95..8041d7a 100644 --- a/flake.nix +++ b/flake.nix @@ -27,18 +27,13 @@ }; rust-bin = pkgs.rust-bin.stable.latest; packages = { - kittybox-micropub = { stdenv, lib, openssl, pkg-config, redis, naersk-lib }: + kittybox-micropub = { stdenv, lib, redis, naersk-lib }: naersk-lib.buildPackage { pname = "kittybox-micropub"; version = "0.1.0"; src = ./.; - #cargoSha256 = nixpkgs.lib.fakeSha256; - #cargoHash = "sha256-c862J7qXkrCAA6+gFn/bX5NXrgu/1HtCH1DqOpQePgk="; - - buildInputs = [ openssl ]; - nativeBuildInputs = [ pkg-config ]; checkInputs = [ redis ]; doCheck = stdenv.hostPlatform == stdenv.targetPlatform; @@ -62,7 +57,6 @@ devShell = pkgs.mkShell { name = "rust-dev-shell"; - buildInputs = with pkgs; [ openssl ]; nativeBuildInputs = with pkgs; [ pkg-config lld rust-bin.default -- cgit 1.4.1