diff --git a/Cargo.lock b/Cargo.lock index 0d3c430..d1ffc82 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -683,6 +683,7 @@ dependencies = [ "rand", "redis", "tokio", + "urlencoding", "zipf", ] @@ -867,6 +868,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index ac4de2d..b6444b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,3 +26,4 @@ awaitgroup = "0.7.0" colored = "2.1.0" enum_delegate = "0.2.0" ctrlc = "3.4.4" +urlencoding = "2.1.3" diff --git a/src/client.rs b/src/client.rs index 854e781..7d6cc26 100644 --- a/src/client.rs +++ b/src/client.rs @@ -4,6 +4,7 @@ use redis::aio::MultiplexedConnection; use redis::cluster_async::ClusterConnection; use redis::{Cmd, RedisFuture, Value}; use std::fmt::{Display, Formatter}; +use urlencoding::encode; #[derive(Clone)] pub struct ClientConfig { @@ -17,10 +18,12 @@ pub struct ClientConfig { impl ClientConfig { pub async fn get_client(&self) -> Client { + let username = encode(&self.username); + let password = encode(&self.password); let conn_str = if self.tls { - format!("rediss://{}:{}@{}/#insecure", &self.username, &self.password, &self.address) + format!("rediss://{}:{}@{}/#insecure", username, password, &self.address) } else { - format!("redis://{}:{}@{}", &self.username, &self.password, &self.address) + format!("redis://{}:{}@{}", username, password, &self.address) }; if self.cluster {