From 988aa9f155ab464a7e50a7d98ff653b62f78535e Mon Sep 17 00:00:00 2001 From: shockrah Date: Sat, 20 Mar 2021 13:56:02 -0700 Subject: [PATCH] Removal of chrono and async_trait as dependancy in db-lib Removig chrono from api code as well Removing chrono as dep in api code + Using Content-Type for /message/send content type Updating cargo lists for removal of fluff deps Removal of more fluff Addking makefile to avoid compiling debug builds by accident while developing --- json-api/Cargo.lock | 154 +--- json-api/Cargo.toml | 11 +- json-api/Makefile | 8 + json-api/db/Cargo.lock | 1576 ----------------------------------- json-api/db/Cargo.toml | 3 - json-api/db/src/common.rs | 27 - json-api/db/src/invites.rs | 133 +-- json-api/db/src/lib.rs | 22 +- json-api/db/src/member.rs | 96 +-- json-api/db/src/messages.rs | 13 +- json-api/src/admin.rs | 5 +- json-api/src/auth.rs | 21 +- json-api/src/channels.rs | 4 +- json-api/src/invites.rs | 43 +- json-api/src/main.rs | 15 +- json-api/src/members.rs | 5 +- json-api/src/messages.rs | 23 +- nginx-conf/freechat.conf | 18 - nginx-conf/readme.md | 42 - nginx-conf/self-signed.conf | 4 - nginx-conf/ssl-params.conf | 20 - 21 files changed, 181 insertions(+), 2062 deletions(-) create mode 100644 json-api/Makefile delete mode 100644 json-api/db/Cargo.lock delete mode 100644 nginx-conf/freechat.conf delete mode 100644 nginx-conf/readme.md delete mode 100644 nginx-conf/self-signed.conf delete mode 100644 nginx-conf/ssl-params.conf diff --git a/json-api/Cargo.lock b/json-api/Cargo.lock index 41d32e3..a09230e 100644 --- a/json-api/Cargo.lock +++ b/json-api/Cargo.lock @@ -48,17 +48,6 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" -[[package]] -name = "async-trait" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3340571769500ddef1e94b45055fabed6b08a881269b7570c830b8f32ef84ef" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "atty" version = "0.2.14" @@ -193,9 +182,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" @@ -363,11 +352,8 @@ dependencies = [ name = "db" version = "0.1.0" dependencies = [ - "async-trait", - "chrono", "mysql_async", "serde", - "serde_json", ] [[package]] @@ -482,21 +468,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -[[package]] -name = "futures" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f55667319111d593ba876406af7c409c0ebb44dc4be6132a783ccf163ea14c1" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - [[package]] name = "futures-channel" version = "0.3.13" @@ -504,7 +475,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c2dd2df839b57db9ab69c2c9d8f3e8c81984781937fe2807dc6dcf3b2ad2939" dependencies = [ "futures-core", - "futures-sink", ] [[package]] @@ -513,23 +483,6 @@ version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15496a72fabf0e62bdc3df11a59a3787429221dd0710ba8ef163d6f7a9112c94" -[[package]] -name = "futures-executor" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891a4b7b96d84d5940084b2a37632dd65deeae662c114ceaa2c879629c9c0ad1" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71c2c65c57704c32f5241c1223167c2c3294fd34ac020c807ddbe6db287ba59" - [[package]] name = "futures-macro" version = "0.3.13" @@ -560,13 +513,9 @@ version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1" dependencies = [ - "futures-channel", "futures-core", - "futures-io", "futures-macro", - "futures-sink", "futures-task", - "memchr", "pin-project-lite 0.2.6", "pin-utils", "proc-macro-hack", @@ -751,9 +700,9 @@ checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "js-sys" -version = "0.3.48" +version = "0.3.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc9f84f9b115ce7843d60706df1422a916680bfdfcbdb0447c5614ff9d7e4d78" +checksum = "dc15e39392125075f60c95ba416f5381ff6c3a948ff02ab12464715adf56c821" dependencies = [ "wasm-bindgen", ] @@ -764,11 +713,9 @@ version = "0.2.0" dependencies = [ "base64 0.12.3", "bcrypt", - "chrono", "clap", "db", "dotenv", - "futures", "getrandom 0.1.16", "hyper", "jsonwebtoken", @@ -777,10 +724,8 @@ dependencies = [ "rand 0.7.3", "serde", "serde_json", - "time 0.2.25", "tokio", "tokio-test", - "url", ] [[package]] @@ -838,9 +783,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.88" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b07a082330a35e43f63177cc01689da34fbffa0105e1246cf0311472cac73a" +checksum = "ba4aede83fc3617411dc6993bc8c70919750c1c257c6ca6a502aed6e0e2394ae" [[package]] name = "libz-sys" @@ -1009,13 +954,13 @@ dependencies = [ "num-bigint", "num-traits", "rand 0.7.3", - "regex 1.4.3", + "regex 1.4.5", "rust_decimal", "serde", "serde_json", "sha1", "sha2", - "time 0.2.25", + "time 0.2.26", "twox-hash", "uuid", ] @@ -1115,15 +1060,15 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.32" +version = "0.10.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038d43985d1ddca7a9900630d8cd031b56e4794eecc2e9ea39dd17aa04399a70" +checksum = "a61075b62a23fef5a29815de7536d940aa35ce96d18ce0cc5076272db678a577" dependencies = [ "bitflags", "cfg-if 1.0.0", "foreign-types", - "lazy_static", "libc", + "once_cell", "openssl-sys", ] @@ -1135,9 +1080,9 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" [[package]] name = "openssl-sys" -version = "0.9.60" +version = "0.9.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "921fc71883267538946025deffb622905ecad223c28efbfdef9bb59a0175f3e6" +checksum = "313752393519e876837e09e1fa183ddef0be7735868dced3196f4472d536277f" dependencies = [ "autocfg", "cc", @@ -1154,7 +1099,7 @@ checksum = "fd56cbd21fea48d0c440b41cd69c589faacade08c992d9a54e471b79d0fd13eb" dependencies = [ "base64 0.13.0", "once_cell", - "regex 1.4.3", + "regex 1.4.5", ] [[package]] @@ -1362,20 +1307,19 @@ dependencies = [ "aho-corasick 0.6.10", "memchr", "regex-syntax 0.5.6", - "thread_local 0.3.6", + "thread_local", "utf8-ranges", ] [[package]] name = "regex" -version = "1.4.3" +version = "1.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" +checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" dependencies = [ "aho-corasick 0.7.15", "memchr", - "regex-syntax 0.6.22", - "thread_local 1.1.3", + "regex-syntax 0.6.23", ] [[package]] @@ -1389,9 +1333,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.22" +version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" +checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" [[package]] name = "remove_dir_all" @@ -1467,9 +1411,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "security-framework" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfd318104249865096c8da1dfabf09ddbb6d0330ea176812a62ec75e40c4166" +checksum = "d493c5f39e02dfb062cd8f33301f90f9b13b650e8c1b1d0fd75c19dd64bff69d" dependencies = [ "bitflags", "core-foundation", @@ -1597,9 +1541,9 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] name = "standback" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2beb4d1860a61f571530b3f855a1b538d0200f7871c63331ecd6f17b1f014f8" +checksum = "decebb311175fdaf1bf8a14583716e93163c566db2ead1c1d608c3e1e4313cb8" dependencies = [ "version_check", ] @@ -1667,9 +1611,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "syn" -version = "1.0.61" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed22b90a0e734a23a7610f4283ac9e5acfb96cbb30dfefa540d66f866f1c09c5" +checksum = "3fd9d1e9976102a03c542daa2eff1b43f9d72306342f3f8b3ed5fb8908195d6f" dependencies = [ "proc-macro2", "quote", @@ -1740,15 +1684,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "thread_local" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" -dependencies = [ - "once_cell", -] - [[package]] name = "time" version = "0.1.43" @@ -1761,9 +1696,9 @@ dependencies = [ [[package]] name = "time" -version = "0.2.25" +version = "0.2.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1195b046942c221454c2539395f85413b33383a067449d78aab2b7b052a142f7" +checksum = "08a8cbfbf47955132d0202d1662f49b2423ae35862aee471f3ba4b133358f372" dependencies = [ "const_fn", "libc", @@ -1826,7 +1761,6 @@ dependencies = [ "libc", "memchr", "mio", - "mio-named-pipes", "mio-uds", "num_cpus", "pin-project-lite 0.1.12", @@ -1952,9 +1886,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" [[package]] name = "ucd-util" @@ -2036,9 +1970,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" [[package]] name = "want" @@ -2064,9 +1998,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" -version = "0.2.71" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee1280240b7c461d6a0071313e08f34a60b0365f14260362e5a2b17d1d31aa7" +checksum = "8fe8f61dba8e5d645a4d8132dc7a0a66861ed5e1045d2c0ed940fab33bac0fbe" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -2074,9 +2008,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.71" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b7d8b6942b8bb3a9b0e73fc79b98095a27de6fa247615e59d096754a3bc2aa8" +checksum = "046ceba58ff062da072c7cb4ba5b22a37f00a302483f7e2a6cdc18fedbdc1fd3" dependencies = [ "bumpalo", "lazy_static", @@ -2089,9 +2023,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.71" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ac38da8ef716661f0f36c0d8320b89028efe10c7c0afde65baffb496ce0d3b" +checksum = "0ef9aa01d36cda046f797c57959ff5f3c615c9cc63997a8d545831ec7976819b" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2099,9 +2033,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.71" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc053ec74d454df287b9374ee8abb36ffd5acb95ba87da3ba5b7d3fe20eb401e" +checksum = "96eb45c1b2ee33545a813a92dbb53856418bf7eb54ab34f7f7ff1448a5b3735d" dependencies = [ "proc-macro2", "quote", @@ -2112,15 +2046,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.71" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d6f8ec44822dd71f5f221a5847fb34acd9060535c1211b70a05844c0f6383b1" +checksum = "b7148f4696fb4960a346eaa60bbfb42a1ac4ebba21f750f75fc1375b098d5ffa" [[package]] name = "web-sys" -version = "0.3.48" +version = "0.3.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec600b26223b2948cedfde2a0aa6756dcf1fef616f43d7b3097aaf53a6c4d92b" +checksum = "59fe19d70f5dacc03f6e46777213facae5ac3801575d56ca6cbd4c93dcd12310" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/json-api/Cargo.toml b/json-api/Cargo.toml index 3de2876..c246134 100644 --- a/json-api/Cargo.toml +++ b/json-api/Cargo.toml @@ -6,25 +6,26 @@ edition = "2018" [workspace] [dependencies] -tokio = { version = "0.2", features=["full"] } +# Networking things +tokio = { version = "^0.2", features = ["rt-core", "rt-threaded", "macros", "signal"] } + hyper = "0.13" -futures = "0.3" -url = "2.1.1" mysql_async = "0.23.1" dotenv = "0.9.0" -chrono = "0.4.0" -time = "0.2" +# Crypto things getrandom = "0.1" bcrypt = "0.8" base64 = "0.12.1" rand = "0.7.3" jsonwebtoken = "7.2.0" +# Cli args clap = "2.32.2" +# Serialization serde_json = "1.0" serde = { version = "1.0.114", features = [ "derive" ] } lazy_static = "1.4.0" diff --git a/json-api/Makefile b/json-api/Makefile new file mode 100644 index 0000000..2fbf707 --- /dev/null +++ b/json-api/Makefile @@ -0,0 +1,8 @@ +default: + cargo build --release + +dep: + cargo update + +clean: + cargo clean diff --git a/json-api/db/Cargo.lock b/json-api/db/Cargo.lock deleted file mode 100644 index e4be112..0000000 --- a/json-api/db/Cargo.lock +++ /dev/null @@ -1,1576 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "addr2line" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" - -[[package]] -name = "aho-corasick" -version = "0.7.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" -dependencies = [ - "memchr", -] - -[[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" - -[[package]] -name = "async-trait" -version = "0.1.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b246867b8b3b6ae56035f1eb1ed557c1d8eae97f0d53696138a50fa0e3a3b8c0" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "autocfg" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" - -[[package]] -name = "backtrace" -version = "0.3.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2baad346b2d4e94a24347adeee9c7a93f412ee94b9cc26e5b59dea23848e9f28" -dependencies = [ - "addr2line", - "cfg-if 1.0.0", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - -[[package]] -name = "base-x" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" - -[[package]] -name = "base64" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" - -[[package]] -name = "bigdecimal" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1374191e2dd25f9ae02e3aa95041ed5d747fc77b3c102b49fe2dd9a8117a6244" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", - "serde", -] - -[[package]] -name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" - -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array", -] - -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - -[[package]] -name = "bumpalo" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" - -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - -[[package]] -name = "byteorder" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" - -[[package]] -name = "bytes" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" - -[[package]] -name = "cc" -version = "1.0.62" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1770ced377336a88a67c473594ccc14eca6f4559217c34f64aac8f83d641b40" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "chrono" -version = "0.4.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" -dependencies = [ - "libc", - "num-integer", - "num-traits", - "serde", - "time 0.1.44", - "winapi 0.3.9", -] - -[[package]] -name = "const_fn" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" - -[[package]] -name = "core-foundation" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" - -[[package]] -name = "crc32fast" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "crossbeam" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69323bff1fb41c635347b8ead484a5ca6c3f11914d784170b158d8449ab07f8e" -dependencies = [ - "cfg-if 0.1.10", - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-epoch", - "crossbeam-queue", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-channel" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" -dependencies = [ - "crossbeam-utils", - "maybe-uninit", -] - -[[package]] -name = "crossbeam-deque" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", - "maybe-uninit", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" -dependencies = [ - "autocfg", - "cfg-if 0.1.10", - "crossbeam-utils", - "lazy_static", - "maybe-uninit", - "memoffset", - "scopeguard", -] - -[[package]] -name = "crossbeam-queue" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" -dependencies = [ - "cfg-if 0.1.10", - "crossbeam-utils", - "maybe-uninit", -] - -[[package]] -name = "crossbeam-utils" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -dependencies = [ - "autocfg", - "cfg-if 0.1.10", - "lazy_static", -] - -[[package]] -name = "db" -version = "0.1.0" -dependencies = [ - "async-trait", - "chrono", - "mysql_async", - "serde", - "serde_json", -] - -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array", -] - -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" - -[[package]] -name = "failure" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" -dependencies = [ - "backtrace", - "failure_derive", -] - -[[package]] -name = "failure_derive" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", -] - -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - -[[package]] -name = "flate2" -version = "1.0.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7411863d55df97a419aa64cb4d2f167103ea9d767e2c54a1868b7ac3f6b47129" -dependencies = [ - "cfg-if 1.0.0", - "crc32fast", - "libc", - "libz-sys", - "miniz_oxide", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "form_urlencoded" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ece68d15c92e84fa4f19d3780f1294e5ca82a78a6d515f1efaabcc144688be00" -dependencies = [ - "matches", - "percent-encoding", -] - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags", - "fuchsia-zircon-sys", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" - -[[package]] -name = "futures-core" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "847ce131b72ffb13b6109a221da9ad97a64cbe48feb1028356b836b47b8f1748" - -[[package]] -name = "futures-macro" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77408a692f1f97bcc61dc001d752e00643408fbc922e4d634c655df50d595556" -dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "futures-sink" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f878195a49cee50e006b02b93cf7e0a95a38ac7b776b4c4d9cc1207cd20fcb3d" - -[[package]] -name = "futures-task" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c554eb5bf48b2426c4771ab68c6b14468b6e76cc90996f528c3338d761a4d0d" -dependencies = [ - "once_cell", -] - -[[package]] -name = "futures-util" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d304cff4a7b99cfb7986f7d43fbe93d175e72e704a8860787cc95e9ffd85cbd2" -dependencies = [ - "futures-core", - "futures-macro", - "futures-task", - "pin-project 1.0.1", - "pin-utils", - "proc-macro-hack", - "proc-macro-nested", - "slab", -] - -[[package]] -name = "generic-array" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" -dependencies = [ - "typenum", -] - -[[package]] -name = "getrandom" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "gimli" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" - -[[package]] -name = "idna" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - -[[package]] -name = "itoa" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "lexical" -version = "5.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28ff8a57641758c89a37b2d28556a68978b3ea3f709f39953e153acea3dbacf" -dependencies = [ - "cfg-if 0.1.10", - "lexical-core", -] - -[[package]] -name = "lexical-core" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db65c6da02e61f55dae90a0ae427b2a5f6b3e8db09f58d10efab23af92592616" -dependencies = [ - "arrayvec", - "bitflags", - "cfg-if 0.1.10", - "ryu", - "static_assertions", -] - -[[package]] -name = "libc" -version = "0.2.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" - -[[package]] -name = "libz-sys" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "602113192b08db8f38796c4e85c39e960c145965140e918018bcde1952429655" -dependencies = [ - "cc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "log" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" -dependencies = [ - "cfg-if 0.1.10", -] - -[[package]] -name = "matches" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" - -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - -[[package]] -name = "memchr" -version = "2.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" - -[[package]] -name = "memoffset" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" -dependencies = [ - "autocfg", -] - -[[package]] -name = "miniz_oxide" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" -dependencies = [ - "adler", - "autocfg", -] - -[[package]] -name = "mio" -version = "0.6.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" -dependencies = [ - "cfg-if 0.1.10", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", - "libc", - "log", - "miow 0.2.1", - "net2", - "slab", - "winapi 0.2.8", -] - -[[package]] -name = "mio-named-pipes" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656" -dependencies = [ - "log", - "mio", - "miow 0.3.6", - "winapi 0.3.9", -] - -[[package]] -name = "mio-uds" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" -dependencies = [ - "iovec", - "libc", - "mio", -] - -[[package]] -name = "miow" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", -] - -[[package]] -name = "miow" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897" -dependencies = [ - "socket2", - "winapi 0.3.9", -] - -[[package]] -name = "mysql_async" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2437d3b8ce11d743be7adfbdc5092f6046141b78677b1e3bc9e914d3d1a4c744" -dependencies = [ - "bytes", - "crossbeam", - "futures-core", - "futures-sink", - "futures-util", - "lazy_static", - "mio-named-pipes", - "mysql_common", - "native-tls", - "percent-encoding", - "pin-project 0.4.27", - "serde", - "serde_json", - "thiserror", - "tokio", - "tokio-tls", - "tokio-util", - "twox-hash", - "url", -] - -[[package]] -name = "mysql_common" -version = "0.22.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c529a525c62e4788cff3a4557b652e2efd04eb3171da4ae2792031499f96442f" -dependencies = [ - "base64", - "bigdecimal", - "bitflags", - "byteorder", - "bytes", - "chrono", - "failure", - "flate2", - "lazy_static", - "lexical", - "num-bigint", - "num-traits", - "rand", - "regex", - "rust_decimal", - "serde", - "serde_json", - "sha1", - "sha2", - "time 0.2.23", - "twox-hash", - "uuid", -] - -[[package]] -name = "native-tls" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fcc7939b5edc4e4f86b1b4a04bb1498afaaf871b1a6691838ed06fcb48d3a3f" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - -[[package]] -name = "net2" -version = "0.2.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "num-bigint" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" -dependencies = [ - "autocfg", -] - -[[package]] -name = "object" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" - -[[package]] -name = "once_cell" -version = "1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" - -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - -[[package]] -name = "openssl" -version = "0.10.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d575eff3665419f9b83678ff2815858ad9d11567e082f5ac1814baba4e2bcb4" -dependencies = [ - "bitflags", - "cfg-if 0.1.10", - "foreign-types", - "lazy_static", - "libc", - "openssl-sys", -] - -[[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.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a842db4709b604f0fe5d1170ae3565899be2ad3d9cbc72dedc789ac0511f78de" -dependencies = [ - "autocfg", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "percent-encoding" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" - -[[package]] -name = "pin-project" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffbc8e94b38ea3d2d8ba92aea2983b503cd75d0888d75b86bb37970b5698e15" -dependencies = [ - "pin-project-internal 0.4.27", -] - -[[package]] -name = "pin-project" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee41d838744f60d959d7074e3afb6b35c7456d0f61cad38a24e35e6553f73841" -dependencies = [ - "pin-project-internal 1.0.1", -] - -[[package]] -name = "pin-project-internal" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pin-project-internal" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81a4ffa594b66bff340084d4081df649a7dc049ac8d7fc458d8e628bfbbb2f86" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pin-project-lite" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pkg-config" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" - -[[package]] -name = "ppv-lite86" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" - -[[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - -[[package]] -name = "proc-macro-nested" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" - -[[package]] -name = "proc-macro2" -version = "1.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "quote" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom", - "libc", - "rand_chacha", - "rand_core", - "rand_hc", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core", -] - -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - -[[package]] -name = "regex" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", - "thread_local", -] - -[[package]] -name = "regex-syntax" -version = "0.6.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" - -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "rust_decimal" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e81662973c7a8d9663e64a0de4cd642b89a21d64966e3d99606efdc5fb0cc6" -dependencies = [ - "num-traits", - "serde", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - -[[package]] -name = "ryu" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" - -[[package]] -name = "schannel" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" -dependencies = [ - "lazy_static", - "winapi 0.3.9", -] - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "security-framework" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1759c2e3c8580017a484a7ac56d3abc5a6c1feadf88db2f3633f12ae4268c69" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f99b9d5e26d2a71633cc4f2ebae7cc9f874044e0c351a27e17892d76dce5678b" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] -name = "serde" -version = "1.0.117" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.117" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.59" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha1" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" - -[[package]] -name = "sha2" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" -dependencies = [ - "block-buffer", - "digest", - "fake-simd", - "opaque-debug", -] - -[[package]] -name = "slab" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" - -[[package]] -name = "socket2" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fd8b795c389288baa5f355489c65e71fd48a02104600d15c4cfbc561e9e429d" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "redox_syscall", - "winapi 0.3.9", -] - -[[package]] -name = "standback" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf906c8b8fc3f6ecd1046e01da1d8ddec83e48c8b08b84dcc02b585a6bedf5a8" -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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" -dependencies = [ - "discard", - "rustc_version", - "stdweb-derive", - "stdweb-internal-macros", - "stdweb-internal-runtime", - "wasm-bindgen", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" -dependencies = [ - "proc-macro2", - "quote", - "serde", - "serde_derive", - "syn", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" -dependencies = [ - "base-x", - "proc-macro2", - "quote", - "serde", - "serde_derive", - "serde_json", - "sha1", - "syn", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" - -[[package]] -name = "syn" -version = "1.0.48" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "synstructure" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "unicode-xid", -] - -[[package]] -name = "tempfile" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "rand", - "redox_syscall", - "remove_dir_all", - "winapi 0.3.9", -] - -[[package]] -name = "thiserror" -version = "1.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e9ae34b84616eedaaf1e9dd6026dbe00dcafa92aa0c8077cb69df1fcfe5e53e" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "thread_local" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "time" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi 0.3.9", -] - -[[package]] -name = "time" -version = "0.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcdaeea317915d59b2b4cd3b5efcd156c309108664277793f5351700c02ce98b" -dependencies = [ - "const_fn", - "libc", - "standback", - "stdweb", - "time-macros", - "version_check", - "winapi 0.3.9", -] - -[[package]] -name = "time-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" -dependencies = [ - "proc-macro-hack", - "time-macros-impl", -] - -[[package]] -name = "time-macros-impl" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5c3be1edfad6027c69f5491cf4cb310d1a71ecd6af742788c6ff8bced86b8fa" -dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "standback", - "syn", -] - -[[package]] -name = "tinyvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b78a366903f506d2ad52ca8dc552102ffdd3e937ba8a227f024dc1d1eae28575" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" - -[[package]] -name = "tokio" -version = "0.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6d7ad61edd59bfcc7e80dababf0f4aed2e6d5e0ba1659356ae889752dfc12ff" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "iovec", - "lazy_static", - "libc", - "memchr", - "mio", - "mio-uds", - "pin-project-lite", - "slab", - "tokio-macros", -] - -[[package]] -name = "tokio-macros" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tokio-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343" -dependencies = [ - "native-tls", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "log", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "twox-hash" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04f8ab788026715fa63b31960869617cba39117e520eb415b0139543e325ab59" -dependencies = [ - "cfg-if 0.1.10", - "rand", - "static_assertions", -] - -[[package]] -name = "typenum" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" - -[[package]] -name = "unicode-bidi" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -dependencies = [ - "matches", -] - -[[package]] -name = "unicode-normalization" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1e9a0b71dba18b6fa17c7b3dcf1440bb3522552deb2f84bf47dabd9fb7e5570" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-xid" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" - -[[package]] -name = "url" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5909f2b0817350449ed73e8bcd81c8c3c8d9a7a5d8acba4b27db277f1868976e" -dependencies = [ - "form_urlencoded", - "idna", - "matches", - "percent-encoding", -] - -[[package]] -name = "uuid" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" - -[[package]] -name = "vcpkg" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" - -[[package]] -name = "version_check" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - -[[package]] -name = "wasm-bindgen" -version = "0.2.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ac64ead5ea5f05873d7c12b545865ca2b8d28adfc50a49b84770a3a97265d42" -dependencies = [ - "cfg-if 0.1.10", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f22b422e2a757c35a73774860af8e112bff612ce6cb604224e8e47641a9e4f68" -dependencies = [ - "bumpalo", - "lazy_static", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b13312a745c08c469f0b292dd2fcd6411dba5f7160f593da6ef69b64e407038" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f249f06ef7ee334cc3b8ff031bfc11ec99d00f34d86da7498396dc1e3b1498fe" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307" - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] diff --git a/json-api/db/Cargo.toml b/json-api/db/Cargo.toml index 07308c4..97bbf4b 100644 --- a/json-api/db/Cargo.toml +++ b/json-api/db/Cargo.toml @@ -8,9 +8,6 @@ edition = "2018" [dependencies] mysql_async = "0.23.1" -async-trait = "0.1.40" -serde_json = "1.0" serde = { version = "1.0.117", features = [ "derive" ] } -chrono = "0.4.0" diff --git a/json-api/db/src/common.rs b/json-api/db/src/common.rs index 5c0d891..efdebf1 100644 --- a/json-api/db/src/common.rs +++ b/json-api/db/src/common.rs @@ -1,9 +1,3 @@ -use mysql_async::Pool; -use async_trait::async_trait; - -use crate::Response; -use crate::UBigInt; - #[macro_export] macro_rules! no_conn { ($spec:literal) => { @@ -30,24 +24,3 @@ macro_rules! sql_err_log { } } -/* - * NOTE: pay attention to work on async in traits for rust - * Each of one these funcs will implicitly do a single heap allocation which - * for our case is fine though ideally we don't - * - * As soon as we finda way around that we should depecrate `#[async_trait` - * for the performance - * */ - -#[async_trait] -pub trait FromDB { - type Row; - - async fn get(p: &Pool, id: UBigInt) -> Response; - - async fn update(p: &Pool, row: T) -> Response; - - async fn delete(p: &Pool, id: UBigInt) -> Response; - - async fn filter(p: &Pool, filter_val: FilterType) -> Response; -} diff --git a/json-api/db/src/invites.rs b/json-api/db/src/invites.rs index 1bdb2f6..692f9e5 100644 --- a/json-api/db/src/invites.rs +++ b/json-api/db/src/invites.rs @@ -1,132 +1,50 @@ -use mysql_async::{params, Pool, Conn}; +use std::time::{SystemTime, Duration, UNIX_EPOCH}; + +use mysql_async::{params, Pool}; use mysql_async::prelude::Queryable; use mysql_async::error::Error as SqlError; -use serde::Serialize; -use async_trait::async_trait; +use crate::{BigInt, Invite, Response}; -use crate::{UBigInt, BigInt}; -use crate::common::FromDB; -use crate::{Response, no_conn}; - -#[allow(dead_code)] -#[derive(Serialize, Debug)] -pub struct Invite { - pub id: BigInt, - pub uses: Option, - pub expires: bool -} - -#[async_trait] -impl FromDB for Invite { - type Row = Option<(BigInt, Option, bool)>; - - async fn get(p: &Pool, id: UBigInt) -> Response { +impl Invite { + pub async fn get(p: &Pool, id: BigInt) -> Result, SqlError> { // NOTE: cast is required for this as `id` is used as unix timestamp let id: BigInt = id as BigInt; if id <= 0 { - return Response::Empty; + return Ok(Response::RestrictedInput(format!("<{}> not found", id))) } - if let Ok(conn) = p.get_conn().await { - let q = "SELECT id, uses, expires FROM invites WHERE id = :id "; - let result: Result<(Conn, Self::Row), SqlError> = - conn.first_exec(q, params!{"id" => id}).await; + let conn = p.get_conn().await?; + let q = "SELECT uses, expires FROM invites WHERE id = :id "; + let (_, data_row): (_, Option<(Option, bool)>) = + conn.first_exec(q, params!{"id" => id}).await?; - if let Ok((_, row)) = result { - return match row { - Some(row) => Response::Row(Self { - id: id as BigInt, - uses: row.1, - expires: row.2 - }), - None => Response::Empty - } - } + return if let Some(row) = data_row { + Ok(Response::Row(Invite{ + id, + uses: row.0, + expires: row.1, + })) + } else { + Ok(Response::Empty) } - return Response::Empty; } - async fn update(p: &Pool, row: Self) -> Response { - let q = r#"UPDATE invites - SET uses = :uses, expires: :exp - WHERE id = :id - "#; - // forcibly udpate even if theres nothing there - // this way we avoid doing an extra network hit - if row.id <= 0 { - return Response::Empty; - } - if let Ok(conn) = p.get_conn().await { - let result: Result = - conn.drop_exec(q, params!{ - "id" => row.id, - "uses" => row.uses, - "exp" => row.expires - }).await; - - return match result { - Ok(_) => Response::Success, - Err(_) => Response::Other(format!("Could not update entry {}", row.id)) - } - } - return Response::Empty; - } - async fn delete(p: &Pool, id: UBigInt) -> Response { - if id <= 0 { // really lame "assertion" that each method has to use for invites since they all internally use - return Response::Empty; - } - if let Ok(conn) = p.get_conn().await { - let q = "DELETE FROM invites WHERE id = :id"; - let result: Result = - conn.drop_exec(q, params!{"id" => id as BigInt}).await; - return match result { - Ok(_) => Response::Success, - Err(_) => Response::Other(format!("Could not delete {}", id)) - } - } - return Response::Success; - } - async fn filter(p: &Pool, expirey_flag: bool) -> Response { - if let Ok(conn) = p.get_conn().await { - let q = "SELECT id, uses, expires FROM invites WHERE expires = :exp"; - if let Ok(query) = conn.prep_exec(q, params!{"exp" => expirey_flag}).await { - let mapping_r = query.map_and_drop(|row| { - let (id, uses): (BigInt, Option) = mysql_async::from_row(row); - Invite { - id, - uses, - expires: expirey_flag - } - }).await; - return match mapping_r { - Ok((_, invites)) => Response::Set(invites), - Err(_) => Response::Empty - } - } - else { - return Response::Other(no_conn!("db::Invite::filter")); - } - } - else { - return Response::Other(no_conn!("db::Invites::filter")); - } - } -} - -impl Invite { pub fn new(uses: Option, expires: bool) -> Invite { - use chrono::Utc; - + // now + 30 minutes + let later = SystemTime::now() + Duration::from_secs(60 * 30); + let id: i64 = later.duration_since(UNIX_EPOCH).expect("honestly idk").as_millis() as i64; + Invite { - id: (Utc::now() + chrono::Duration::minutes(30)).timestamp_millis(), + id, uses, expires } } + pub async fn add(&self, p: &Pool) -> Result<(), SqlError> { let conn = p.get_conn().await?; @@ -140,4 +58,5 @@ impl Invite { Ok(()) } + } diff --git a/json-api/db/src/lib.rs b/json-api/db/src/lib.rs index fe67652..cc8c5c0 100644 --- a/json-api/db/src/lib.rs +++ b/json-api/db/src/lib.rs @@ -66,13 +66,19 @@ pub struct Channel { pub kind: Integer } -#[macro_export] -macro_rules! fetch_row { - ($table:literal, $col:literal, $key:expr, $rtype:ty,$conn:expr) => { - let lib_str = format!("SELECT * FROM {} WHERE {} = :{}", $table, $col, $col); - let (_, $rtype) = $conn.first_exec!(lib_str, sql_params{ - $col => $key, - }); - } +#[derive(Serialize, Debug)] +pub struct Invite { + pub id: BigInt, + pub uses: Option, + pub expires: bool +} + +#[derive(Debug, Serialize)] +pub struct Member { + pub id: UBigInt, + pub secret: VarChar, + pub name: VarChar, + pub status: Integer, + pub permissions: UBigInt, } diff --git a/json-api/db/src/member.rs b/json-api/db/src/member.rs index 1e4aab0..a2455d0 100644 --- a/json-api/db/src/member.rs +++ b/json-api/db/src/member.rs @@ -2,24 +2,12 @@ use mysql_async::{params, Pool, Conn}; use mysql_async::prelude::Queryable; use mysql_async::error::Error as SqlError; -use async_trait::async_trait; - -use serde::Serialize; use crate::{Response, no_conn, sql_err}; -use crate::{UBigInt, BigInt, Integer, VarChar}; +use crate::{UBigInt, Integer, VarChar}; +use crate::Member; -use crate::common::FromDB; -#[derive(Debug, Serialize)] -pub struct Member { - pub id: UBigInt, - pub secret: VarChar, - pub name: VarChar, - pub joindate: BigInt, - pub status: Integer, - pub permissions: UBigInt, -} pub const STATUS_ONLINE: Integer = 0; @@ -33,16 +21,14 @@ pub const STATUS_DO_NOT_DISTURB: Integer = 3; * return response based on result * */ -#[async_trait] -impl FromDB for Member { - type Row = Option<(VarChar, VarChar, BigInt, Integer, UBigInt)>; - - async fn get(p: &Pool, id: UBigInt) -> Response { +impl Member { + pub async fn get(p: &Pool, id: UBigInt) -> Response { //! @returns Row on success //! @returns Other on failure if let Ok(conn) = p.get_conn().await { - let q = "SELECT secret, name, joindate, status, permissions FROM members WHERE id = :id"; - let db_res : Result<(Conn, Self::Row), SqlError> + let q = "SELECT secret, name, status, permissions FROM members WHERE id = :id"; + type Row = Option<(VarChar, VarChar, Integer, UBigInt)>; + let db_res : Result<(Conn, Row), SqlError> = conn.first_exec(q, params!{"id" => id}).await; if let Ok((_, row)) = db_res { return match row { @@ -50,9 +36,8 @@ impl FromDB for Member { id, secret: row.0, name: row.1, - joindate: row.2, - status: row.3, - permissions: row.4 + status: row.2, + permissions: row.3 }), None => Response::Empty } @@ -62,52 +47,8 @@ impl FromDB for Member { return Response::Other(no_conn!("Member::FromDB::get")); } - async fn update(p: &Pool, row: Member) -> Response { - let q = r#"UPDATE members - SET status = :status, permissions = :perms, name = :name - WHERE id = :id"#; - if let Ok(conn) = p.get_conn().await { - let query = conn.drop_exec(q, params!{ - "id" => row.id, - "status" => row.status, - "name" => row.name, - "perms" => row.permissions - }).await; - - return match query { - Ok(_) => Response::Success, - Err(err) => Response::Other(sql_err!(err)) - } - } - - return Response::Other(no_conn!("db::Member::update")); - } - - async fn delete(p: &Pool, id: UBigInt) -> Response { - if let Ok(conn) = p.get_conn().await { - let q = "DELETE from members WHERE id = :id"; - let db_result: Result - = conn.drop_exec(q, params!{"id" => id}).await; - match Member::get(p, id).await { - Response::Row(_) => { - if let Ok(conn) = db_result { - return match conn.prep_exec("", params!{"id" => id}).await { - Ok(_) => Response::Success, - Err(_) => Response::Other(sql_err!("Member::FromDB::delete")) - } - } - return Response::Success - }, - Response::Empty => return Response::Empty, - _ => return Response::Other(sql_err!("Member::FromDB::delete | another stupid get happened delid this")) - } - } - - return Response::Empty; - } - - async fn filter(p: &Pool, status: Integer) -> Response { + pub async fn filter(p: &Pool, status: Integer) -> Response { //! @params status return match (p.get_conn().await, status) { (Ok(conn), STATUS_ONLINE) | (Ok(conn), STATUS_OFFLINE) | @@ -127,7 +68,6 @@ impl FromDB for Member { id, secret: "".into(), // no show for obv reasons name, - joindate: 0, // doesn't matter status, permissions } @@ -144,9 +84,6 @@ impl FromDB for Member { _ => Response::Other(sql_err!("err")) } } -} - -impl Member { pub async fn add(p: &Pool, name: &str, secret: &str, perms: u64) -> Result, SqlError> { //! @param {pool} p //! @param {&str} name of new user @@ -156,23 +93,15 @@ impl Member { //! @returns : on_succes => Ok(Response) //! @returns : on_partial_succes => Ok(Response) //! @returns : on_failure => Err(SomeBS) - use chrono::Utc; - let conn = p.get_conn().await?; - //name - //perms - //secret - let now: BigInt = Utc::now().timestamp(); - let conn = conn.drop_exec( - "INSERT INTO members(secret, name, joindate, status, permissions) - VALUES(:secret, :name, :joindate, :status, :permissions)", + "INSERT INTO members(secret, name, status, permissions) + VALUES(:secret, :name, :status, :permissions)", mysql_async::params!{ "secret" => secret.clone(), "name" => name.clone(), - "joindate" => now, "status" => STATUS_ONLINE, "permissions" => perms }).await?; @@ -188,7 +117,6 @@ impl Member { id, secret: secret.into(), name: name.into(), - joindate: now, status: STATUS_ONLINE, permissions: perms })) diff --git a/json-api/db/src/messages.rs b/json-api/db/src/messages.rs index 50177f4..ebb0ed1 100644 --- a/json-api/db/src/messages.rs +++ b/json-api/db/src/messages.rs @@ -1,3 +1,5 @@ +use std::time::{SystemTime, UNIX_EPOCH}; + use mysql_async::{params, Pool}; use mysql_async::prelude::Queryable; use mysql_async::error::Error as SqlError; @@ -5,22 +7,25 @@ use mysql_async::error::Error as SqlError; use crate::{Response, sql_err}; use crate::{UBigInt, BigInt, VarChar}; -use crate::UserMessage; +use crate::{Message, UserMessage}; const MAX_MESSAGES: u64 = 1000; -impl crate::Message { +impl Message { pub async fn send(p: &Pool, content: &str, content_type: &str, cid: UBigInt, uid: UBigInt) -> Result, SqlError> { //! @returns on_sucess -> empty //! @returns on_failure Err(SqlErr) - use chrono::Utc; let conn = p.get_conn().await?; let q = "INSERT INTO messages (time, content, content_type, author_id, channel_id) VALUES (:time, :content, :ctype, :author, :channel)"; - let now = Utc::now().timestamp(); + + let now: i64 = SystemTime::now() + .duration_since(UNIX_EPOCH) + .expect("System time `NOW` failed") + .as_millis() as i64; let res = conn.prep_exec(q, params!{ "time" => now, diff --git a/json-api/src/admin.rs b/json-api/src/admin.rs index 1d3bc1b..0d09c2a 100644 --- a/json-api/src/admin.rs +++ b/json-api/src/admin.rs @@ -9,10 +9,7 @@ use std::collections::HashMap; use crate::perms::ADMIN_PERMS; -use db::{ - self, - member::Member -}; +use db::{self, Member}; use crate::qs_param; diff --git a/json-api/src/auth.rs b/json-api/src/auth.rs index cdf10f4..5d13067 100644 --- a/json-api/src/auth.rs +++ b/json-api/src/auth.rs @@ -1,15 +1,14 @@ use serde::{Serialize, Deserialize}; use bcrypt::{self, BcryptResult}; use mysql_async::Pool; -use chrono::{Utc, Duration}; use std::collections::HashMap; +use std::time::{SystemTime, UNIX_EPOCH}; use crate::routes; use crate::qs_param; -use db::{member::Member, common::FromDB}; -use db::Response; +use db::{Response, Member}; use jsonwebtoken::EncodingKey; lazy_static! { @@ -31,12 +30,14 @@ struct Claim { impl Claim { pub fn new(id: db::UBigInt) -> Claim { + let now = SystemTime::now() + .duration_since(UNIX_EPOCH) + .expect("System time fetch failed") + .as_millis() as i64; + Claim { sub: id, - exp: Utc::now() - .checked_add_signed(Duration::weeks(1)) - .expect("Couldn't generate an expirey date") - .timestamp(), + exp: now, cookie: generate_cookie() } } @@ -114,10 +115,14 @@ async fn valid_jwt(p: &Pool, token: &str) -> AuthReason { let algo = Algorithm::HS512; let dk = DecodingKey::from_secret(&HMAC_SECRET); if let Ok(decoded) = decode::(token, &dk, &Validation::new(algo)) { + let now = SystemTime::now() + .duration_since(UNIX_EPOCH) + .expect("System time fetch failed") + .as_millis() as i64; // subject used for querying speed NOT security let listed = db::auth::listed_jwt(p, decoded.claims.sub, token).await.unwrap(); - let active = Utc::now().timestamp() < decoded.claims.exp; + let active = now < decoded.claims.exp; return match listed && active { true => AuthReason::Good, diff --git a/json-api/src/channels.rs b/json-api/src/channels.rs index 122b44e..769f169 100644 --- a/json-api/src/channels.rs +++ b/json-api/src/channels.rs @@ -6,7 +6,7 @@ use serde_json::json; use std::collections::HashMap; -use db::{ self, common::FromDB, Channel }; +use db::{ self, Channel}; use crate::http::set_json_body; use crate::qs_param; @@ -80,7 +80,7 @@ pub async fn delete_channel(pool: &Pool, response: &mut Response, params: * @channel_id : u64 - required */ use crate::perms; - use db::member::Member; + use db::Member; use db::Response::*; let uid = qs_param!(params, "id", u64).unwrap(); diff --git a/json-api/src/invites.rs b/json-api/src/invites.rs index 8bdf2d5..d73485a 100644 --- a/json-api/src/invites.rs +++ b/json-api/src/invites.rs @@ -1,22 +1,11 @@ -use serde_json::json; - -use mysql_async; -use mysql_async::Pool; - -use hyper::{Response, Body, StatusCode}; - -use chrono::Utc; - +use std::time::{SystemTime, UNIX_EPOCH}; use std::collections::HashMap; -use db::BigInt; -use db::common::FromDB; -use db::member::Member; -use db::invites::Invite; - -use crate::qs_param; -use crate::http; -use crate::meta; +use serde_json::json; +use mysql_async::{self, Pool}; +use hyper::{Response, Body, StatusCode}; +use db::{BigInt, Member, Invite}; +use crate::{http, meta, qs_param}; /* @@ -29,15 +18,23 @@ async fn valid_invite(pool: &Pool, id: BigInt) -> bool { /* * Fetches an invite from the database to check for validity */ - let query: Option = match db::invites::Invite::get(pool, id as u64).await { - db::Response::Row(invite) => { Some(invite) }, - _ => { None } + let query = if let Ok(inv) = Invite::get(pool, id).await { + match inv { + db::Response::Row(data) => Some(data), + _ => None + } + } else { + None }; if let Some(invite) = query { // if expires at all if invite.expires { - let now = Utc::now().timestamp_millis(); + let now: i64 = SystemTime::now() + .duration_since(UNIX_EPOCH) + .expect("Systemtime fetch failed") + .as_millis() as i64; + // old? let mut valid_status = now < invite.id; // used? @@ -70,7 +67,7 @@ async fn use_invite(pool: &Pool, code: Option) -> Option{ if valid_invite(pool, id).await { let raw_secret = auth::generate_secret(); let secret = auth::encrypt_secret(&raw_secret).unwrap(); - return match db::member::Member::add(pool, "Anonymous".into(), &secret, GENERAL_NEW).await { + return match Member::add(pool, "Anonymous".into(), &secret, GENERAL_NEW).await { Ok(response) => { match response { db::Response::Row(member) => Some(member), @@ -123,7 +120,7 @@ pub async fn join(pool: &Pool, response: &mut Response, params: HashMap bool { use crate::perms; - return match db::member::Member::get(pool, uid).await { + return match Member::get(pool, uid).await { db::Response::Row(user) => perms::has_perm(user.permissions, perms::CREATE_PERM_INVITES), _ => false }; diff --git a/json-api/src/main.rs b/json-api/src/main.rs index b303dd2..3bdf0ed 100644 --- a/json-api/src/main.rs +++ b/json-api/src/main.rs @@ -1,5 +1,4 @@ extern crate db; -extern crate chrono; extern crate clap; extern crate dotenv; extern crate getrandom; @@ -20,7 +19,8 @@ use hyper::{ Server, Response, Request, Body, Method, StatusCode, - service::{make_service_fn, service_fn} + service::{make_service_fn, service_fn}, + HeaderMap }; use mysql_async::Pool; @@ -51,11 +51,13 @@ async fn route_dispatcher( meth: &Method, path: &str, body: Body, - params: HashMap) { + params: HashMap, + headers: HeaderMap) { const GET: &Method = &Method::GET; const POST: &Method = &Method::POST; const DELETE: &Method = &Method::DELETE; + println!("{}: {}", meth, path); match (meth, path) { /* INVITES */ (POST, routes::INVITE_CREATE) => invites::create(pool, resp, params).await, @@ -65,7 +67,7 @@ async fn route_dispatcher( (POST, routes::CHANNELS_CREATE) => channels::create_channel(pool, resp, params).await, (DELETE, routes::CHANNELS_DELETE) => channels::delete_channel(pool, resp, params).await, /* MESSAGING */ - (POST, routes::MESSAGE_SEND) => messages::send_message(pool, resp, body, params).await, + (POST, routes::MESSAGE_SEND) => messages::send_message(pool, resp, body, headers, params).await, (GET, routes::MESSAGE_TIME_RANGE) => messages::get_by_time(pool, resp, params).await, (GET, routes::MESSAGE_FROM_ID) =>messages::from_id(pool, resp, params).await, /* ADMIN */ @@ -94,6 +96,7 @@ async fn main_responder(request: Request) -> Result, hyper: let method = parts.method; let path = parts.uri.path(); let qs = parts.uri.query(); + let headers = parts.headers; let params_opt: Option> = if let Some(query_string) = qs { Some(http::parse_query_string(query_string)) } else { @@ -103,7 +106,7 @@ async fn main_responder(request: Request) -> Result, hyper: if let Some(params) = params_opt { let mysql_pool = Pool::new(&env::var("DATABASE_URL").unwrap()); match auth::wall_entry(path, &mysql_pool, ¶ms).await { - OpenAuth | Good => route_dispatcher(&mysql_pool, &mut response, &method, path, body, params).await, + OpenAuth | Good => route_dispatcher(&mysql_pool, &mut response, &method, path, body, params, headers).await, LoginValid => auth::login_get_jwt(&mysql_pool, &mut response, params).await, NoKey | BadKey => *response.status_mut() = StatusCode::UNAUTHORIZED, ServerIssue(msg) => { @@ -155,7 +158,7 @@ async fn attempt_owner_creation(name: &str) { let p = Pool::new(&env::var("DATABASE_URL").unwrap()); let owner_secret = auth::generate_secret(); if let Ok(enc_secret) = auth::encrypt_secret(&owner_secret) { - if let Ok(response) = db::member::Member::add(&p, name, &enc_secret, perms::OWNER).await { + if let Ok(response) = db::Member::add(&p, name, &enc_secret, perms::OWNER).await { match response { db::Response::Row(mut owner) => { owner.secret = owner_secret; // giving the secret itself back to the user diff --git a/json-api/src/members.rs b/json-api/src/members.rs index 5d2b944..b4f120f 100644 --- a/json-api/src/members.rs +++ b/json-api/src/members.rs @@ -4,8 +4,7 @@ use mysql_async::Pool; use serde_json::json; use db::member::STATUS_ONLINE; -use db::common::FromDB; -use db::member::Member; +use db::Member; use db::Response::*; use crate::http::set_json_body; @@ -36,7 +35,6 @@ pub async fn get_self(p: &Pool, response: &mut Response, params: HashMap, params: HashMap set_json_body(response, json!({"member": { "id": member.id, "name": member.name, - "joindate": member.joindate, "status": member.status, "permissions": member.permissions }})); diff --git a/json-api/src/messages.rs b/json-api/src/messages.rs index 3e9a439..03c2b12 100644 --- a/json-api/src/messages.rs +++ b/json-api/src/messages.rs @@ -1,5 +1,5 @@ use mysql_async::Pool; -use hyper::{Response, Body, StatusCode}; +use hyper::{Response, Body, HeaderMap, StatusCode}; use hyper::body::to_bytes; use serde_json::json; @@ -54,19 +54,27 @@ pub async fn get_by_time(pool: &Pool, response: &mut Response, params: Has } } -pub async fn send_message(pool: &Pool, response: &mut Response, body: Body, params: HashMap) { +pub async fn send_message(pool: &Pool, response: &mut Response, body: Body, headers: HeaderMap, params: HashMap) { /* * Message content is sent in the message body * @channel_id: channel id that we're going to send a message to + * @content-type in the headers * TODO: more features here because send_message is a large handler */ use db::Response::*; - use db::member::Member; - use crate::db::common::FromDB; + use db::Member; - // NOTE: auth module guarantees this will be there in the correct form + // NOTE: auth module guarantees that id will be present so the unwrap is safe let uid = qs_param!(params, "id", u64).unwrap(); - let ctype = params.get("type"); + let ctype: Option<&str> = match headers.get("Content-Type") { + Some(hval) => { + match hval.to_str() { + Ok(s) => Some(s), + _ => None + } + }, + None => None + }; let permissions = match Member::get(pool, uid).await { Row(user) => user.permissions, @@ -89,10 +97,11 @@ pub async fn send_message(pool: &Pool, response: &mut Response, body: Body } else { // block away wrong content types const CONTENT_TYPES: [&'static str;7] = ["text", "png", "jpeg", "jpg", "webm", "mp3", "mp4"]; - if CONTENT_TYPES.contains(&ctype.unwrap().as_str()) == false { + if CONTENT_TYPES.contains(&ctype.unwrap()) == false { *response.status_mut() = StatusCode::BAD_REQUEST; } else { + // ctype safe unwrap match db::Message::send(pool, &content, ctype.unwrap(), channel_id.unwrap(), uid).await { Ok(Empty) => {/* TODO: put something here to notify the rtc server if its there*/}, Ok(RestrictedInput(_msg)) => *response.status_mut() = StatusCode::BAD_REQUEST, diff --git a/nginx-conf/freechat.conf b/nginx-conf/freechat.conf deleted file mode 100644 index 941a9e3..0000000 --- a/nginx-conf/freechat.conf +++ /dev/null @@ -1,18 +0,0 @@ -server { - # Freechat servers should not bother adding support for unencrypted trafic - listen 443 ssl; # default_server; - listen [::]:443 ssl; # default_server; - - # Uncomment this line if you are self signing your certs - #include snippets/self-signed.conf; - - # General SSL/TLS settings for nginx - include snippets/ssl-params.conf; - - server_name _; - - location / { - proxy_pass http://0.0.0.0:4536; - } -} - diff --git a/nginx-conf/readme.md b/nginx-conf/readme.md deleted file mode 100644 index d48a38f..0000000 --- a/nginx-conf/readme.md +++ /dev/null @@ -1,42 +0,0 @@ -# Configs for Nginx Reverse Proxy - -The above are ultra minimal configs for setting up nginx. - - -# For self signing - -_I'll be using openssl and summarizing the Digital OCean tutorial._ [Reference](https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-nginx-in-ubuntu-16-04) - -1. First you will have to generate a self-signed key and certificate pair. - -``` -openssl req -x509 -nodes -days 365 -newkey:2048 -keyout /etc/ssl/private/freechat.key -out /etc/ssl/certs/freechat.crt -``` - -2. Next create the Diffie-Hellman group file: - -``` -openssl dhparam -out /detc/ssl/certs/freechat.pem 2048 -``` - -3. Next we should setup the configs for Nginx - -* Place self-signed.conf into `/etc/nginx/snippets`. - -This file tells nginx to use the previously created self signed certificates. - -* Place ssl-params.conf into `/etc/nginx/snippets`. - -This file is pretty general so if you're not self signing you can still use it as just configures TLS and SSL for Nginx. - -4. After that you should be ready to start the server. - - -# Final Notes - -Keep in mind will be able to access json-api endpoints with https://domain.net: and without the port number attached. If you wish to restrict then I suggest restricting clients to _force the port number_ as all clients should be configured to do so anyway. - - -# Suggestions? - -If something here seems wrong or needs fixing/updating/correcting feel free to open an issue. diff --git a/nginx-conf/self-signed.conf b/nginx-conf/self-signed.conf deleted file mode 100644 index e27a200..0000000 --- a/nginx-conf/self-signed.conf +++ /dev/null @@ -1,4 +0,0 @@ -# This should only be used if you are planning on self signing - -ssl_certificate /etc/ssl/certs/freechat.crt; -ssl_certificate_key /etc/ssl/private/freechat.key; diff --git a/nginx-conf/ssl-params.conf b/nginx-conf/ssl-params.conf deleted file mode 100644 index 5e393c2..0000000 --- a/nginx-conf/ssl-params.conf +++ /dev/null @@ -1,20 +0,0 @@ -ssl_protocols TLSv1 TLSV1.1 TLSv1.2; -ssl_prefer_server_ciphers on; -ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"; -ssl_ecdh_curve secp384r1; -ssl_session_cache shared:SSL:10m; -ssl_session_tickets off; -ssl_stapling on; -ssl_stapling_verify on; -resolver 8.8.8.8 8.8.4.4 valid=300s; -resolver_timeout 5s; -# Disable preloading HSTS for now. You can use the commented out header line that includes -# the "preload" directive if you understand the implications. -#add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"; -add_header Strict-Transport-Security "max-age=63072000; includeSubdomains"; -add_header X-Frame-Options DENY; -add_header X-Content-Type-Options nosniff; - -# literal misspelling -ssl_dhparam /etc/ssl/certs/nginx-dev.pem; -