pub struct RendezvousServer { /* private fields */ }Expand description
Soft-state rendezvous + blind relay. Keyed by NodeId.
Implementations§
Source§impl RendezvousServer
impl RendezvousServer
pub fn new(_now_ms: u64) -> Self
Sourcepub fn new_with_roots(
_now_ms: u64,
ca_pubkeys: Vec<[u8; 32]>,
network_id: [u8; 16],
) -> Self
pub fn new_with_roots( _now_ms: u64, ca_pubkeys: Vec<[u8; 32]>, network_id: [u8; 16], ) -> Self
A rooted (mesh-mode) server: RegisterSigned records are verified
against ca_pubkeys/network_id, and legacy unsigned Register is
dropped (see roots_cfg).
pub fn forwarded_count(&self) -> u64
Sourcepub fn forwarded_handle(&self) -> Arc<AtomicU64> ⓘ
pub fn forwarded_handle(&self) -> Arc<AtomicU64> ⓘ
A cheap clone of the shared forward-count handle, so a front that does
not hold this struct behind the server mutex — the TLS tunnel
(bin/yip-rendezvous/src/conn_tunnel.rs) — can bump the SAME counter
lock-free (#68). The returned handle and this server’s forwarded are
one allocation; a fetch_add through either is visible via
forwarded_count.
Sourcepub fn record_relay_forward(&self)
pub fn record_relay_forward(&self)
Record one relayed hop that happened OUTSIDE handle’s own
RelaySend match arm — specifically, the TLS-tunnel relay path
(bin/yip-rendezvous/src/conn_tunnel.rs’s route), which forwards
RelaySend->RelayDeliver directly over its own per-connection
mpsc channels and never calls handle at all. Without this, the
TLS-relay path would be invisible to forwarded_count even while
genuinely carrying traffic, since forwarded would only ever reflect
the UDP-facing relay half. Same best-effort semantics as the UDP
path’s own increment: counted when a live destination route was
found and delivery was attempted, not gated on confirmed receipt.
Sourcepub fn is_registered(&self, node: &NodeId, now_ms: u64) -> bool
pub fn is_registered(&self, node: &NodeId, now_ms: u64) -> bool
True iff node has a live (unexpired) registration. Used by the TLS
front to distinguish an upgraded tunnel client from a decoy request.
Sourcepub fn roots_cfg(&self) -> Option<&(Vec<[u8; 32]>, [u8; 16])>
pub fn roots_cfg(&self) -> Option<&(Vec<[u8; 32]>, [u8; 16])>
Returns Some((ca_pubkeys, network_id)) if this server is in rooted (mesh) mode,
or None if running rootless.
Sourcepub fn verify_signed_record(&self, record: &Record, now_secs: u64) -> bool
pub fn verify_signed_record(&self, record: &Record, now_secs: u64) -> bool
Verifies a RegisterSigned record’s cert, signature, network ID, and
sequence freshness window against this server’s roots_cfg.
Sourcepub fn sweep(&mut self, now_ms: u64)
pub fn sweep(&mut self, now_ms: u64)
Evict expired registrations. Call on a timer from the socket loop.
Sourcepub fn register_if_fresh(
&mut self,
node: NodeId,
counter: u64,
src: SocketAddr,
now_ms: u64,
) -> bool
pub fn register_if_fresh( &mut self, node: NodeId, counter: u64, src: SocketAddr, now_ms: u64, ) -> bool
Register node iff the message is fresh: a first-seen/expired node, or a
counter strictly greater than the last accepted for a currently-live
registration. Returns true iff THIS call accepted it (fresh insert or a
counter-advancing refresh); false if rejected as stale/replayed or refused
at capacity. This is the discriminator’s source of truth — no inference
from expiry timestamps.
Sourcepub fn register_if_fresh_tls(
&mut self,
node: NodeId,
counter: u64,
now_ms: u64,
) -> bool
pub fn register_if_fresh_tls( &mut self, node: NodeId, counter: u64, now_ms: u64, ) -> bool
Freshness gate for the TLS-front discriminator, kept SEPARATE from the
UDP-servable regs map (a TLS peer is not UDP-reachable and must not
appear in Lookup/RelaySend results with a bogus addr). Returns true
iff counter is fresh (first-seen/expired, or strictly greater than the
last accepted) for this node on the TLS path.
Sourcepub fn handle(
&mut self,
src: SocketAddr,
msg: Message,
now_ms: u64,
now_secs: u64,
) -> Vec<(SocketAddr, Message)>
pub fn handle( &mut self, src: SocketAddr, msg: Message, now_ms: u64, now_secs: u64, ) -> Vec<(SocketAddr, Message)>
Process one received message; return datagrams to send as (dst, msg).
now_ms is the monotonic clock used for TTL/rate-limit bookkeeping
(unchanged from before this task); now_secs is WALL-CLOCK seconds,
used to validate a RegisterSigned record’s embedded cert
window and sequence freshness window — the two are intentionally distinct
clocks and must not be conflated (a monotonic clock has no relation to
wall-clock UNIX timestamps).