Skip to main content

RendezvousServer

Struct RendezvousServer 

Source
pub struct RendezvousServer { /* private fields */ }
Expand description

Soft-state rendezvous + blind relay. Keyed by NodeId.

Implementations§

Source§

impl RendezvousServer

Source

pub fn new(_now_ms: u64) -> Self

Source

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).

Source

pub fn forwarded_count(&self) -> u64

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn sweep(&mut self, now_ms: u64)

Evict expired registrations. Call on a timer from the socket loop.

Source

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.

Source

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.

Source

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).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.