📝 docs: done with ptth_relay for now
parent
c75448fe2c
commit
67975d9b11
|
@ -15,8 +15,7 @@ use crate::{
|
|||
},
|
||||
};
|
||||
|
||||
// Stuff we need to load from the config file and use to
|
||||
// set up the HTTP server
|
||||
/// Config fields as they are loaded from the config file
|
||||
|
||||
pub mod file {
|
||||
use serde::Deserialize;
|
||||
|
@ -29,26 +28,31 @@ pub mod file {
|
|||
|
||||
#[derive (Deserialize)]
|
||||
pub struct Server {
|
||||
// This is duplicated in the hashmap, but it's not a problem
|
||||
/// This is duplicated in the hashmap, but it's not a problem
|
||||
pub name: String,
|
||||
|
||||
pub tripcode: BlakeHashWrapper,
|
||||
|
||||
/// This allows a relay-side rename of servers
|
||||
pub display_name: Option <String>,
|
||||
}
|
||||
|
||||
/// Empty
|
||||
|
||||
#[derive (Deserialize)]
|
||||
pub struct DevMode {
|
||||
|
||||
}
|
||||
|
||||
// Stuff that's identical between the file and the runtime structures
|
||||
/// Config fields that are identical in the file and at runtime
|
||||
|
||||
#[derive (Default, Deserialize)]
|
||||
pub struct Isomorphic {
|
||||
#[serde (default)]
|
||||
pub enable_scraper_api: bool,
|
||||
|
||||
// If any of these fields are used, we are in dev mode and have to
|
||||
// show extra warnings, since some auth may be weakened
|
||||
/// If any of the `DevMode` fields are used, we are in dev mode
|
||||
/// and have to show extra warnings, since auth may be weakened
|
||||
pub dev_mode: Option <DevMode>,
|
||||
}
|
||||
|
||||
|
@ -65,7 +69,7 @@ pub mod file {
|
|||
}
|
||||
}
|
||||
|
||||
// Stuff we actually need at runtime
|
||||
/// Config fields as they are used at runtime
|
||||
|
||||
pub struct Config {
|
||||
pub iso: file::Isomorphic,
|
||||
|
|
|
@ -72,24 +72,24 @@ impl Default for ServerStatus {
|
|||
}
|
||||
|
||||
pub struct Relay {
|
||||
pub config: RwLock <Config>,
|
||||
pub (crate) config: RwLock <Config>,
|
||||
|
||||
// Key: Server ID
|
||||
pub request_rendezvous: Mutex <HashMap <String, RequestRendezvous>>,
|
||||
pub server_status: Mutex <HashMap <String, ServerStatus>>,
|
||||
pub (crate) request_rendezvous: Mutex <HashMap <String, RequestRendezvous>>,
|
||||
pub (crate) server_status: Mutex <HashMap <String, ServerStatus>>,
|
||||
|
||||
// Key: Request ID
|
||||
pub response_rendezvous: RwLock <DashMap <String, ResponseRendezvous>>,
|
||||
pub (crate) response_rendezvous: RwLock <DashMap <String, ResponseRendezvous>>,
|
||||
|
||||
pub shutdown_watch_tx: watch::Sender <bool>,
|
||||
pub shutdown_watch_rx: watch::Receiver <bool>,
|
||||
pub (crate) shutdown_watch_tx: watch::Sender <bool>,
|
||||
pub (crate) shutdown_watch_rx: watch::Receiver <bool>,
|
||||
|
||||
// List of recently rejected server names (Used to approve servers)
|
||||
pub unregistered_servers: BoundedVec <RejectedServer>,
|
||||
pub (crate) unregistered_servers: BoundedVec <RejectedServer>,
|
||||
|
||||
// Memory backend for audit logging
|
||||
// TODO: Add file / database / network server logging backend
|
||||
pub audit_log: BoundedVec <AuditEvent>,
|
||||
pub (crate) audit_log: BoundedVec <AuditEvent>,
|
||||
}
|
||||
|
||||
#[derive (Clone)]
|
||||
|
@ -177,6 +177,8 @@ impl TryFrom <Config> for Relay {
|
|||
}
|
||||
|
||||
impl Relay {
|
||||
/// Returns a `Vec` of the names of currently connected servers
|
||||
|
||||
pub async fn list_servers (&self) -> Vec <String> {
|
||||
self.request_rendezvous.lock ().await.iter ()
|
||||
.map (|(k, _)| (*k).clone ())
|
||||
|
|
Loading…
Reference in New Issue