//! //! 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, }; /// Key used by a server during the handshake #[derive(Clone, Debug)] pub struct ServerKey { pub id: KeyID, pub priv_key: PrivKey, pub pub_key: PubKey, } /// Authentication Server information and keys #[derive(Clone, Debug)] pub struct AuthServer { /// fqdn of the authentication server pub fqdn: crate::auth::Domain, /// list of key ids enabled for this domain pub keys: 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 authentication servers /// clients will have this empty pub servers: Vec, /// list of public/private keys /// clients should have this empty pub server_keys: Vec, } 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(), servers: Vec::new(), server_keys: Vec::new(), } } }