mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 18:18:55 +00:00
feat(connlib): gzip encode log files (#2345)
Resolves: #2342. Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
This commit is contained in:
33
rust/Cargo.lock
generated
33
rust/Cargo.lock
generated
@@ -281,6 +281,19 @@ dependencies = [
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-compression"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f658e2baef915ba0f26f1f7c42bfb8e12f532a01f449a090ded75ae7a07e9ba2"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"futures-core",
|
||||
"memchr",
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.73"
|
||||
@@ -792,6 +805,7 @@ name = "connlib-client-shared"
|
||||
version = "1.20231001.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-compression",
|
||||
"async-trait",
|
||||
"backoff",
|
||||
"chrono",
|
||||
@@ -916,6 +930,15 @@ version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484"
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.5.8"
|
||||
@@ -1295,6 +1318,16 @@ dependencies = [
|
||||
"wintun",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.0.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fnv"
|
||||
version = "1.0.7"
|
||||
|
||||
@@ -26,6 +26,7 @@ url = { version = "2.4.1", features = ["serde"] }
|
||||
time = { version = "0.3.29", features = ["formatting"] }
|
||||
reqwest = { version = "0.11.22", default-features = false, features = ["stream", "rustls-tls"] }
|
||||
tokio-tungstenite = { version = "0.20", default-features = false, features = ["connect", "handshake", "rustls-tls-webpki-roots"] }
|
||||
async-compression = { version = "0.4.3", features = ["tokio", "gzip"] }
|
||||
|
||||
[target.'cfg(target_os = "android")'.dependencies]
|
||||
tracing = { workspace = true, features = ["std", "attributes"] }
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use async_compression::tokio::bufread::GzipEncoder;
|
||||
use std::path::PathBuf;
|
||||
use std::{io, sync::Arc};
|
||||
|
||||
@@ -15,6 +16,8 @@ use connlib_shared::{
|
||||
|
||||
use async_trait::async_trait;
|
||||
use firezone_tunnel::{ClientState, ControlSignal, Request, Tunnel};
|
||||
use reqwest::header::{CONTENT_ENCODING, CONTENT_TYPE};
|
||||
use tokio::io::BufReader;
|
||||
use tokio::sync::Mutex;
|
||||
use tokio_util::codec::{BytesCodec, FramedRead};
|
||||
use url::Url;
|
||||
@@ -301,10 +304,13 @@ async fn upload(path: PathBuf, url: Url) -> io::Result<()> {
|
||||
tracing::info!(path = %path.display(), %url, "Uploading log file");
|
||||
|
||||
let file = tokio::fs::File::open(&path).await?;
|
||||
|
||||
let response = reqwest::Client::new()
|
||||
.put(url)
|
||||
.header(CONTENT_TYPE, "text/plain")
|
||||
.header(CONTENT_ENCODING, "gzip")
|
||||
.body(reqwest::Body::wrap_stream(FramedRead::new(
|
||||
file,
|
||||
GzipEncoder::new(BufReader::new(file)),
|
||||
BytesCodec::default(),
|
||||
)))
|
||||
.send()
|
||||
|
||||
Reference in New Issue
Block a user