From 69d1c203ec867ab6328a810a4bb89bc087433410 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Wed, 8 Dec 2021 11:49:30 -0600 Subject: [PATCH 1/5] Get https websockets working It turns out websocket upgrades with HTTP/2 require an HTTP extension, which Cloudflare doesn't currently support: https://datatracker.ietf.org/doc/html/rfc8441 To avoid this, enable HTTP/1 for the remote client. This required an update to rustls to allow enabling http1. --- Cargo.lock | 73 +++++++++++++++------------ Cargo.toml | 7 +-- src/commands/dev/edge/server/http.rs | 8 ++- src/commands/dev/edge/server/https.rs | 8 ++- src/commands/dev/gcs/server/http.rs | 7 ++- src/commands/dev/gcs/server/https.rs | 7 ++- src/commands/dev/mod.rs | 13 +++++ src/commands/dev/tls/mod.rs | 19 ++++--- 8 files changed, 82 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b8c339ccb..7adf91af5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -563,15 +563,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "ct-logs" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8" -dependencies = [ - "sct", -] - [[package]] name = "curl" version = "0.4.40" @@ -1178,9 +1169,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.14" +version = "0.14.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b91bb1f221b6ea1f1e4371216b70f40748774c2fb5971b450c07773fb92d26b" +checksum = "436ec0091e4f20e655156a30a0df3770fe2900aa301e548e08446ec794b6953c" dependencies = [ "bytes 1.1.0", "futures-channel", @@ -1202,19 +1193,17 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.22.1" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f7a97316d44c0af9b0301e65010573a853a9fc97046d7331d7f6bc0fd5a64" +checksum = "d87c48c02e0dc5e3b849a2041db3029fd066650f8f717c07bf8ed78ccb895cac" dependencies = [ - "ct-logs", - "futures-util", + "http", "hyper", "log", "rustls", "rustls-native-certs", "tokio", "tokio-rustls", - "webpki", ] [[package]] @@ -2123,9 +2112,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.6" +version = "0.11.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d2927ca2f685faf0fc620ac4834690d29e7abb153add10f5812eef20b5e280" +checksum = "07bea77bc708afa10e59905c3d4af7c8fd43c9214251673095ff8b14345fcbc5" dependencies = [ "base64", "bytes 1.1.0", @@ -2147,6 +2136,7 @@ dependencies = [ "percent-encoding 2.1.0", "pin-project-lite", "rustls", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", @@ -2208,29 +2198,37 @@ checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" [[package]] name = "rustls" -version = "0.19.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" +checksum = "d37e5e2290f3e040b594b1a9e04377c2c671f1a1cfd9bfdef82106ac1c113f84" dependencies = [ - "base64", "log", "ring", "sct", - "webpki", + "webpki 0.22.0", ] [[package]] name = "rustls-native-certs" -version = "0.5.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a07b7c1885bd8ed3831c289b7870b13ef46fe0e856d288c30d9cc17d75a2092" +checksum = "5ca9ebdfa27d3fc180e42879037b5338ab1c040c06affd00d8338598e7800943" dependencies = [ "openssl-probe", - "rustls", + "rustls-pemfile", "schannel", "security-framework", ] +[[package]] +name = "rustls-pemfile" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9" +dependencies = [ + "base64", +] + [[package]] name = "rustversion" version = "1.0.5" @@ -2270,9 +2268,9 @@ dependencies = [ [[package]] name = "sct" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" dependencies = [ "ring", "untrusted", @@ -2846,13 +2844,13 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.22.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" +checksum = "4baa378e417d780beff82bf54ceb0d195193ea6a00c14e22359e7f39456b5689" dependencies = [ "rustls", "tokio", - "webpki", + "webpki 0.22.0", ] [[package]] @@ -2993,7 +2991,7 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f559b464de2e2bdabcac6a210d12e9b5a5973c251e102c44c585c71d51bd78e" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "rand 0.8.4", "static_assertions", ] @@ -3242,13 +3240,23 @@ dependencies = [ "untrusted", ] +[[package]] +name = "webpki" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "webpki-roots" version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" dependencies = [ - "webpki", + "webpki 0.21.4", ] [[package]] @@ -3362,6 +3370,7 @@ dependencies = [ "regex", "reqwest", "rustls", + "rustls-pemfile", "semver", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 8b4fc0a57..0b22c7d32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ futures-util = "0.3" globset = "0.4.6" http = "0.2.1" hyper = { version = "0.14.7", features = ["http2", "server", "runtime"] } -hyper-rustls = "0.22.1" +hyper-rustls = "0.23" ignore = "0.4.17" indicatif = "0.15.0" log = "0.4.11" @@ -49,7 +49,8 @@ prettytable-rs = "0.8.0" rand = "0.8.3" regex = "1.4.1" reqwest = { version = "0.11.3", features = ["blocking", "json", "multipart"] } -rustls = "0.19.1" +rustls = "0.20.2" +rustls-pemfile = "0.2.1" semver = "1.0.3" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0.60" @@ -63,7 +64,7 @@ text_io = "0.1.8" tokio = { version = "1.5.0", default-features = false, features = ["io-std", "time", "macros", "process", "signal", "sync"] } tokio-native-tls = "0.3.0" tokio-retry = "0.3" -tokio-rustls = "0.22.0" +tokio-rustls = "0.23.0" tokio-stream = "0.1.5" tokio-tungstenite = "0.14.0" toml = "0.5.8" diff --git a/src/commands/dev/edge/server/http.rs b/src/commands/dev/edge/server/http.rs index 277f997ba..8b3f7a431 100644 --- a/src/commands/dev/edge/server/http.rs +++ b/src/commands/dev/edge/server/http.rs @@ -1,6 +1,6 @@ use super::preview_request; use crate::commands::dev::utils::{get_path_as_str, rewrite_redirect}; -use crate::commands::dev::{Protocol, ServerConfig}; +use crate::commands::dev::{self, Protocol, ServerConfig}; use crate::terminal::emoji; use std::sync::{Arc, Mutex}; @@ -9,8 +9,7 @@ use anyhow::Result; use chrono::prelude::*; use hyper::service::{make_service_fn, service_fn}; use hyper::upgrade::OnUpgrade; -use hyper::{Body, Client as HyperClient, Server}; -use hyper_rustls::HttpsConnector; +use hyper::Server; use tokio::sync::oneshot::{Receiver, Sender}; pub async fn http( @@ -21,8 +20,7 @@ pub async fn http( shutdown_channel: (Receiver<()>, Sender<()>), ) -> Result<()> { // set up https client to connect to the preview service - let https = HttpsConnector::with_native_roots(); - let client = HyperClient::builder().build::<_, Body>(https); + let client = dev::client(); let listening_address = server_config.listening_address; diff --git a/src/commands/dev/edge/server/https.rs b/src/commands/dev/edge/server/https.rs index 8ca68584a..3302de2c8 100644 --- a/src/commands/dev/edge/server/https.rs +++ b/src/commands/dev/edge/server/https.rs @@ -1,6 +1,6 @@ use super::preview_request; use crate::commands::dev::utils::{get_path_as_str, rewrite_redirect}; -use crate::commands::dev::{tls, Protocol, ServerConfig}; +use crate::commands::dev::{self, tls, Protocol, ServerConfig}; use crate::terminal::emoji; use crate::terminal::message::{Message, StdOut}; use std::sync::{Arc, Mutex}; @@ -11,8 +11,7 @@ use futures_util::{stream::StreamExt, FutureExt}; use hyper::service::{make_service_fn, service_fn}; use hyper::upgrade::OnUpgrade; -use hyper::{Body, Client as HyperClient, Server}; -use hyper_rustls::HttpsConnector; +use hyper::Server; use tokio::net::TcpListener; use tokio::sync::oneshot::{Receiver, Sender}; @@ -25,8 +24,7 @@ pub async fn https( tls::generate_cert()?; // set up https client to connect to the preview service - let https = HttpsConnector::with_native_roots(); - let client = HyperClient::builder().build::<_, Body>(https); + let client = dev::client(); let listening_address = server_config.listening_address; diff --git a/src/commands/dev/gcs/server/http.rs b/src/commands/dev/gcs/server/http.rs index a9cdcfa3b..1449ea5da 100644 --- a/src/commands/dev/gcs/server/http.rs +++ b/src/commands/dev/gcs/server/http.rs @@ -1,4 +1,5 @@ use super::preview_request; +use crate::commands::dev; use crate::commands::dev::gcs::headers::destructure_response; use crate::commands::dev::server_config::ServerConfig; use crate::commands::dev::utils::{get_path_as_str, rewrite_redirect}; @@ -9,15 +10,13 @@ use std::sync::{Arc, Mutex}; use anyhow::Result; use chrono::prelude::*; use hyper::service::{make_service_fn, service_fn}; -use hyper::{Body, Client as HyperClient, Response, Server}; -use hyper_rustls::HttpsConnector; +use hyper::{Response, Server}; /// performs all logic that takes an incoming request /// and routes it to the Workers runtime preview service pub async fn http(server_config: ServerConfig, preview_id: Arc>) -> Result<()> { // set up https client to connect to the preview service - let https = HttpsConnector::with_native_roots(); - let client = HyperClient::builder().build::<_, Body>(https); + let client = dev::client(); let listening_address = server_config.listening_address; diff --git a/src/commands/dev/gcs/server/https.rs b/src/commands/dev/gcs/server/https.rs index 643e04c57..0a34a1420 100644 --- a/src/commands/dev/gcs/server/https.rs +++ b/src/commands/dev/gcs/server/https.rs @@ -1,4 +1,5 @@ use super::preview_request; +use crate::commands::dev; use crate::commands::dev::gcs::headers::destructure_response; use crate::commands::dev::server_config::ServerConfig; use crate::commands::dev::tls; @@ -11,8 +12,7 @@ use anyhow::Result; use chrono::prelude::*; use futures_util::{FutureExt, StreamExt}; use hyper::service::{make_service_fn, service_fn}; -use hyper::{Body, Client as HyperClient, Response, Server}; -use hyper_rustls::HttpsConnector; +use hyper::{Response, Server}; use tokio::net::TcpListener; /// performs all logic that takes an incoming request @@ -21,8 +21,7 @@ pub async fn https(server_config: ServerConfig, preview_id: Arc>) tls::generate_cert()?; // set up https client to connect to the preview service - let https = HttpsConnector::with_native_roots(); - let client = HyperClient::builder().build::<_, Body>(https); + let client = dev::client(); let listening_address = server_config.listening_address; diff --git a/src/commands/dev/mod.rs b/src/commands/dev/mod.rs index e08f339ae..d8f639b25 100644 --- a/src/commands/dev/mod.rs +++ b/src/commands/dev/mod.rs @@ -5,6 +5,9 @@ mod socket; mod tls; mod utils; +use hyper::client::HttpConnector; +use hyper::Body; +use hyper_rustls::HttpsConnector; pub use server_config::Protocol; pub use server_config::ServerConfig; @@ -17,6 +20,16 @@ use crate::terminal::styles; use anyhow::Result; +fn client() -> hyper::Client> { + let builder = hyper_rustls::HttpsConnectorBuilder::new() + .with_native_roots() + .https_or_http(); + // Cloudflare doesn't currently support websockets with HTTP/2. + // Allow using HTTP/1.1 for websocket connections. + let https = builder.enable_http1().build(); + hyper::Client::builder().build::<_, Body>(https) +} + /// `wrangler dev` starts a server on a dev machine that routes incoming HTTP requests /// to a Cloudflare Workers runtime and returns HTTP responses #[allow(clippy::too_many_arguments)] diff --git a/src/commands/dev/tls/mod.rs b/src/commands/dev/tls/mod.rs index 829f19067..24c9f15d9 100644 --- a/src/commands/dev/tls/mod.rs +++ b/src/commands/dev/tls/mod.rs @@ -5,8 +5,7 @@ use anyhow::Result; use core::task::{Context, Poll}; use fs::File; use futures_util::stream::Stream; -use rustls::internal::pemfile; -use rustls::{NoClientAuth, ServerConfig}; +use rustls::{server::NoClientAuth, ServerConfig}; use std::path::PathBuf; use std::pin::Pin; use std::sync::Arc; @@ -30,10 +29,13 @@ pub(super) fn get_tls_acceptor() -> Result { let key = load_private_key(privkey)?; // Do not use client certificate authentication. - let mut cfg = ServerConfig::new(NoClientAuth::new()); + let cfg = ServerConfig::builder() + .with_safe_defaults() + .with_client_cert_verifier(NoClientAuth::new()); // Select a certificate to use. - cfg.set_single_cert(certs, key) + let cfg = cfg + .with_single_cert(certs, key) .map_err(|e| io_error(format!("{}", e)))?; Ok(TlsAcceptor::from(Arc::new(cfg))) @@ -71,7 +73,10 @@ fn load_certs(file: PathBuf) -> io::Result> { let mut reader = io::BufReader::new(certfile); // Load and return certificate. - pemfile::certs(&mut reader).map_err(|_| io_error("failed to load certificate".into())) + match rustls_pemfile::certs(&mut reader) { + Ok(certs) => Ok(certs.into_iter().map(rustls::Certificate).collect()), + Err(_) => Err(io_error("failed to load certificate".into())), + } } // Load private key from file. @@ -81,10 +86,10 @@ fn load_private_key(file: PathBuf) -> io::Result { let mut reader = io::BufReader::new(keyfile); // Load and return a single private key. - let keys = pemfile::pkcs8_private_keys(&mut reader) + let mut keys = rustls_pemfile::pkcs8_private_keys(&mut reader) .map_err(|_| io_error("failed to load private key".into()))?; if keys.len() != 1 { return Err(io_error("expected a single private key".into())); } - Ok(keys[0].clone()) + Ok(rustls::PrivateKey(keys.pop().unwrap())) } From a3bc640f13c8a4d10f3211b577037f7c32aff7ae Mon Sep 17 00:00:00 2001 From: Sunil Pai Date: Thu, 16 Dec 2021 14:51:07 +0000 Subject: [PATCH 2/5] 1.19.6 (#2159) --- CHANGELOG.md | 81 ++++++++++++++++++ Cargo.lock | 180 +++++++++++++++++++++------------------- Cargo.toml | 2 +- npm/npm-shrinkwrap.json | 7 +- npm/package.json | 2 +- package-lock.json | 6 ++ 6 files changed, 186 insertions(+), 92 deletions(-) create mode 100644 package-lock.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 41c0298bd..236696662 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,86 @@ # Changelog +## v1.19.6 + +- ### Features + + - **Add `wrangler1` as an alias - [TehShrike], [pull/2139]** + + So that when @cloudflare/wrangler is installed along wrangler2, they can each be referenced in npm run scripts. + + See https://github.com/cloudflare/wrangler2/pull/40 + + [tehshrike]: https://github.com/TehShrike + [pull/2139]: https://github.com/cloudflare/wrangler/pull/2139 + +- ### Fixes + + - **Don't look for background updates unless Wrangler finished successfully - [jyn514], [pull/2150]** + + This works around a segfault due to OpenSSL's exit handlers not being thread-safe. + + See https://github.com/cloudflare/wrangler/issues/1464#issuecomment-988245785 for an explanation and alternatives. + + [jyn514]: https://github.com/jyn514 + [pull/2150]: https://github.com/cloudflare/wrangler/pull/2150 + + - **fix: incomplete binary with npm installation - [12f23eddde], [pull/2149]** + + Closes #2148. + This PR modifies binary-install.js ([reference](https://stackoverflow.com/questions/55374755/node-js-axios-download-file-stream-and-writefile)) to make sure the file stream is complete before the program finishes. + I'm not a + ... truncated + + [12f23eddde]: https://github.com/12f23eddde + [pull/2149]: https://github.com/cloudflare/wrangler/pull/2149 + + - **Get https websockets working - [jyn514], [pull/2153]** + + It turns out websocket upgrades with HTTP/2 require an HTTP extension, + which Cloudflare doesn't currently support: https://datatracker.ietf.org/doc/html/rfc8441 + + To avoid this, enable HTTP/1 for the remote client. + + This required an upd + ... truncated + + [jyn514]: https://github.com/jyn514 + [pull/2153]: https://github.com/cloudflare/wrangler/pull/2153 + + - **Get the audit CI job passing - [jyn514], [pull/2151]** + + Note that I didn't say "fix the vulnerabilities" - this just ignores the `chrono` and `time` vulnerabilities because they're both very hard to fix and not very common in practice. + + This uncovered a tokio vulnerability, which I've fixed by + ... truncated + + [jyn514]: https://github.com/jyn514 + [pull/2151]: https://github.com/cloudflare/wrangler/pull/2151 + + - **Proxy websocket connections when using authenticated (realish) preview - [jyn514], [pull/2135]** + + Previously, Wrangler would return a "101 Switching Protocols" response + and then immediately close the TCP connection. This changes it to instead + continue proxying the connection to the remote worker. + + This is simpler than `wrangler dev + ... truncated + + [jyn514]: https://github.com/jyn514 + [pull/2135]: https://github.com/cloudflare/wrangler/pull/2135 + +- ### Maintenance + + - **Update Rust toolchain to 1.57 - [taylorlee], [pull/2145]** + + I originally updated my toolchain to 1.56.1 on a local branch, since afaict rust-analyzer wasn't able to work with derived StructOpt proc-macros in 1.54. Since 1.57 was released today, I figured I'd update it all the way in this pr. + + foll + ... truncated + + [taylorlee]: https://github.com/taylorlee + [pull/2145]: https://github.com/cloudflare/wrangler/pull/2145 + ## v1.19.5 - ## Features diff --git a/Cargo.lock b/Cargo.lock index 7adf91af5..2f2bc65a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,15 +32,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -dependencies = [ - "winapi 0.3.9", -] - [[package]] name = "ansi_term" version = "0.12.1" @@ -52,18 +43,18 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.45" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee10e43ae4a853c0a3591d4e2ada1719e553be18199d9da9d4a83f5927c2f5c7" +checksum = "8b26702f315f53b6071259e15dd9d64528213b44d61de1ec926eca7715d62203" dependencies = [ "backtrace", ] [[package]] name = "arc-swap" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6df5aef5c5830360ce5218cecb8f018af3438af5686ae945094affc86fdec63" +checksum = "c5d78ce20460b82d3fa150275ed9d55e21064fc7951177baacf86a145c4a4b1f" [[package]] name = "arrayref" @@ -93,9 +84,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.51" +version = "0.1.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e" +checksum = "061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3" dependencies = [ "proc-macro2", "quote", @@ -285,9 +276,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.71" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd" +checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" [[package]] name = "cfg-if" @@ -324,17 +315,17 @@ dependencies = [ "num-integer", "num-traits", "serde", - "time", + "time 0.1.44", "winapi 0.3.9", ] [[package]] name = "clap" -version = "2.33.3" +version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ - "ansi_term 0.11.0", + "ansi_term", "atty", "bitflags", "strsim 0.8.0", @@ -386,7 +377,7 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd32eb54d016e203b7c2600e3a7802c75843a92e38ccc4869aefeca21771a64" dependencies = [ - "ansi_term 0.12.1", + "ansi_term", "atty", "libc", "serde", @@ -514,9 +505,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" dependencies = [ "cfg-if 1.0.0", ] @@ -549,7 +540,7 @@ checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" dependencies = [ "bstr", "csv-core", - "itoa", + "itoa 0.4.8", "ryu", "serde", ] @@ -565,9 +556,9 @@ dependencies = [ [[package]] name = "curl" -version = "0.4.40" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877cc2f9b8367e32b6dabb9d581557e651cb3aa693a37f8679091bbf42687d5d" +checksum = "1bc6d233563261f8db6ffb83bbaad5a73837a6e6b28868e926337ebbdece0be3" dependencies = [ "curl-sys", "libc", @@ -580,9 +571,9 @@ dependencies = [ [[package]] name = "curl-sys" -version = "0.4.50+curl-7.79.1" +version = "0.4.51+curl-7.80.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4856b76919dd599f31236bb18db5f5bd36e2ce131e64f857ca5c259665b76171" +checksum = "d130987e6a6a34fe0889e1083022fa48cd90e6709a84be3fb8dd95801de5af20" dependencies = [ "cc", "libc", @@ -595,9 +586,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "757c0ded2af11d8e739c4daea1ac623dd1624b06c844cf3f5a39f1bdbd99bb12" +checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4" dependencies = [ "darling_core", "darling_macro", @@ -605,9 +596,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c34d8efb62d0c2d7f60ece80f75e5c63c1588ba68032740494b0b9a996466e3" +checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324" dependencies = [ "fnv", "ident_case", @@ -619,9 +610,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc" +checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" dependencies = [ "darling_core", "quote", @@ -740,9 +731,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.29" +version = "0.8.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a74ea89a0a1b98f6332de42c95baff457ada66d1cb4030f9ff151b2041a1c746" +checksum = "7896dc8abb250ffdda33912550faa54c88ec8b998dec0b2c55ab224921ce11df" dependencies = [ "cfg-if 1.0.0", ] @@ -1080,9 +1071,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.7" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fd819562fcebdac5afc5c113c3ec36f902840b70fd4fc458799c8ce4607ae55" +checksum = "8f072413d126e57991455e0a922b31e4c8ba7c2ffbebf6b78b4f8521397d65cd" dependencies = [ "bytes 1.1.0", "fnv", @@ -1135,7 +1126,7 @@ checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b" dependencies = [ "bytes 1.1.0", "fnv", - "itoa", + "itoa 0.4.8", ] [[package]] @@ -1157,9 +1148,9 @@ checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" [[package]] name = "httpdate" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "humantime" @@ -1169,9 +1160,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.15" +version = "0.14.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436ec0091e4f20e655156a30a0df3770fe2900aa301e548e08446ec794b6953c" +checksum = "b7ec3e62bdc98a2f0393a5048e4c30ef659440ea6e0e572965103e72bd836f55" dependencies = [ "bytes 1.1.0", "futures-channel", @@ -1182,7 +1173,7 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa", + "itoa 0.4.8", "pin-project-lite", "socket2", "tokio", @@ -1331,9 +1322,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.10.1" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" dependencies = [ "either", ] @@ -1344,6 +1335,12 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" +[[package]] +name = "itoa" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" + [[package]] name = "js-sys" version = "0.3.55" @@ -1390,9 +1387,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.107" +version = "0.2.112" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbe5e23404da5b4f555ef85ebed98fb4083e55a00c317800bc2a50ede9f3d219" +checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" [[package]] name = "libflate" @@ -1698,9 +1695,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" [[package]] name = "opaque-debug" @@ -1736,18 +1733,18 @@ checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" [[package]] name = "openssl-src" -version = "300.0.2+3.0.0" +version = "111.17.0+1.1.1m" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14a760a11390b1a5daf72074d4f6ff1a6e772534ae191f999f57e9ee8146d1fb" +checksum = "05d6a336abd10814198f66e2a91ccd7336611f30334119ca8ce300536666fcf4" dependencies = [ "cc", ] [[package]] name = "openssl-sys" -version = "0.9.70" +version = "0.9.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6517987b3f8226b5da3661dad65ff7f300cc59fb5ea8333ca191fc65fde3edf" +checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb" dependencies = [ "autocfg", "cc", @@ -1839,21 +1836,21 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.22" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12295df4f294471248581bc09bef3c38a5e46f1e36d6a37353621a0c6c357e1f" +checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" [[package]] name = "plist" -version = "1.2.1" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a38d026d73eeaf2ade76309d0c65db5a35ecf649e3cec428db316243ea9d6711" +checksum = "bd39bc6cdc9355ad1dc5eeedefee696bb35c34caf21768741e81826c0bbd7225" dependencies = [ "base64", - "chrono", "indexmap", "line-wrap", "serde", + "time 0.3.5", "xml-rs", ] @@ -1865,9 +1862,9 @@ checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" [[package]] name = "predicates" -version = "2.0.3" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6ce811d0b2e103743eec01db1c50612221f173084ce2f7941053e94b6bb474" +checksum = "95e5a7689e456ab905c22c2b48225bb921aba7c8dfa58440d68ba13f6222a715" dependencies = [ "difflib", "float-cmp", @@ -1945,9 +1942,9 @@ checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] name = "proc-macro2" -version = "1.0.32" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" +checksum = "2f84e92c0f7c9d58328b85a78557813e4bd845130db68d7184635344399423b1" dependencies = [ "unicode-xid", ] @@ -2231,15 +2228,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088" +checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" [[package]] name = "ryu" -version = "1.0.5" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" [[package]] name = "safemem" @@ -2307,18 +2304,18 @@ checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" [[package]] name = "serde" -version = "1.0.130" +version = "1.0.131" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" +checksum = "b4ad69dfbd3e45369132cc64e6748c2d65cdfb001a2b1c232d128b4ad60561c1" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.130" +version = "1.0.131" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" +checksum = "b710a83c4e0dff6a3d511946b95274ad9ca9e5d3ae497b63fda866ac955358d2" dependencies = [ "proc-macro2", "quote", @@ -2327,11 +2324,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.69" +version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e466864e431129c7e0d3476b92f20458e5879919a0596c6472738d9fa2d342f8" +checksum = "bcbd0344bc6533bc7ec56df11d42fb70f1b912351c0825ccb7211b59d8af7cf5" dependencies = [ - "itoa", + "itoa 1.0.1", "ryu", "serde", ] @@ -2364,7 +2361,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" dependencies = [ "form_urlencoded", - "itoa", + "itoa 0.4.8", "ryu", "serde", ] @@ -2593,9 +2590,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966" +checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59" dependencies = [ "proc-macro2", "quote", @@ -2632,9 +2629,9 @@ checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" [[package]] name = "tar" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6f5515d3add52e0bbdcad7b83c388bb36ba7b754dda3b5f5bc2d38640cdba5c" +checksum = "4b55807c0344e1e6c04d7c965f5289c39a8d94ae23ed5c0b57aabac549f871c6" dependencies = [ "filetime", "libc", @@ -2776,6 +2773,16 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "time" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41effe7cfa8af36f439fac33861b66b049edc6f9a32331e2312660529c1c24ad" +dependencies = [ + "itoa 0.4.8", + "libc", +] + [[package]] name = "tinyvec" version = "1.5.1" @@ -2793,11 +2800,10 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e992e41e0d2fb9f755b37446f20900f64446ef54874f40a60c78f021ac6144" +checksum = "fbbf1c778ec206785635ce8ad57fe52b3009ae9e0c9f574a728f3049d3e55838" dependencies = [ - "autocfg", "bytes 1.1.0", "libc", "memchr", @@ -2812,9 +2818,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9efc1aba077437943f7515666aa2b882dfabfbfdf89c819ea75a8d6e9eaba5e" +checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" dependencies = [ "proc-macro2", "quote", @@ -3324,7 +3330,7 @@ dependencies = [ [[package]] name = "wrangler" -version = "1.19.5" +version = "1.19.6" dependencies = [ "anyhow", "assert_cmd", @@ -3439,5 +3445,5 @@ dependencies = [ "crc32fast", "flate2", "thiserror", - "time", + "time 0.1.44", ] diff --git a/Cargo.toml b/Cargo.toml index 0b22c7d32..7dcd47432 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wrangler" -version = "1.19.5" +version = "1.19.6" authors = ["The Wrangler Team "] edition = "2018" license = "MIT/Apache-2.0" diff --git a/npm/npm-shrinkwrap.json b/npm/npm-shrinkwrap.json index 9f30bccca..2378764ef 100644 --- a/npm/npm-shrinkwrap.json +++ b/npm/npm-shrinkwrap.json @@ -1,12 +1,12 @@ { "name": "@cloudflare/wrangler", - "version": "1.19.5", + "version": "1.19.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@cloudflare/wrangler", - "version": "1.19.5", + "version": "1.19.6", "hasInstallScript": true, "license": "MIT OR Apache-2.0", "dependencies": { @@ -15,7 +15,8 @@ "tar": "^6.1.10" }, "bin": { - "wrangler": "run-wrangler.js" + "wrangler": "run-wrangler.js", + "wrangler1": "run-wrangler.js" } }, "node_modules/axios": { diff --git a/npm/package.json b/npm/package.json index 06b6c94a9..a5843c967 100644 --- a/npm/package.json +++ b/npm/package.json @@ -1,6 +1,6 @@ { "name": "@cloudflare/wrangler", - "version": "1.19.5", + "version": "1.19.6", "description": "Command-line interface for all things Cloudflare Workers", "main": "binary.js", "scripts": { diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..84b18d095 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "wrangler", + "lockfileVersion": 2, + "requires": true, + "packages": {} +} From 8a7ae475945e126e156f92c2a43f751cdbea49a7 Mon Sep 17 00:00:00 2001 From: Saikat Das Date: Sat, 18 Dec 2021 05:43:05 -0800 Subject: [PATCH 3/5] fix cli help typo (#2160) --- src/cli/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/mod.rs b/src/cli/mod.rs index d2e1efc8c..b19aa2446 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -294,7 +294,7 @@ pub enum Command { }, /// Logout from your current authentication method and remove any configuration files. - /// It does not logout if you have authenticated wrangler through envrionment variables. + /// It does not logout if you have authenticated wrangler through environment variables. #[structopt(name = "logout")] Logout, From d504457b0d4d746bfa5a03b3a332f26252a8ee31 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Wed, 22 Dec 2021 11:46:01 -0600 Subject: [PATCH 4/5] Revert "Don't look for background updates unless Wrangler finished successfully" This reverts commit 45f5ab26383787ec1ac8f17fc78c1b8f4028d7da to avoid #2161. It's unclear to me why that would have introduced a regression, but this whole issue is actual Undefined Behavior according to the C standard, so it's basically impossible to predict the behavior of the program from the source code. I unfortunately wasn't able to reproduce the regression locally so I'm not sure whether this helps or not. --- src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index ec2bf0ca6..bf6c97442 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,6 +22,7 @@ fn main() -> Result<()> { } env_logger::init(); + let latest_version_receiver = background_check_for_updates(); if let Ok(me) = env::current_exe() { // If we're actually running as the installer then execute our // self-installation, otherwise just continue as usual. @@ -35,7 +36,7 @@ fn main() -> Result<()> { } } run()?; - if let Ok(latest_version) = background_check_for_updates().try_recv() { + if let Ok(latest_version) = latest_version_receiver.try_recv() { let latest_version = styles::highlight(latest_version.to_string()); let new_version_available = format!( "A new version of Wrangler ({}) is available!", From 4c92c94756f54a01f4e719297d0ce18def6183ab Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Wed, 22 Dec 2021 12:26:16 -0600 Subject: [PATCH 5/5] Check for updates in the foreground, not the background This avoids creating a new OpenSSL context while the main thread exits the process. --- src/main.rs | 22 ++-------------------- src/version/mod.rs | 29 +++++++++++++++++++---------- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/src/main.rs b/src/main.rs index bf6c97442..6ed50df16 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,9 +9,7 @@ use wrangler::cli::{exec, Cli, Command}; use wrangler::commands; use wrangler::installer; use wrangler::reporter; -use wrangler::terminal::message::{Message, StdOut}; -use wrangler::terminal::styles; -use wrangler::version::background_check_for_updates; +use wrangler::version::check_for_updates; use anyhow::Result; use structopt::StructOpt; @@ -22,7 +20,6 @@ fn main() -> Result<()> { } env_logger::init(); - let latest_version_receiver = background_check_for_updates(); if let Ok(me) = env::current_exe() { // If we're actually running as the installer then execute our // self-installation, otherwise just continue as usual. @@ -36,22 +33,7 @@ fn main() -> Result<()> { } } run()?; - if let Ok(latest_version) = latest_version_receiver.try_recv() { - let latest_version = styles::highlight(latest_version.to_string()); - let new_version_available = format!( - "A new version of Wrangler ({}) is available!", - latest_version - ); - let update_message = "You can learn more about updating here:".to_string(); - let update_docs_url = styles::url( - "https://developers.cloudflare.com/workers/cli-wrangler/install-update#update", - ); - - StdOut::billboard(&format!( - "{}\n{}\n{}", - new_version_available, update_message, update_docs_url - )); - } + check_for_updates(); Ok(()) } diff --git a/src/version/mod.rs b/src/version/mod.rs index f7cc28d90..f5922c7cd 100644 --- a/src/version/mod.rs +++ b/src/version/mod.rs @@ -1,11 +1,11 @@ use std::fs; use std::path::Path; use std::str::FromStr; -use std::sync::mpsc; -use std::thread; use std::time::SystemTime; use crate::settings::get_wrangler_home_dir; +use crate::terminal::message::{Message, StdOut}; +use crate::terminal::styles; use anyhow::Result; use reqwest::header::USER_AGENT; @@ -14,21 +14,30 @@ use serde::{Deserialize, Serialize}; const ONE_DAY: u64 = 60 * 60 * 24; -pub fn background_check_for_updates() -> mpsc::Receiver { - let (sender, receiver) = mpsc::channel(); - - let _detached_thread = thread::spawn(move || match check_wrangler_versions() { +pub fn check_for_updates() { + match check_wrangler_versions() { Ok(wrangler_versions) => { // If the wrangler version has not been checked within the last day and the versions // are different, print out an update message if wrangler_versions.is_outdated() { - let _ = sender.send(wrangler_versions.latest); + let latest_version = styles::highlight(wrangler_versions.latest.to_string()); + let new_version_available = format!( + "A new version of Wrangler ({}) is available!", + latest_version + ); + let update_message = "You can learn more about updating here:".to_string(); + let update_docs_url = styles::url( + "https://developers.cloudflare.com/workers/cli-wrangler/install-update#update", + ); + + StdOut::billboard(&format!( + "{}\n{}\n{}", + new_version_available, update_message, update_docs_url + )); } } Err(e) => log::debug!("could not determine if update is needed:\n{}", e), - }); - - receiver + } } #[derive(Debug, Clone)]