Skip to main content

Nat

Struct Nat 

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

Регистрация локальных адресов в GNUnet NAT. Drop снимает регистрацию.

Implementations§

Source§

impl Nat

Source

pub async fn register( runtime: &GnunetRuntime, config: &Config, config_section: &str, transport: NatTransport, addresses: &[SocketAddr], options: NatOptions, ) -> Result<(Self, NatEvents), NatError>

Регистрирует адреса, на которых слушает приложение. config_section — секция конфигурации с настройками NAT для этого приложения.

Source

pub async fn add_global_address(&self, address: &str) -> Result<(), NatError>

Сообщает сервису адрес, под которым нас видит другой peer (текстовое представление адреса).

Source

pub async fn test_address(&self, address: SocketAddr) -> Result<bool, NatError>

Входит ли адрес в число тех, что сервис сейчас считает нашими.

Source

pub async fn request_reversal( &self, local: SocketAddrV4, remote: SocketAddrV4, ) -> Result<(), NatError>

Просит удалённый peer за NAT установить соединение с нами.

Source

pub async fn stun_handle_packet( &self, sender: SocketAddr, packet: &[u8], ) -> Result<bool, NatError>

Передаёт сервису UDP-пакет, полученный на зарегистрированном сокете. Ok(true) — это был ответ STUN и он обработан; Ok(false) — пакет не STUN и остаётся приложению.

Source

pub async fn stun_request( runtime: &GnunetRuntime, server: &str, port: u16, socket: &UdpSocket, ) -> Result<(), NatError>

Отправляет STUN-запрос серверу с данного UDP-сокета. Завершается после отправки; ответ придёт на тот же сокет, и его нужно передать в stun_handle_packet.

Source

pub async fn close(self) -> Result<(), NatError>

Дожидается снятия регистрации.

Trait Implementations§

Source§

impl Drop for Nat

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Nat

§

impl !UnwindSafe for Nat

§

impl Freeze for Nat

§

impl Send for Nat

§

impl Sync for Nat

§

impl Unpin for Nat

§

impl UnsafeUnpin for Nat

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