📝 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
|
/// Config fields as they are loaded from the config file
|
||||||
// set up the HTTP server
|
|
||||||
|
|
||||||
pub mod file {
|
pub mod file {
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
@ -29,26 +28,31 @@ pub mod file {
|
||||||
|
|
||||||
#[derive (Deserialize)]
|
#[derive (Deserialize)]
|
||||||
pub struct Server {
|
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 name: String,
|
||||||
|
|
||||||
pub tripcode: BlakeHashWrapper,
|
pub tripcode: BlakeHashWrapper,
|
||||||
|
|
||||||
|
/// This allows a relay-side rename of servers
|
||||||
pub display_name: Option <String>,
|
pub display_name: Option <String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Empty
|
||||||
|
|
||||||
#[derive (Deserialize)]
|
#[derive (Deserialize)]
|
||||||
pub struct DevMode {
|
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)]
|
#[derive (Default, Deserialize)]
|
||||||
pub struct Isomorphic {
|
pub struct Isomorphic {
|
||||||
#[serde (default)]
|
#[serde (default)]
|
||||||
pub enable_scraper_api: bool,
|
pub enable_scraper_api: bool,
|
||||||
|
|
||||||
// If any of these fields are used, we are in dev mode and have to
|
/// If any of the `DevMode` fields are used, we are in dev mode
|
||||||
// show extra warnings, since some auth may be weakened
|
/// and have to show extra warnings, since auth may be weakened
|
||||||
pub dev_mode: Option <DevMode>,
|
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 struct Config {
|
||||||
pub iso: file::Isomorphic,
|
pub iso: file::Isomorphic,
|
||||||
|
|
|
@ -72,24 +72,24 @@ impl Default for ServerStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Relay {
|
pub struct Relay {
|
||||||
pub config: RwLock <Config>,
|
pub (crate) config: RwLock <Config>,
|
||||||
|
|
||||||
// Key: Server ID
|
// Key: Server ID
|
||||||
pub request_rendezvous: Mutex <HashMap <String, RequestRendezvous>>,
|
pub (crate) request_rendezvous: Mutex <HashMap <String, RequestRendezvous>>,
|
||||||
pub server_status: Mutex <HashMap <String, ServerStatus>>,
|
pub (crate) server_status: Mutex <HashMap <String, ServerStatus>>,
|
||||||
|
|
||||||
// Key: Request ID
|
// 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 (crate) shutdown_watch_tx: watch::Sender <bool>,
|
||||||
pub shutdown_watch_rx: watch::Receiver <bool>,
|
pub (crate) shutdown_watch_rx: watch::Receiver <bool>,
|
||||||
|
|
||||||
// List of recently rejected server names (Used to approve servers)
|
// 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
|
// Memory backend for audit logging
|
||||||
// TODO: Add file / database / network server logging backend
|
// TODO: Add file / database / network server logging backend
|
||||||
pub audit_log: BoundedVec <AuditEvent>,
|
pub (crate) audit_log: BoundedVec <AuditEvent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive (Clone)]
|
#[derive (Clone)]
|
||||||
|
@ -177,6 +177,8 @@ impl TryFrom <Config> for Relay {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Relay {
|
impl Relay {
|
||||||
|
/// Returns a `Vec` of the names of currently connected servers
|
||||||
|
|
||||||
pub async fn list_servers (&self) -> Vec <String> {
|
pub async fn list_servers (&self) -> Vec <String> {
|
||||||
self.request_rendezvous.lock ().await.iter ()
|
self.request_rendezvous.lock ().await.iter ()
|
||||||
.map (|(k, _)| (*k).clone ())
|
.map (|(k, _)| (*k).clone ())
|
||||||
|
|
Loading…
Reference in New Issue