Skip to main content

UdpConfig

Struct UdpConfig 

Source
pub struct UdpConfig {
    pub bind_addr: Option<String>,
    pub mtu: Option<u16>,
    pub recv_buf_size: Option<usize>,
    pub send_buf_size: Option<usize>,
    pub advertise_on_nostr: Option<bool>,
    pub public: Option<bool>,
    pub external_addr: Option<String>,
    pub outbound_only: Option<bool>,
    pub accept_connections: Option<bool>,
}
Expand description

UDP transport instance configuration.

Fields§

§bind_addr: Option<String>

Bind address (bind_addr). Defaults to “0.0.0.0:2121”.

When outbound_only = true, this field is ignored and the transport binds to 0.0.0.0:0 (kernel-assigned ephemeral port) regardless.

§mtu: Option<u16>

UDP MTU (mtu). Defaults to 1280 (IPv6 minimum).

§recv_buf_size: Option<usize>

UDP receive buffer size in bytes (recv_buf_size). Defaults to 16 MiB.

§send_buf_size: Option<usize>

UDP send buffer size in bytes (send_buf_size). Defaults to 8 MiB.

§advertise_on_nostr: Option<bool>

Whether this transport should be advertised on Nostr overlay discovery. Default: false. Implicitly forced false when outbound_only = true.

§public: Option<bool>

Whether UDP should be advertised as directly reachable (host:port) on Nostr. When false and advertised, UDP is emitted as addr: "nat" to trigger rendezvous traversal.

Default: false.

§external_addr: Option<String>

Optional explicit public address to advertise when public: true is set. Takes precedence over both the bound address and any STUN-derived autodiscovery. Accepts either a bare IP ("198.51.100.1" — the configured bind_addr port is appended) or a full host:port ("198.51.100.1:443"). Useful when the public IP isn’t on a local interface (e.g. AWS EIP / cloud 1:1 NAT) and the operator wants to skip STUN autodiscovery for a deterministic value.

§outbound_only: Option<bool>

Outbound-only mode. When true, the transport binds to a kernel- assigned ephemeral port (0.0.0.0:0) instead of the configured bind_addr, refuses inbound handshake msg1, and is never advertised on Nostr regardless of advertise_on_nostr. Use this to participate in the mesh as a pure client — initiate outbound links without exposing an inbound listener on a known port. Default: false.

§accept_connections: Option<bool>

Accept inbound handshake msg1 from new peers. Default: true. Setting this to false combined with auto_connect: true on peer-side configurations gives a “client” posture: this node initiates outbound links but refuses inbound handshakes from unfamiliar addresses. The Node-level gate at src/node/handlers/handshake.rs carves out msg1 from peers already established on this transport (so rekey continues to work) — see ISSUE-2026-0004.

Implementations§

Source§

impl UdpConfig

Source

pub fn bind_addr(&self) -> &str

Get the bind address, using default if not configured.

When outbound_only = true, returns 0.0.0.0:0 so the kernel picks an ephemeral source port and no listener is exposed on a known port.

Source

pub fn mtu(&self) -> u16

Get the UDP MTU, using default if not configured.

Source

pub fn recv_buf_size(&self) -> usize

Get the receive buffer size, using default if not configured.

Source

pub fn send_buf_size(&self) -> usize

Get the send buffer size, using default if not configured.

Source

pub fn advertise_on_nostr(&self) -> bool

Whether this UDP transport should be advertised on Nostr discovery. Always false when outbound_only = true.

Source

pub fn is_public(&self) -> bool

Whether this UDP transport should be advertised as directly reachable.

Source

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

Parse external_addr against the configured bind_addr port, returning the absolute SocketAddr to advertise on Nostr. Returns None if external_addr is unset or malformed, or if the port cannot be inferred.

Source

pub fn outbound_only(&self) -> bool

Whether this transport runs in outbound-only mode. Default: false.

Source

pub fn accept_connections(&self) -> bool

Whether this transport accepts inbound handshakes. Default: true.

Trait Implementations§

Source§

impl Clone for UdpConfig

Source§

fn clone(&self) -> UdpConfig

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 UdpConfig

Source§

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

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

impl Default for UdpConfig

Source§

fn default() -> UdpConfig

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

impl<'de> Deserialize<'de> for UdpConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for UdpConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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 = 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,