From 29c48afafb4a6a0a0636774f9b56423881fb1703 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 29 May 2024 23:44:14 +0200 Subject: implement cookie base auth. --- src/config.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index dfc4e73..a474e1d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -2,9 +2,10 @@ use crate::{ filters::{Node, NodeKind}, State, }; -use anyhow::{anyhow, Context}; +use anyhow::Context; use inotify::{EventMask, Inotify, WatchMask}; use log::{error, info}; +use rand::random; use serde::{ de::{value, Error, SeqAccess, Visitor}, Deserialize, Deserializer, Serialize, @@ -27,11 +28,16 @@ pub struct Config { pub watch_config: bool, pub http: Option, pub https: Option, + #[serde(default = "random_bytes")] + pub private_key: [u8; 32], #[serde(default)] pub limits: Limits, pub handler: DynNode, } +fn random_bytes() -> [u8; 32] { + [(); 32].map(|_| random()) +} pub fn return_true() -> bool { true } @@ -155,7 +161,8 @@ impl<'de> Deserialize<'de> for DynNode { .ok_or(serde::de::Error::unknown_variant(s, &[]))? .instanciate(tv.value) .map_err(|e| { - serde::de::Error::custom(e.context(anyhow!("instanciating modules {s:?}"))) + let x = format!("instanciating modules {s:?}: {e:?}"); + serde::de::Error::custom(e.context(x)) })?; Ok(Self(inst)) -- cgit v1.2.3-70-g09d2