back to stable async-std + use surf instead of reqwest

removes tokio from our dependency tree, now only one async executor
This commit is contained in:
dignifiedquire
2020-05-22 11:10:26 +02:00
parent c43e7cdbdc
commit 70a2dbb4bb
10 changed files with 258 additions and 445 deletions

525
Cargo.lock generated
View File

@@ -114,20 +114,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efd3d156917d94862e779f356c5acae312b08fd3121e792c857d7928c8088423" checksum = "efd3d156917d94862e779f356c5acae312b08fd3121e792c857d7928c8088423"
dependencies = [ dependencies = [
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.22", "syn 1.0.23",
]
[[package]]
name = "async-h1"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "effd501febce09534b924aa471e6a7fd689071fee63659473413f62a1979ae56"
dependencies = [
"async-std",
"byte-pool",
"futures-core",
"http-types",
"httparse",
"lazy_static",
"log",
"pin-project-lite",
"url",
] ]
[[package]] [[package]]
name = "async-imap" name = "async-imap"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/async-email/async-imap#5e338db3b664ebcfb437dddda035fc18a78cc3ea" source = "git+https://github.com/async-email/async-imap?rev=1e8fdd86dbc99b6d92ab4667b426092060fe8b16#1e8fdd86dbc99b6d92ab4667b426092060fe8b16"
dependencies = [ dependencies = [
"async-native-tls", "async-native-tls",
"async-std", "async-std",
"base64 0.11.0", "base64 0.11.0",
"byte-pool", "byte-pool",
"chrono", "chrono",
"futures", "futures 0.3.5",
"imap-proto", "imap-proto",
"lazy_static", "lazy_static",
"log", "log",
@@ -141,9 +158,10 @@ dependencies = [
[[package]] [[package]]
name = "async-native-tls" name = "async-native-tls"
version = "0.3.3" version = "0.3.3"
source = "git+https://github.com/async-email/async-native-tls#bda408c86e84e4fa9382f50820dadcae74924320" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e9e7a929bd34c68a82d58a4de7f86fffdaf97fb2af850162a7bb19dd7269b33"
dependencies = [ dependencies = [
"futures-util", "async-std",
"native-tls", "native-tls",
"thiserror", "thiserror",
"url", "url",
@@ -152,7 +170,8 @@ dependencies = [
[[package]] [[package]]
name = "async-smtp" name = "async-smtp"
version = "0.3.0" version = "0.3.0"
source = "git+https://github.com/async-email/async-smtp#b2ffb61eb2ec4202c67013bfb3c7e22727c15228" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb010dac8f81ceb798b089c522766c0427b54253789194b5c7de9720aeb7f091"
dependencies = [ dependencies = [
"async-native-tls", "async-native-tls",
"async-std", "async-std",
@@ -173,34 +192,40 @@ dependencies = [
[[package]] [[package]]
name = "async-std" name = "async-std"
version = "1.6.0-beta.2" version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3bca717ee7c0abd18e11ba8bc12170e7eee097f96597a021129686bfcfd4978" checksum = "538ecb01eb64eecd772087e5b6f7540cbc917f047727339a472dafed2185b267"
dependencies = [ dependencies = [
"async-attributes", "async-attributes",
"async-task", "async-task",
"broadcaster",
"crossbeam-channel",
"crossbeam-deque",
"crossbeam-utils", "crossbeam-utils",
"futures-channel",
"futures-core", "futures-core",
"futures-io", "futures-io",
"futures-timer", "futures-timer",
"kv-log-macro", "kv-log-macro",
"log", "log",
"memchr", "memchr",
"mio",
"mio-uds",
"num_cpus", "num_cpus",
"once_cell", "once_cell",
"pin-project-lite", "pin-project-lite",
"pin-utils", "pin-utils",
"slab", "slab",
"smol",
"wasm-bindgen-futures",
] ]
[[package]] [[package]]
name = "async-task" name = "async-task"
version = "3.0.0" version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c17772156ef2829aadc587461c7753af20b7e8db1529bc66855add962a3b35d3" checksum = "0ac2c016b079e771204030951c366db398864f5026f84a44dafb0ff20f02085d"
dependencies = [
"libc",
"winapi 0.3.8",
]
[[package]] [[package]]
name = "async-trait" name = "async-trait"
@@ -210,7 +235,7 @@ checksum = "26c4f3195085c36ea8d24d32b2f828d23296a9370a28aa39d111f6f16bef9f3b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.22", "syn 1.0.23",
] ]
[[package]] [[package]]
@@ -353,6 +378,20 @@ dependencies = [
"opaque-debug", "opaque-debug",
] ]
[[package]]
name = "broadcaster"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9c972e21e0d055a36cf73e4daae870941fe7a8abcd5ac3396aab9e4c126bd87"
dependencies = [
"futures-channel",
"futures-core",
"futures-sink",
"futures-util",
"parking_lot",
"slab",
]
[[package]] [[package]]
name = "buf_redux" name = "buf_redux"
version = "0.8.4" version = "0.8.4"
@@ -403,6 +442,16 @@ version = "1.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
[[package]]
name = "bytes"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c"
dependencies = [
"byteorder",
"iovec",
]
[[package]] [[package]]
name = "bytes" name = "bytes"
version = "0.5.4" version = "0.5.4"
@@ -512,6 +561,15 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
[[package]]
name = "cookie"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "888604f00b3db336d2af898ec3c1d5d0ddf5e6d462220f2ededc33a87ac4bbd5"
dependencies = [
"time",
]
[[package]] [[package]]
name = "core-foundation" name = "core-foundation"
version = "0.7.0" version = "0.7.0"
@@ -543,20 +601,6 @@ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "crossbeam"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69323bff1fb41c635347b8ead484a5ca6c3f11914d784170b158d8449ab07f8e"
dependencies = [
"cfg-if",
"crossbeam-channel",
"crossbeam-deque",
"crossbeam-epoch",
"crossbeam-queue",
"crossbeam-utils",
]
[[package]] [[package]]
name = "crossbeam-channel" name = "crossbeam-channel"
version = "0.4.2" version = "0.4.2"
@@ -621,7 +665,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf6b25ee9ac1995c54d7adb2eff8cfffb7260bc774fb63c601ec65467f43cd9d" checksum = "cf6b25ee9ac1995c54d7adb2eff8cfffb7260bc774fb63c601ec65467f43cd9d"
dependencies = [ dependencies = [
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.22", "syn 1.0.23",
] ]
[[package]] [[package]]
@@ -658,7 +702,7 @@ dependencies = [
"proc-macro2", "proc-macro2",
"quote 1.0.6", "quote 1.0.6",
"strsim", "strsim",
"syn 1.0.22", "syn 1.0.23",
] ]
[[package]] [[package]]
@@ -669,7 +713,7 @@ checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72"
dependencies = [ dependencies = [
"darling_core", "darling_core",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.22", "syn 1.0.23",
] ]
[[package]] [[package]]
@@ -715,7 +759,7 @@ dependencies = [
"email", "email",
"encoded-words", "encoded-words",
"escaper", "escaper",
"futures", "futures 0.3.5",
"hex", "hex",
"image", "image",
"image-meta", "image-meta",
@@ -739,7 +783,6 @@ dependencies = [
"r2d2_sqlite", "r2d2_sqlite",
"rand 0.7.3", "rand 0.7.3",
"regex", "regex",
"reqwest",
"rusqlite", "rusqlite",
"rustyline", "rustyline",
"sanitize-filename", "sanitize-filename",
@@ -750,9 +793,11 @@ dependencies = [
"stop-token", "stop-token",
"strum", "strum",
"strum_macros", "strum_macros",
"surf",
"tempfile", "tempfile",
"thiserror", "thiserror",
"thread-local-object", "thread-local-object",
"url",
] ]
[[package]] [[package]]
@@ -760,7 +805,7 @@ name = "deltachat_derive"
version = "2.0.0" version = "2.0.0"
dependencies = [ dependencies = [
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.22", "syn 1.0.23",
] ]
[[package]] [[package]]
@@ -787,7 +832,7 @@ dependencies = [
"derive_builder_core", "derive_builder_core",
"proc-macro2", "proc-macro2",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.22", "syn 1.0.23",
] ]
[[package]] [[package]]
@@ -799,7 +844,7 @@ dependencies = [
"darling", "darling",
"proc-macro2", "proc-macro2",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.22", "syn 1.0.23",
] ]
[[package]] [[package]]
@@ -1021,7 +1066,7 @@ checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.22", "syn 1.0.23",
"synstructure", "synstructure",
] ]
@@ -1107,6 +1152,12 @@ version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
[[package]]
name = "futures"
version = "0.1.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef"
[[package]] [[package]]
name = "futures" name = "futures"
version = "0.3.5" version = "0.3.5"
@@ -1164,7 +1215,7 @@ dependencies = [
"proc-macro-hack", "proc-macro-hack",
"proc-macro2", "proc-macro2",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.22", "syn 1.0.23",
] ]
[[package]] [[package]]
@@ -1184,13 +1235,9 @@ dependencies = [
[[package]] [[package]]
name = "futures-timer" name = "futures-timer"
version = "3.0.2" version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" checksum = "a1de7508b218029b0f01662ed8f61b1c964b3ae99d6f25462d0f55a595109df6"
dependencies = [
"gloo-timers",
"send_wrapper",
]
[[package]] [[package]]
name = "futures-util" name = "futures-util"
@@ -1198,6 +1245,7 @@ version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6" checksum = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6"
dependencies = [ dependencies = [
"futures 0.1.29",
"futures-channel", "futures-channel",
"futures-core", "futures-core",
"futures-io", "futures-io",
@@ -1210,6 +1258,7 @@ dependencies = [
"proc-macro-hack", "proc-macro-hack",
"proc-macro-nested", "proc-macro-nested",
"slab", "slab",
"tokio-io",
] ]
[[package]] [[package]]
@@ -1254,38 +1303,6 @@ version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" checksum = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
[[package]]
name = "gloo-timers"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47204a46aaff920a1ea58b11d03dec6f704287d27561724a4631e450654a891f"
dependencies = [
"futures-channel",
"futures-core",
"js-sys",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "h2"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79b7246d7e4b979c03fa093da39cfb3617a96bbeee6310af63991668d7e843ff"
dependencies = [
"bytes",
"fnv",
"futures-core",
"futures-sink",
"futures-util",
"http",
"indexmap",
"log",
"slab",
"tokio",
"tokio-util",
]
[[package]] [[package]]
name = "heck" name = "heck"
version = "0.3.1" version = "0.3.1"
@@ -1326,19 +1343,43 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9"
dependencies = [ dependencies = [
"bytes", "bytes 0.5.4",
"fnv", "fnv",
"itoa", "itoa",
] ]
[[package]] [[package]]
name = "http-body" name = "http-client"
version = "0.3.1" version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" checksum = "271fae45413daaca82e8c6bf46e452b897873676ce56196d8939645711f542d5"
dependencies = [ dependencies = [
"bytes", "async-h1",
"async-native-tls",
"async-std",
"futures 0.3.5",
"http-types",
"js-sys",
"log",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
]
[[package]]
name = "http-types"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05af75a78dfeb163d472b1d27bebb6a8845917a069accdf53a9bed47aaff9bfc"
dependencies = [
"anyhow",
"async-std",
"cookie",
"http", "http",
"infer",
"omnom",
"pin-project-lite",
"url",
] ]
[[package]] [[package]]
@@ -1371,43 +1412,6 @@ dependencies = [
"quick-error", "quick-error",
] ]
[[package]]
name = "hyper"
version = "0.13.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96816e1d921eca64d208a85aab4f7798455a8e34229ee5a88c935bdee1b78b14"
dependencies = [
"bytes",
"futures-channel",
"futures-core",
"futures-util",
"h2",
"http",
"http-body",
"httparse",
"itoa",
"log",
"net2",
"pin-project",
"time",
"tokio",
"tower-service",
"want",
]
[[package]]
name = "hyper-tls"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3adcd308402b9553630734e9c36b77a7e48b3821251ca2493e8cd596763aafaa"
dependencies = [
"bytes",
"hyper",
"native-tls",
"tokio",
"tokio-tls",
]
[[package]] [[package]]
name = "ident_case" name = "ident_case"
version = "1.0.1" version = "1.0.1"
@@ -1469,6 +1473,15 @@ dependencies = [
"autocfg 1.0.0", "autocfg 1.0.0",
] ]
[[package]]
name = "infer"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d55c406a76164eb346a829ed4b97b73cb06259078eca01adeb12e8ca308d4123"
dependencies = [
"byteorder",
]
[[package]] [[package]]
name = "inflate" name = "inflate"
version = "0.4.5" version = "0.4.5"
@@ -1746,6 +1759,17 @@ dependencies = [
"winapi 0.2.8", "winapi 0.2.8",
] ]
[[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]] [[package]]
name = "miow" name = "miow"
version = "0.2.1" version = "0.2.1"
@@ -1800,19 +1824,6 @@ dependencies = [
"void", "void",
] ]
[[package]]
name = "nix"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50e4785f2c3b7589a0d0c1dd60285e1188adac4006e8abd6dd578e1567027363"
dependencies = [
"bitflags",
"cc",
"cfg-if",
"libc",
"void",
]
[[package]] [[package]]
name = "nodrop" name = "nodrop"
version = "0.1.14" version = "0.1.14"
@@ -1867,7 +1878,7 @@ checksum = "0c8b15b261814f992e33760b1fca9fe8b693d8a65299f20c9901688636cfb746"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.22", "syn 1.0.23",
] ]
[[package]] [[package]]
@@ -1927,6 +1938,15 @@ version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2" checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2"
[[package]]
name = "omnom"
version = "2.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6b216cee2e0d6e680f73158d15468c80b39e571c11669cd90556f9a644e9fd3"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.4.0" version = "1.4.0"
@@ -2104,7 +2124,7 @@ checksum = "e58db2081ba5b4c93bd6be09c40fd36cb9193a8336c384f3b40012e531aa7e40"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.22", "syn 1.0.23",
] ]
[[package]] [[package]]
@@ -2119,16 +2139,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "piper"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6d62a6ea407d82215154475927b288219b79c8670e3371166210328e758ebaa"
dependencies = [
"crossbeam-utils",
"futures",
]
[[package]] [[package]]
name = "pkg-config" name = "pkg-config"
version = "0.3.17" version = "0.3.17"
@@ -2190,9 +2200,9 @@ checksum = "8e946095f9d3ed29ec38de908c22f95d9ac008e424c7bcae54c75a79c527c694"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.13" version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53f5ffe53a6b28e37c9c1ce74893477864d64f74778a93a4beb43c8fa167f639" checksum = "de40dd4ff82d9c9bab6dae29dbab1167e515f8df9ed17d2987cb6012db206933"
dependencies = [ dependencies = [
"unicode-xid 0.2.0", "unicode-xid 0.2.0",
] ]
@@ -2515,43 +2525,7 @@ checksum = "475e68978dc5b743f2f40d8e0a8fdc83f1c5e78cbf4b8fa5e74e73beebc340de"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.22", "syn 1.0.23",
]
[[package]]
name = "reqwest"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02b81e49ddec5109a9dcfc5f2a317ff53377c915e9ae9d4f2fb50914b85614e2"
dependencies = [
"base64 0.11.0",
"bytes",
"encoding_rs",
"futures-core",
"futures-util",
"http",
"http-body",
"hyper",
"hyper-tls",
"js-sys",
"lazy_static",
"log",
"mime",
"mime_guess",
"native-tls",
"percent-encoding",
"pin-project-lite",
"serde",
"serde_json",
"serde_urlencoded",
"time",
"tokio",
"tokio-tls",
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"winreg",
] ]
[[package]] [[package]]
@@ -2647,7 +2621,7 @@ dependencies = [
"libc", "libc",
"log", "log",
"memchr", "memchr",
"nix 0.13.1", "nix",
"unicode-segmentation", "unicode-segmentation",
"unicode-width", "unicode-width",
"utf8parse", "utf8parse",
@@ -2704,12 +2678,6 @@ dependencies = [
"parking_lot", "parking_lot",
] ]
[[package]]
name = "scoped-tls-hkt"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2e9d7eaddb227e8fbaaa71136ae0e1e913ca159b86c7da82f3e8f0044ad3a63"
[[package]] [[package]]
name = "scopeguard" name = "scopeguard"
version = "1.1.0" version = "1.1.0"
@@ -2755,12 +2723,6 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "send_wrapper"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.110" version = "1.0.110"
@@ -2778,7 +2740,7 @@ checksum = "818fbf6bfa9a42d3bfcaca148547aa00c7b915bec71d1757aa2d44ca68771984"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.22", "syn 1.0.23",
] ]
[[package]] [[package]]
@@ -2869,37 +2831,6 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4"
[[package]]
name = "smol"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b1014c048f35c553bfd0155079a62ab9a0e220f9e39f49244c1d58f825ab84a"
dependencies = [
"async-task",
"crossbeam",
"futures-io",
"futures-util",
"nix 0.17.0",
"once_cell",
"piper",
"scoped-tls-hkt",
"slab",
"socket2",
"wepoll-binding",
]
[[package]]
name = "socket2"
version = "0.3.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"winapi 0.3.8",
]
[[package]] [[package]]
name = "spin" name = "spin"
version = "0.5.2" version = "0.5.2"
@@ -2921,7 +2852,8 @@ checksum = "7f3eb36b47e512f8f1c9e3d10c2c1965bc992bd9cdb024fa581e2194501c83d3"
[[package]] [[package]]
name = "stop-token" name = "stop-token"
version = "0.1.2" version = "0.1.2"
source = "git+https://github.com/dignifiedquire/stop-token#05f56fa8e968fc79230a9a00c49d027b9ecee176" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06855fb7c94d3be9b3a57c4d82dfc8a43bb658fbb3b1dda79de89e748d9eb9dd"
dependencies = [ dependencies = [
"async-std", "async-std",
"pin-project-lite", "pin-project-lite",
@@ -2957,7 +2889,7 @@ dependencies = [
"heck", "heck",
"proc-macro2", "proc-macro2",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.22", "syn 1.0.23",
] ]
[[package]] [[package]]
@@ -2966,6 +2898,26 @@ version = "2.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941"
[[package]]
name = "surf"
version = "2.0.0-alpha.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d72c302d4a24b2c9d412f1fe5edd892946778d33c423bba087c6c10deeb656ff"
dependencies = [
"async-std",
"futures 0.3.5",
"http-client",
"http-types",
"log",
"mime",
"mime_guess",
"pin-project-lite",
"serde",
"serde_json",
"serde_urlencoded",
"url",
]
[[package]] [[package]]
name = "syn" name = "syn"
version = "0.11.11" version = "0.11.11"
@@ -2979,9 +2931,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.22" version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1425de3c33b0941002740a420b1a906a350b88d08b82b2c8a01035a3f9447bac" checksum = "95b5f192649e48a5302a13f2feb224df883b98933222369e4b3b0fe2a5447269"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote 1.0.6", "quote 1.0.6",
@@ -3005,7 +2957,7 @@ checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.22", "syn 1.0.23",
"unicode-xid 0.2.0", "unicode-xid 0.2.0",
] ]
@@ -3044,22 +2996,22 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.18" version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5976891d6950b4f68477850b5b9e5aa64d955961466f9e174363f573e54e8ca7" checksum = "b13f926965ad00595dd129fa12823b04bbf866e9085ab0a5f2b05b850fbfc344"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.18" version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab81dbd1cd69cd2ce22ecfbdd3bdb73334ba25350649408cc6c085f46d89573d" checksum = "893582086c2f98cde18f906265a65b5030a074b1046c674ae898be6519a7f479"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.22", "syn 1.0.23",
] ]
[[package]] [[package]]
@@ -3091,45 +3043,14 @@ dependencies = [
] ]
[[package]] [[package]]
name = "tokio" name = "tokio-io"
version = "0.2.21" version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d099fa27b9702bed751524694adbe393e18b36b204da91eb1cbbbbb4a5ee2d58" checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674"
dependencies = [ dependencies = [
"bytes", "bytes 0.4.12",
"fnv", "futures 0.1.29",
"futures-core",
"iovec",
"lazy_static",
"memchr",
"mio",
"num_cpus",
"pin-project-lite",
"slab",
]
[[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.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499"
dependencies = [
"bytes",
"futures-core",
"futures-sink",
"log", "log",
"pin-project-lite",
"tokio",
] ]
[[package]] [[package]]
@@ -3141,24 +3062,12 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "tower-service"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860"
[[package]] [[package]]
name = "traitobject" name = "traitobject"
version = "0.1.0" version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079"
[[package]]
name = "try-lock"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382"
[[package]] [[package]]
name = "try_from" name = "try_from"
version = "0.3.2" version = "0.3.2"
@@ -3315,16 +3224,6 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "want"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0"
dependencies = [
"log",
"try-lock",
]
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.9.0+wasi-snapshot-preview1" version = "0.9.0+wasi-snapshot-preview1"
@@ -3338,8 +3237,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3c7d40d09cdbf0f4895ae58cf57d92e1e57a9dd8ed2e8390514b54a47cc5551" checksum = "e3c7d40d09cdbf0f4895ae58cf57d92e1e57a9dd8ed2e8390514b54a47cc5551"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"serde",
"serde_json",
"wasm-bindgen-macro", "wasm-bindgen-macro",
] ]
@@ -3354,7 +3251,7 @@ dependencies = [
"log", "log",
"proc-macro2", "proc-macro2",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.22", "syn 1.0.23",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@@ -3388,7 +3285,7 @@ checksum = "8eb197bd3a47553334907ffd2f16507b4f4f01bbec3ac921a7719e0decdfe72a"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.22", "syn 1.0.23",
"wasm-bindgen-backend", "wasm-bindgen-backend",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@@ -3409,25 +3306,6 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "wepoll-binding"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7511014d92edaa2cba607fd6dc62974915bebc3e16f91f911a4bb240b4a3a68c"
dependencies = [
"bitflags",
"wepoll-sys",
]
[[package]]
name = "wepoll-sys"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9082a777aed991f6769e2b654aa0cb29f1c3d615daf009829b07b66c7aff6a24"
dependencies = [
"cc",
]
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.2.8" version = "0.2.8"
@@ -3471,15 +3349,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "winreg"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9"
dependencies = [
"winapi 0.3.8",
]
[[package]] [[package]]
name = "winutil" name = "winutil"
version = "0.1.1" version = "0.1.1"
@@ -3527,6 +3396,6 @@ checksum = "de251eec69fc7c1bc3923403d18ececb929380e016afe103da75f396704f8ca2"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.22", "syn 1.0.23",
"synstructure", "synstructure",
] ]

