Skip to main content

pb_mapper_server/
lib.rs

1//! Relay server domain model and module wiring.
2//!
3//! ```text
4//! TCP / QUIC listener -> connection authentication/dispatch -> ManagerTask queue
5//!                                                         -> routing runtime
6//! registered control connection <------ ConnTask ----+------> subscriber
7//! ```
8//!
9//! `connection` owns per-socket protocol/authentication concerns, while `runtime`
10//! serializes global routing maps and quotas. `task` holds the messages between
11//! them, `routing` the routing model the runtime keeps, and `service_key` the
12//! namespaced service keys both use. Service-side and client-side tunnel loops
13//! remain isolated in `server` and `client`.
14
15mod admin;
16mod client;
17mod connection;
18pub mod direct;
19mod error;
20mod guard;
21// Moved here from `common`: the routing runtime is its only caller.
22pub mod manager;
23#[cfg(feature = "relay-quic")]
24mod quic;
25mod routing;
26mod runtime;
27mod server;
28mod service_key;
29mod status;
30mod task;
31
32use std::net::SocketAddr;
33
34pub use direct::DirectServerConfig;
35pub use routing::{ImutableKey, ServerConnHealth, ServerConnInfo, ServerConnMap};
36pub use runtime::{
37    run_server, run_server_on_listener, run_server_on_listener_with_direct,
38    run_server_on_listener_with_options, run_server_with_auth_config, run_server_with_shutdown,
39};
40pub use task::{ConnTask, ManagerTask};
41
42// Paths the connection handlers and the direct coordinator name items by.
43pub(crate) use error::Result;
44pub(crate) use routing::server_conn_idle_timeout;
45pub(crate) use service_key::{
46    compose_service_key, scoped_service_key, split_scoped_service_key, validate_service_name,
47};
48pub(crate) use task::{ConnTaskReceiver, ConnTaskSender, ManagerTaskSender};
49
50#[derive(Debug, Clone)]
51pub struct ServerStatusInfo {
52    /// Registered control connections, across every service.
53    pub active_connections: u32,
54    pub registered_services: u32,
55    pub uptime_seconds: u64,
56}
57
58/// Optional QUIC listener, separate from the direct STUN UDP port.
59#[derive(Clone, Debug)]
60pub struct QuicServerConfig {
61    pub listen: SocketAddr,
62    /// Zero advertises the bound port; set for a NAT port mapping.
63    pub advertise_port: u16,
64}
65
66#[derive(Clone, Debug, Default)]
67pub struct RelayServerOptions {
68    pub direct: Option<DirectServerConfig>,
69    pub quic: Option<QuicServerConfig>,
70}