Skip to main content

IceAddressPolicy

Struct IceAddressPolicy 

Source
pub struct IceAddressPolicy(/* private fields */);
Expand description

An embedder’s address policy for ICE: one predicate asked at every point where an address enters the ICE agent or the peer connection’s stream, TURN and server-reflexive code, whichever way traffic would go.

  • AddressPurpose::InboundDatagramSource: a datagram (or ICE-TCP stream data) from a refused source is dropped before the agent reads it: it gets no STUN response, teaches no peer-reflexive candidate, refreshes no consent, creates no pair, and no DTLS record or media from it is taken. An ICE-TCP connection from such a source is refused when the driver reports it accepted, and one a TURN server announces for a relayed TCP address is not bound.
  • AddressPurpose::RemoteCandidate: a remote candidate on a refused address is never held or paired (the peer connection treats it as W3C webrtc-pc 4.4.2 “administratively prohibited”: addIceCandidate succeeds, no check is ever sent there).
  • AddressPurpose::PeerReflexiveSource: a refused source is not learned as a peer-reflexive remote candidate, so its request is not answered.
  • AddressPurpose::StunTurnServer: a server address the engine would send its Binding request or its Allocate to (after the name’s resolution) is skipped, as if it had failed.

The predicate sees the address with an IPv4-mapped IPv6 address (::ffff:a.b.c.d) given as the IPv4 address it carries, so one rule covers both forms. The default allows everything and asks nothing: the agent behaves as it does without a policy.

RFC 8445’s procedures (Section 7.3: answer every authenticated request, Section 7.3.1.3: learn its source as a peer-reflexive candidate) apply to what reaches the agent; a datagram the policy refuses is dropped before that, as a host firewall would drop it. This is how an embedder carries out the address handling of RFC 8828 (which modes of address exposure and which routes are allowed) beyond what the candidate types alone can say.

Implementations§

Source§

impl IceAddressPolicy

Source

pub fn new( predicate: impl Fn(SocketAddr, AddressDirection, AddressPurpose) -> bool + Send + Sync + 'static, ) -> Self

A policy asking predicate about every address; false refuses it.

Source

pub fn allow_all() -> Self

The default: every address is allowed and the predicate is never asked.

Source

pub fn is_allow_all(&self) -> bool

Whether this is the allow-everything default.

Source

pub fn allows(&self, addr: SocketAddr, purpose: AddressPurpose) -> bool

Whether addr may be used for purpose (in that purpose’s direction).

Trait Implementations§

Source§

impl Clone for IceAddressPolicy

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IceAddressPolicy

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for IceAddressPolicy

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.