View File

@@ -17,15 +17,15 @@ hex = "0.4.0"
sha2 = "0.8.0" sha2 = "0.8.0"
rand = "0.7.0" rand = "0.7.0"
smallvec = "1.0.0" smallvec = "1.0.0"
reqwest = { version = "0.10.0", features = ["blocking", "json"] } surf = { version = "2.0.0-alpha.2", default-features = false, features = ["h1-client"] }
num-derive = "0.3.0" num-derive = "0.3.0"
num-traits = "0.2.6" num-traits = "0.2.6"
async-smtp = { git = "https://github.com/async-email/async-smtp", version = "0.3" } async-smtp = { version = "0.3" }
email = { git = "https://github.com/deltachat/rust-email", branch = "master" } email = { git = "https://github.com/deltachat/rust-email", branch = "master" }
lettre_email = { git = "https://github.com/deltachat/lettre", branch = "master" } lettre_email = { git = "https://github.com/deltachat/lettre", branch = "master" }
async-imap = { git = "https://github.com/async-email/async-imap" } async-imap = { git = "https://github.com/async-email/async-imap", rev = "1e8fdd86dbc99b6d92ab4667b426092060fe8b16" }
async-native-tls = { git = "https://github.com/async-email/async-native-tls", version = "0.3.1" } async-native-tls = { version = "0.3.1" }
async-std = { version = "1.6.0-beta.2", features = ["unstable"] } async-std = { version = "1.5.0", features = ["unstable"] }
base64 = "0.11" base64 = "0.11"
charset = "0.1" charset = "0.1"
percent-encoding = "2.0" percent-encoding = "2.0"
@@ -50,7 +50,7 @@ escaper = "0.1.0"
bitflags = "1.1.0" bitflags = "1.1.0"
debug_stub_derive = "0.3.0" debug_stub_derive = "0.3.0"
sanitize-filename = "0.2.1" sanitize-filename = "0.2.1"
stop-token = { git = "https://github.com/dignifiedquire/stop-token", version = "0.1.1", features = ["unstable"] } stop-token = { version = "0.1.1", features = ["unstable"] }
mailparse = "0.12.0" mailparse = "0.12.0"
encoded-words = { git = "https://github.com/async-email/encoded-words", branch="master" } encoded-words = { git = "https://github.com/async-email/encoded-words", branch="master" }
native-tls = "0.2.3" native-tls = "0.2.3"
@@ -65,13 +65,14 @@ rustyline = { version = "4.1.0", optional = true }
ansi_term = { version = "0.12.1", optional = true } ansi_term = { version = "0.12.1", optional = true }
async-trait = "0.1.31" async-trait = "0.1.31"
crossbeam-channel = "0.4.2" crossbeam-channel = "0.4.2"
url = "2.1.1"
[dev-dependencies] [dev-dependencies]
tempfile = "3.0" tempfile = "3.0"
pretty_assertions = "0.6.1" pretty_assertions = "0.6.1"
pretty_env_logger = "0.3.0" pretty_env_logger = "0.3.0"
proptest = "0.9.4" proptest = "0.9.4"
async-std = { version = "1.6.0-beta.2", features = ["unstable", "attributes"] } async-std = { version = "1.5.0", features = ["unstable", "attributes"] }
[workspace] [workspace]
members = [ members = [
@@ -93,5 +94,5 @@ required-features = ["repl"]
default = ["nightly"] default = ["nightly"]
internals = [] internals = []
repl = ["internals", "rustyline", "log", "pretty_env_logger", "ansi_term"] repl = ["internals", "rustyline", "log", "pretty_env_logger", "ansi_term"]
vendored = ["async-native-tls/vendored", "reqwest/native-tls-vendored", "async-smtp/native-tls-vendored"] vendored = ["async-native-tls/vendored", "async-smtp/native-tls-vendored"]
nightly = ["pgp/nightly"] nightly = ["pgp/nightly"]

View File

@@ -20,7 +20,7 @@ libc = "0.2"
human-panic = "1.0.1" human-panic = "1.0.1"
num-traits = "0.2.6" num-traits = "0.2.6"
serde_json = "1.0" serde_json = "1.0"
async-std = "1.6.0-beta.2" async-std = "1.5.0"
anyhow = "1.0.28" anyhow = "1.0.28"
thiserror = "1.0.14" thiserror = "1.0.14"

View File

@@ -94,12 +94,12 @@ fn parse_xml(in_emailaddr: &str, xml_raw: &str) -> Result<LoginParam, Error> {
} }
} }
pub fn moz_autoconfigure( pub async fn moz_autoconfigure(
context: &Context, context: &Context,
url: &str, url: &str,
param_in: &LoginParam, param_in: &LoginParam,
) -> Result<LoginParam, Error> { ) -> Result<LoginParam, Error> {
let xml_raw = read_url(context, url)?; let xml_raw = read_url(context, url).await?;
let res = parse_xml(&param_in.addr, &xml_raw); let res = parse_xml(&param_in.addr, &xml_raw);
if let Err(err) = &res { if let Err(err) = &res {

View File

@@ -112,7 +112,7 @@ fn parse_xml(xml_raw: &str) -> Result<ParsingResult, Error> {
Ok(res) Ok(res)
} }
pub fn outlk_autodiscover( pub async fn outlk_autodiscover(
context: &Context, context: &Context,
url: &str, url: &str,
_param_in: &LoginParam, _param_in: &LoginParam,
@@ -120,7 +120,7 @@ pub fn outlk_autodiscover(
let mut url = url.to_string(); let mut url = url.to_string();
/* Follow up to 10 xml-redirects (http-redirects are followed in read_url() */ /* Follow up to 10 xml-redirects (http-redirects are followed in read_url() */
for _i in 0..10 { for _i in 0..10 {
let xml_raw = read_url(context, &url)?; let xml_raw = read_url(context, &url).await?;
let res = parse_xml(&xml_raw); let res = parse_xml(&xml_raw);
if let Err(err) = &res { if let Err(err) = &res {
warn!(context, "{}", err); warn!(context, "{}", err);

View File

@@ -248,7 +248,7 @@ async fn exec_step(
"https://autoconfig.{}/mail/config-v1.1.xml?emailaddress={}", "https://autoconfig.{}/mail/config-v1.1.xml?emailaddress={}",
param_domain, param_addr_urlencoded param_domain, param_addr_urlencoded
); );
*param_autoconfig = moz_autoconfigure(ctx, &url, &param).ok(); *param_autoconfig = moz_autoconfigure(ctx, &url, &param).await.ok();
} }
} }
6 => { 6 => {
@@ -259,7 +259,7 @@ async fn exec_step(
"https://{}/.well-known/autoconfig/mail/config-v1.1.xml?emailaddress={}", "https://{}/.well-known/autoconfig/mail/config-v1.1.xml?emailaddress={}",
param_domain, param_addr_urlencoded param_domain, param_addr_urlencoded
); );
*param_autoconfig = moz_autoconfigure(ctx, &url, &param).ok(); *param_autoconfig = moz_autoconfigure(ctx, &url, &param).await.ok();
} }
} }
/* Outlook section start ------------- */ /* Outlook section start ------------- */
@@ -268,7 +268,7 @@ async fn exec_step(
progress!(ctx, 310); progress!(ctx, 310);
if param_autoconfig.is_none() { if param_autoconfig.is_none() {
let url = format!("https://{}/autodiscover/autodiscover.xml", param_domain); let url = format!("https://{}/autodiscover/autodiscover.xml", param_domain);
*param_autoconfig = outlk_autodiscover(ctx, &url, &param).ok(); *param_autoconfig = outlk_autodiscover(ctx, &url, &param).await.ok();
} }
} }
8 => { 8 => {
@@ -278,7 +278,7 @@ async fn exec_step(
"https://{}{}/autodiscover/autodiscover.xml", "https://{}{}/autodiscover/autodiscover.xml",
"autodiscover.", param_domain "autodiscover.", param_domain
); );
*param_autoconfig = outlk_autodiscover(ctx, &url, &param).ok(); *param_autoconfig = outlk_autodiscover(ctx, &url, &param).await.ok();
} }
} }
/* ----------- Outlook section end */ /* ----------- Outlook section end */
@@ -289,7 +289,7 @@ async fn exec_step(
"http://autoconfig.{}/mail/config-v1.1.xml?emailaddress={}", "http://autoconfig.{}/mail/config-v1.1.xml?emailaddress={}",
param_domain, param_addr_urlencoded param_domain, param_addr_urlencoded
); );
*param_autoconfig = moz_autoconfigure(ctx, &url, &param).ok(); *param_autoconfig = moz_autoconfigure(ctx, &url, &param).await.ok();
} }
} }
10 => { 10 => {
@@ -300,7 +300,7 @@ async fn exec_step(
"http://{}/.well-known/autoconfig/mail/config-v1.1.xml", "http://{}/.well-known/autoconfig/mail/config-v1.1.xml",
param_domain param_domain
); );
*param_autoconfig = moz_autoconfigure(ctx, &url, &param).ok(); *param_autoconfig = moz_autoconfigure(ctx, &url, &param).await.ok();
} }
} }
/* B. If we have no configuration yet, search configuration in Thunderbird's centeral database */ /* B. If we have no configuration yet, search configuration in Thunderbird's centeral database */
@@ -309,7 +309,7 @@ async fn exec_step(
if param_autoconfig.is_none() { if param_autoconfig.is_none() {
/* always SSL for Thunderbird's database */ /* always SSL for Thunderbird's database */
let url = format!("https://autoconfig.thunderbird.net/v1.1/{}", param_domain); let url = format!("https://autoconfig.thunderbird.net/v1.1/{}", param_domain);
*param_autoconfig = moz_autoconfigure(ctx, &url, &param).ok(); *param_autoconfig = moz_autoconfigure(ctx, &url, &param).await.ok();
} }
} }
/* C. Do we have any autoconfig result? /* C. Do we have any autoconfig result?

View File

@@ -3,17 +3,13 @@ use crate::context::Context;
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum Error { pub enum Error {
#[error("URL request error")] #[error("URL request error")]
GetError(#[from] reqwest::Error), GetError(surf::Error),
} }
pub fn read_url(context: &Context, url: &str) -> Result<String, Error> { pub async fn read_url(context: &Context, url: &str) -> Result<String, Error> {
info!(context, "Requesting URL {}", url); info!(context, "Requesting URL {}", url);
match reqwest::blocking::Client::new() match surf::get(url).recv_string().await {
.get(url)
.send()
.and_then(|res| res.text())
{
Ok(res) => Ok(res), Ok(res) => Ok(res),
Err(err) => { Err(err) => {
info!(context, "Can\'t read URL {}", url); info!(context, "Can\'t read URL {}", url);

View File

@@ -161,10 +161,7 @@ pub async fn dc_get_oauth2_access_token(
} }
// ... and POST // ... and POST
let response = reqwest::blocking::Client::new() let response = surf::post(post_url).body_form(&post_param);
.post(post_url)
.form(&post_param)
.send();
if response.is_err() { if response.is_err() {
warn!( warn!(
context, context,
@@ -172,19 +169,8 @@ pub async fn dc_get_oauth2_access_token(
); );
return None; return None;
} }
let response = response.unwrap();
if !response.status().is_success() {
warn!(
context,
"Unsuccessful response when calling OAuth2 at {}: {:?}",
token_url,
response.status()
);
return None;
}
// generate new token: parse returned json let parsed: Result<Response, _> = response.unwrap().recv_json().await;
let parsed: reqwest::Result<Response> = response.json();
if parsed.is_err() { if parsed.is_err() {
warn!( warn!(
context, context,
@@ -192,7 +178,6 @@ pub async fn dc_get_oauth2_access_token(
); );
return None; return None;
} }
println!("response: {:?}", &parsed);
// update refresh_token if given, typically on the first round, but we update it later as well. // update refresh_token if given, typically on the first round, but we update it later as well.
let response = parsed.unwrap(); let response = parsed.unwrap();
@@ -260,12 +245,12 @@ pub async fn dc_get_oauth2_addr(
if let Some(access_token) = if let Some(access_token) =
dc_get_oauth2_access_token(context, addr.as_ref(), code.as_ref(), false).await dc_get_oauth2_access_token(context, addr.as_ref(), code.as_ref(), false).await
{ {
let addr_out = oauth2.get_addr(context, access_token); let addr_out = oauth2.get_addr(context, access_token).await;
if addr_out.is_none() { if addr_out.is_none() {
// regenerate // regenerate
if let Some(access_token) = dc_get_oauth2_access_token(context, addr, code, true).await if let Some(access_token) = dc_get_oauth2_access_token(context, addr, code, true).await
{ {
oauth2.get_addr(context, access_token) oauth2.get_addr(context, access_token).await
} else { } else {
None None
} }
@@ -295,7 +280,7 @@ impl Oauth2 {
} }
} }
fn get_addr(&self, context: &Context, access_token: impl AsRef<str>) -> Option<String> { async fn get_addr(&self, context: &Context, access_token: impl AsRef<str>) -> Option<String> {
let userinfo_url = self.get_userinfo.unwrap_or_else(|| ""); let userinfo_url = self.get_userinfo.unwrap_or_else(|| "");
let userinfo_url = replace_in_uri(&userinfo_url, "$ACCESS_TOKEN", access_token); let userinfo_url = replace_in_uri(&userinfo_url, "$ACCESS_TOKEN", access_token);
@@ -306,41 +291,25 @@ impl Oauth2 {
// "verified_email": true, // "verified_email": true,
// "picture": "https://lh4.googleusercontent.com/-Gj5jh_9R0BY/AAAAAAAAAAI/AAAAAAAAAAA/IAjtjfjtjNA/photo.jpg" // "picture": "https://lh4.googleusercontent.com/-Gj5jh_9R0BY/AAAAAAAAAAI/AAAAAAAAAAA/IAjtjfjtjNA/photo.jpg"
// } // }
let response = reqwest::blocking::Client::new().get(&userinfo_url).send(); let response: Result<HashMap<String, serde_json::Value>, surf::Error> =
surf::get(userinfo_url).recv_json().await;
if response.is_err() { if response.is_err() {
warn!(context, "Error getting userinfo: {:?}", response); warn!(context, "Error getting userinfo: {:?}", response);
return None; return None;
} }
let response = response.unwrap();
if !response.status().is_success() {
warn!(context, "Error getting userinfo: {:?}", response.status());
return None;
}
let parsed: reqwest::Result<HashMap<String, serde_json::Value>> = response.json(); let parsed = response.unwrap();
if parsed.is_err() { // CAVE: serde_json::Value.as_str() removes the quotes of json-strings
warn!( // but serde_json::Value.to_string() does not!
context, if let Some(addr) = parsed.get("email") {
"Failed to parse userinfo JSON response: {:?}", parsed if let Some(s) = addr.as_str() {
); Some(s.to_string())
return None;
}
if let Ok(response) = parsed {
// CAVE: serde_json::Value.as_str() removes the quotes of json-strings
// but serde_json::Value.to_string() does not!
if let Some(addr) = response.get("email") {
if let Some(s) = addr.as_str() {
Some(s.to_string())
} else {
warn!(context, "E-mail in userinfo is not a string: {}", addr);
None
}
} else { } else {
warn!(context, "E-mail missing in userinfo."); warn!(context, "E-mail in userinfo is not a string: {}", addr);
None None
} }
} else { } else {
warn!(context, "Failed to parse userinfo."); warn!(context, "E-mail missing in userinfo.");
None None
} }
} }

View File

@@ -2,7 +2,6 @@
use lazy_static::lazy_static; use lazy_static::lazy_static;
use percent_encoding::percent_decode_str; use percent_encoding::percent_decode_str;
use reqwest::Url;
use serde::Deserialize; use serde::Deserialize;
use crate::chat; use crate::chat;
@@ -193,7 +192,7 @@ fn decode_account(_context: &Context, qr: &str) -> Lot {
let mut lot = Lot::new(); let mut lot = Lot::new();
if let Ok(url) = Url::parse(payload) { if let Ok(url) = url::Url::parse(payload) {
if url.scheme() == "https" { if url.scheme() == "https" {
lot.state = LotState::QrAccount; lot.state = LotState::QrAccount;
lot.text1 = url.host_str().map(|x| x.to_string()); lot.text1 = url.host_str().map(|x| x.to_string());
@@ -221,25 +220,12 @@ struct CreateAccountResponse {
pub async fn set_config_from_qr(context: &Context, qr: &str) -> Result<(), Error> { pub async fn set_config_from_qr(context: &Context, qr: &str) -> Result<(), Error> {
let url_str = &qr[DCACCOUNT_SCHEME.len()..]; let url_str = &qr[DCACCOUNT_SCHEME.len()..];
let response = reqwest::blocking::Client::new().post(url_str).send(); let response: Result<CreateAccountResponse, surf::Error> =
surf::post(url_str).recv_json().await;
if response.is_err() { if response.is_err() {
bail!("Cannot create account, request to {} failed", url_str); bail!("Cannot create account, request to {} failed", url_str);
} }
let response = response.unwrap(); let parsed = response.unwrap();
if !response.status().is_success() {
bail!("Request to {} unsuccessful: {:?}", url_str, response);
}
let parsed: reqwest::Result<CreateAccountResponse> = response.json();
if parsed.is_err() {
bail!(
"Failed to parse JSON response from {}: error: {:?}",
url_str,
parsed
);
}
println!("response: {:?}", &parsed);
let parsed = parsed.unwrap();
context context
.set_config(Config::Addr, Some(&parsed.email)) .set_config(Config::Addr, Some(&parsed.email))

View File

@@ -341,12 +341,10 @@ impl Scheduler {
// wait for all loops to be started // wait for all loops to be started
inbox_start_recv inbox_start_recv
.recv() .recv()
.try_join(mvbox_start_recv.recv()) .join(mvbox_start_recv.recv())
.try_join(sentbox_start_recv.recv()) .join(sentbox_start_recv.recv())
.try_join(smtp_start_recv.recv()) .join(smtp_start_recv.recv())
.await .await;
.map(|_| ())
.unwrap_or_else(|err| error!(ctx, "failed to start scheduler: {}", err));
info!(ctx, "scheduler is running"); info!(ctx, "scheduler is running");
} }
@@ -384,36 +382,28 @@ impl Scheduler {
async fn interrupt_inbox(&self) { async fn interrupt_inbox(&self) {
match self { match self {
Scheduler::Running { ref inbox, .. } => { Scheduler::Running { ref inbox, .. } => inbox.interrupt().await,
inbox.interrupt().await.ok();
}
_ => {} _ => {}
} }
} }
async fn interrupt_mvbox(&self) { async fn interrupt_mvbox(&self) {
match self { match self {
Scheduler::Running { ref mvbox, .. } => { Scheduler::Running { ref mvbox, .. } => mvbox.interrupt().await,
mvbox.interrupt().await.ok();
}
_ => {} _ => {}
} }
} }
async fn interrupt_sentbox(&self) { async fn interrupt_sentbox(&self) {
match self { match self {
Scheduler::Running { ref sentbox, .. } => { Scheduler::Running { ref sentbox, .. } => sentbox.interrupt().await,
sentbox.interrupt().await.ok();
}
_ => {} _ => {}
} }
} }
async fn interrupt_smtp(&self) { async fn interrupt_smtp(&self) {
match self { match self {
Scheduler::Running { ref smtp, .. } => { Scheduler::Running { ref smtp, .. } => smtp.interrupt().await,
smtp.interrupt().await.ok();
}
_ => {} _ => {}
} }
} }
@@ -492,12 +482,14 @@ impl ConnectionState {
// Trigger shutdown of the run loop. // Trigger shutdown of the run loop.
self.stop_sender.send(()).await; self.stop_sender.send(()).await;
// Wait for a notification that the run loop has been shutdown. // Wait for a notification that the run loop has been shutdown.
self.shutdown_receiver.recv().await.ok(); self.shutdown_receiver.recv().await;
} }
async fn interrupt(&self) -> Result<(), async_std::sync::TrySendError<()>> { async fn interrupt(&self) {
// Use try_send to avoid blocking on interrupts. if !self.idle_interrupt_sender.is_full() {
self.idle_interrupt_sender.try_send(()) // Use try_send to avoid blocking on interrupts.
self.idle_interrupt_sender.send(()).await;
}
} }
} }
@@ -531,8 +523,8 @@ impl SmtpConnectionState {
} }
/// Interrupt any form of idle. /// Interrupt any form of idle.
async fn interrupt(&self) -> Result<(), async_std::sync::TrySendError<()>> { async fn interrupt(&self) {
self.state.interrupt().await self.state.interrupt().await;
} }
/// Shutdown this connection completely. /// Shutdown this connection completely.
@@ -579,8 +571,8 @@ impl ImapConnectionState {
} }
/// Interrupt any form of idle. /// Interrupt any form of idle.
async fn interrupt(&self) -> Result<(), async_std::sync::TrySendError<()>> { async fn interrupt(&self) {
self.state.interrupt().await self.state.interrupt().await;
} }
/// Shutdown this connection completely. /// Shutdown this connection completely.