mirror of
https://github.com/astro/buzzrelay.git
synced 2024-11-21 11:41:00 +00:00
add RedisConfig.password_file
This commit is contained in:
parent
38f5b2cb13
commit
a8461c7217
3 changed files with 9 additions and 1 deletions
|
@ -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"
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue