ntp_server/lib.rs
1// Copyright 2026 U.S. Federal Government (in countries where recognized)
2// SPDX-License-Identifier: Apache-2.0
3
4//! NTP server library with tokio/smol runtime support and NTS-KE.
5//!
6//! This crate provides NTPv4 server implementations using either the tokio
7//! or smol async runtimes, with optional NTS (Network Time Security) support.
8
9#![deny(unsafe_code)]
10#![warn(missing_docs)]
11#![warn(unreachable_pub)]
12
13// Re-export protocol types from ntp_proto for convenience.
14pub use ntp_proto::{error, extension, protocol, unix_time};
15
16/// Shared NTS logic re-exported from `ntp_proto`.
17#[cfg(any(feature = "nts", feature = "nts-smol"))]
18pub(crate) use ntp_proto::nts_common;
19
20/// Shared types and logic for the NTP server.
21///
22/// Provides request validation, response building, rate limiting, access control,
23/// and interleaved mode tracking per RFC 5905, RFC 8633, and RFC 9769.
24#[cfg(any(feature = "tokio", feature = "smol-runtime"))]
25pub mod server_common;
26
27/// NTP server using the Tokio runtime.
28///
29/// Provides a configurable NTPv4 server that responds to client requests.
30#[cfg(feature = "tokio")]
31pub mod server;
32
33/// NTP server using the smol runtime.
34///
35/// Provides the same server functionality as [`server`] but using the smol
36/// async runtime.
37#[cfg(feature = "smol-runtime")]
38pub mod smol_server;
39
40/// Shared NTS server logic (cookie generation, master key management, NTS request processing).
41#[cfg(any(feature = "nts", feature = "nts-smol"))]
42pub mod nts_server_common;
43
44/// NTS-KE server using the Tokio runtime (RFC 8915).
45///
46/// Provides a TLS 1.3 listener for NTS Key Establishment, distributing cookies
47/// and negotiating AEAD algorithms with NTS clients.
48#[cfg(feature = "nts")]
49pub mod nts_ke_server;
50
51/// NTS-KE server using the smol runtime (RFC 8915).
52///
53/// Provides the same NTS-KE server functionality as [`nts_ke_server`] but
54/// using the smol async runtime and futures-rustls.
55#[cfg(feature = "nts-smol")]
56pub mod smol_nts_ke_server;
57
58/// NTP broadcast mode (mode 5) packet building per RFC 5905 Section 8.
59///
60/// Deprecated by BCP 223 (RFC 8633) but implemented for spec completeness.
61#[cfg(all(
62 feature = "broadcast",
63 any(feature = "tokio", feature = "smol-runtime")
64))]
65pub mod broadcast;