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
impl UdpConfig
Sourcepub fn bind_addr(&self) -> &str
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.
Sourcepub fn recv_buf_size(&self) -> usize
pub fn recv_buf_size(&self) -> usize
Get the receive buffer size, using default if not configured.
Sourcepub fn send_buf_size(&self) -> usize
pub fn send_buf_size(&self) -> usize
Get the send buffer size, using default if not configured.
Sourcepub fn advertise_on_nostr(&self) -> bool
pub fn advertise_on_nostr(&self) -> bool
Whether this UDP transport should be advertised on Nostr discovery.
Always false when outbound_only = true.
Sourcepub fn is_public(&self) -> bool
pub fn is_public(&self) -> bool
Whether this UDP transport should be advertised as directly reachable.
Sourcepub fn external_advert_addr(&self) -> Option<SocketAddr>
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.
Sourcepub fn outbound_only(&self) -> bool
pub fn outbound_only(&self) -> bool
Whether this transport runs in outbound-only mode. Default: false.
Sourcepub fn accept_connections(&self) -> bool
pub fn accept_connections(&self) -> bool
Whether this transport accepts inbound handshakes. Default: true.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for UdpConfig
impl<'de> Deserialize<'de> for UdpConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for UdpConfig
impl RefUnwindSafe for UdpConfig
impl Send for UdpConfig
impl Sync for UdpConfig
impl Unpin for UdpConfig
impl UnsafeUnpin for UdpConfig
impl UnwindSafe for UdpConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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