diff --git a/config.yaml b/config.yaml index f844030..8c9f515 100644 --- a/config.yaml +++ b/config.yaml @@ -21,4 +21,5 @@ db: "host=localhost user=relay password=xyz dbname=buzzrelay" # Optional Redis redis: connection: "redis://127.0.0.1:6378/" + password_file: "redis_password.txt" in_topic: "relay-in" diff --git a/src/config.rs b/src/config.rs index 383e4db..d14fd1a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -4,6 +4,7 @@ use sigh::{PrivateKey, PublicKey, Key}; #[derive(Clone, Deserialize)] pub struct RedisConfig { pub connection: String, + pub password_file: String, pub in_topic: String, } diff --git a/src/main.rs b/src/main.rs index d1ee929..0dd6aa7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,7 @@ use serde_json::json; use std::{net::SocketAddr, sync::Arc, time::Duration, collections::HashMap}; use std::{panic, process}; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; +use reqwest::Url; mod error; mod config; @@ -334,7 +335,12 @@ async fn main() { let database = db::Database::connect(&config.db).await; let mut redis = None; if let Some(redis_config) = config.redis.clone() { - let client = redis::Client::open(redis_config.connection) + let mut redis_url = Url::parse(&redis_config.connection) + .expect("redis.connection"); + let redis_password = std::fs::read_to_string(redis_config.password_file) + .expect("redis.password_file"); + redis_url.set_password(Some(&redis_password)).unwrap(); + let client = redis::Client::open(redis_url) .expect("redis::Client"); let manager = redis::aio::ConnectionManager::new(client) .await