//! //! Configuration to initialize the Fenrir networking library use crate::{ connection::handshake::HandshakeID, enc::{ asym::{KeyExchangeKind, KeyID, PrivKey, PubKey}, hkdf::HkdfKind, sym::CipherKind, }, }; use ::std::{ net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}, num::NonZeroUsize, option::Option, vec, }; /// Main config for libFenrir #[derive(Clone, Debug)] pub struct Config { /// number of threads that libFenrir will use pub threads: Option, /// List of ipv4 or ipv6 UDP inet socket to listen on /// If empty, libFenrir will listen on a random UDP port on `0.0.0.0` pub listen: Vec, /// List of DNS resolvers to use pub resolvers: Vec, /// Supported handshakes pub handshakes: Vec, /// Supported key exchanges pub key_exchanges: Vec, /// Supported Hkdfs pub hkdfs: Vec, /// Supported Ciphers pub ciphers: Vec, /// list of public/private keys pub keys: Vec<(KeyID, PrivKey, PubKey)>, } impl Default for Config { fn default() -> Self { Config { threads: None, listen: vec![ // ipv4 random port SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 0), // ipv6 random port SocketAddr::new( IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0)), 0, ), ], resolvers: Vec::new(), handshakes: [HandshakeID::DirectorySynchronized].to_vec(), key_exchanges: [KeyExchangeKind::X25519DiffieHellman].to_vec(), hkdfs: [HkdfKind::Sha3].to_vec(), ciphers: [CipherKind::XChaCha20Poly1305].to_vec(), keys: Vec::new(), } } }