Peer

Struct Peer 

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

One connection, as the voice plane sees it.

Implementations§

Source§

impl Peer

Source

pub fn new( connection: ConnectionId, session: SessionId, host: IpAddr, crypt: CryptState, queue: Arc<OutboundQueue>, plane: ShardPlane, now: Instant, ) -> Peer

Source

pub fn online_since(&self) -> Instant

When this connection was registered.

Source

pub fn record_report(&self, report: ClientReport)

Store what the client reported about its own side of the link.

Source

pub fn reported(&self) -> ClientReport

Source

pub fn traffic(&self, now: Instant) -> (u32, Duration)

Voice throughput over the last second, in bytes per second, and how long this connection has been idle.

Source

pub fn record_activity(&self, now: Instant)

Note a control message that is not a keepalive.

Source

pub fn connection(&self) -> ConnectionId

Source

pub fn session(&self) -> SessionId

Source

pub fn host(&self) -> IpAddr

Source

pub fn queue(&self) -> Arc<OutboundQueue>

Source

pub fn cursor_cell(&self) -> Arc<AtomicU64>

Source

pub fn cursor(&self) -> u64

Source

pub fn shard(&self) -> ShardId

Source

pub fn routing(&self) -> Arc<AudioRouting>

The routing table of the shard this connection belongs to.

Source

pub fn move_to(&self, plane: ShardPlane)

Point this connection at another shard. Called by a migration, once.

Source

pub fn decrypt(&self, datagram: &[u8]) -> Option<Vec<u8>>

Try to decrypt a datagram in this peer’s OCB2 domain.

A failure is side-effect free - the IV is restored and nothing is written to the replay history - which is what makes the cold path’s “try every candidate” safe.

REF: references/mumble/src/murmur/Server.cpp : Server::run binds an unknown peer to the first checkDecrypt that succeeds.

Source

pub fn encrypt(&self, plaintext: &[u8]) -> Option<Vec<u8>>

Source

pub fn crypt_counters(&self) -> (u32, u32, u32)

The OCB2 counters the TCP Ping reply must report.

Source

pub fn allow_voice(&self, now: Instant, bytes: usize) -> bool

Whether this peer may send one more voice packet right now.

Source

pub fn allow_text(&self, now: Instant) -> bool

Whether this peer may send one more text message right now.

Source

pub fn set_udp_mode(&self, on: bool)

Record that this peer’s audio is arriving over UDP again, or that it has fallen back to the tunnel.

REF: references/mumble/src/murmur/Server.cpp : aiUdpFlag goes to 0 on a UDPTunnel message and back to 1 when a datagram arrives.

Source

pub fn destination(&self) -> Option<SocketAddr>

Where audio for this peer goes: its proven address, or None meaning the TCP tunnel.

Both conditions are required, as in the real server: a proven address and a peer whose own audio last came over UDP. A client whose UDP dies mid-call keeps hearing everyone, through the tunnel.

Source

pub fn proven_address(&self) -> Option<SocketAddr>

The address this peer has proven, whatever transport it last used.

Source

pub fn close(&self)

Mark the connection for teardown by its own task.

Trait Implementations§

Source§

impl Debug for Peer

Hand-written so key material never reaches a log. Everything printed here is an identifier or a state flag; the OCB2 domain is named, not shown.

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Peer

§

impl RefUnwindSafe for Peer

§

impl Send for Peer

§

impl Sync for Peer

§

impl Unpin for Peer

§

impl UnwindSafe for Peer

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.