pub struct Server { /* private fields */ }Expand description
A running KROT server: owns the endpoint and all shared state.
Implementations§
Source§impl Server
impl Server
Sourcepub async fn start(config: ServerConfig) -> Result<Self, ServerError>
pub async fn start(config: ServerConfig) -> Result<Self, ServerError>
Assemble and start a server. Spawns HTTP + HTTPS routers immediately in DomainMode (so ACME HTTP-01 challenges can be answered during cert acquisition).
Sourcepub fn tcp_fallback_addr(&self) -> Option<SocketAddr>
pub fn tcp_fallback_addr(&self) -> Option<SocketAddr>
§16.1.4: local address the krot-tcp/1 fallback listener
bound to, when enabled.
Sourcepub fn admin_api_addr(&self) -> Option<SocketAddr>
pub fn admin_api_addr(&self) -> Option<SocketAddr>
§16.4: local address the admin API bound to, when enabled.
Sourcepub fn with_peer_lookup(self, lookup: Arc<dyn PeerLabelLookup>) -> Self
pub fn with_peer_lookup(self, lookup: Arc<dyn PeerLabelLookup>) -> Self
§16.3.4: swap in a custom PeerLabelLookup implementation.
The default is NoOpPeerLookup which never reports a
collision. Tests use this to inject a mock; real deployments
use it to plug in an HTTP client that queries peer §16.4 admin
APIs.
Safe to call at any point before / during a running server —
the field is Mutex<Arc<...>> and this method swaps the inner
Arc. Concurrent registrations either see the old value or
the new one, not something torn.
pub fn issue_admin_token(&self) -> Result<String, ServerError>
pub fn issue_admin_token_if_needed(&self) -> Result<Option<String>, ServerError>
pub fn fingerprint_hex(&self) -> Option<&str>
pub fn local_addr(&self) -> Result<SocketAddr>
pub fn http_addr(&self) -> Option<SocketAddr>
pub fn https_addr(&self) -> Option<SocketAddr>
pub fn registry(&self) -> &Arc<TunnelRegistry> ⓘ
Sourcepub async fn run(&self)
pub async fn run(&self)
Single-core accept loop, driven on the current tokio runtime.
Runs forever — for tests where the harness kills the task at the
end. For graceful shutdown, use Self::run_until.
Sourcepub async fn run_until(&self, shutdown: Receiver<bool>)
pub async fn run_until(&self, shutdown: Receiver<bool>)
Single-core accept loop with graceful shutdown: exits cleanly when
shutdown flips to true (or its sender is dropped).
Sourcepub fn run_multicore(
self,
cores: usize,
shutdown: &Receiver<bool>,
) -> Result<(), ServerError>
pub fn run_multicore( self, cores: usize, shutdown: &Receiver<bool>, ) -> Result<(), ServerError>
Thread-per-core: spawn cores OS threads, each running an
independent current_thread tokio runtime with its own
SO_REUSEPORT-bound QUIC endpoint and (in DomainMode) its own
HTTPS listener.
Consumes the initial single-endpoint bound in Self::start and
releases its socket before the workers rebind with SO_REUSEPORT.
Blocks until all worker threads join. Graceful shutdown is triggered
by flipping shutdown to true.