1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
// SPEC.rs
// by Lut99
//
// Created:
// 23 Nov 2022, 11:02:54
// Last edited:
// 09 Mar 2023, 16:12:19
// Auto updated?
// Yes
//
// Description:
//! Defines (public) interfaces and structs used in the `brane-prx`
//! crate.
//
use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::Mutex;
use brane_cfg::proxy::ProxyConfig;
use serde::{Deserialize, Serialize};
use crate::ports::PortAllocator;
/***** LIBRARY *****/
/// Defines the Context to all warp calls.
#[derive(Debug)]
pub struct Context {
/// Specifies the node config file.
pub node_config_path: PathBuf,
/// The address to proxy to if at all.
pub proxy: ProxyConfig,
/// Specificies ports we're already serving on.
pub opened: Mutex<HashMap<(String, Option<NewPathRequestTlsOptions>), u16>>,
/// Specificies available path ports.
pub ports: Mutex<PortAllocator>,
}
/// Defines the body for new path requests.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct NewPathRequest {
/// The address to connect to.
pub address: String,
/// If given, uses TLS with the given options.
pub tls: Option<NewPathRequestTlsOptions>,
}
/// Defines the body for TLS options.
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct NewPathRequestTlsOptions {
/// The location for which we use TLS. Effectively this means a root certificate to use.
pub location: String,
/// Whether to load a client certficate or not.
pub use_client_auth: bool,
}