diff options
author | metamuffin <metamuffin@disroot.org> | 2024-05-29 23:44:14 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-05-29 23:44:14 +0200 |
commit | 29c48afafb4a6a0a0636774f9b56423881fb1703 (patch) | |
tree | fa610555a33c25a1aaeb98242099c2010ac243b0 /src/config.rs | |
parent | 886a18e0c67624d0882f04c7f6659bcfee6b4d8d (diff) | |
download | gnix-29c48afafb4a6a0a0636774f9b56423881fb1703.tar gnix-29c48afafb4a6a0a0636774f9b56423881fb1703.tar.bz2 gnix-29c48afafb4a6a0a0636774f9b56423881fb1703.tar.zst |
implement cookie base auth.
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 11 |
1 files changed, 9 insertions, 2 deletions
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<HttpConfig>, pub https: Option<HttpsConfig>, + #[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)) |