pub struct TcpConfig {
pub bind_addr: Option<String>,
pub mtu: Option<u16>,
pub connect_timeout_ms: Option<u64>,
pub nodelay: Option<bool>,
pub keepalive_secs: Option<u64>,
pub recv_buf_size: Option<usize>,
pub send_buf_size: Option<usize>,
pub max_inbound_connections: Option<usize>,
pub advertise_on_nostr: Option<bool>,
pub external_addr: Option<String>,
}Expand description
TCP transport instance configuration.
Fields§
§bind_addr: Option<String>Listen address (e.g., “0.0.0.0:443”). If not set, outbound-only.
mtu: Option<u16>Default MTU for TCP connections. Defaults to 1400. Per-connection MTU is derived from TCP_MAXSEG when available.
connect_timeout_ms: Option<u64>Outbound connect timeout in milliseconds. Defaults to 5000.
nodelay: Option<bool>Enable TCP_NODELAY (disable Nagle). Defaults to true.
keepalive_secs: Option<u64>TCP keepalive interval in seconds. 0 = disabled. Defaults to 30.
recv_buf_size: Option<usize>TCP receive buffer size in bytes. Defaults to 2 MB.
send_buf_size: Option<usize>TCP send buffer size in bytes. Defaults to 2 MB.
max_inbound_connections: Option<usize>Maximum simultaneous inbound connections. Defaults to 256.
advertise_on_nostr: Option<bool>Whether this transport should be advertised on Nostr overlay discovery. Default: false.
external_addr: Option<String>Optional explicit public address to advertise. Required when
bind_addr is wildcard (e.g. "0.0.0.0:443") and
advertise_on_nostr: true, since TCP has no STUN equivalent
for autodiscovery. Accepts either a bare IP ("198.51.100.1"
— the configured bind_addr port is appended) or a full
host:port. Common pattern on AWS EIP / cloud 1:1 NAT setups
where the public IP isn’t bindable on the host.
Implementations§
Source§impl TcpConfig
impl TcpConfig
Sourcepub fn connect_timeout_ms(&self) -> u64
pub fn connect_timeout_ms(&self) -> u64
Get the connect timeout in milliseconds.
Sourcepub fn keepalive_secs(&self) -> u64
pub fn keepalive_secs(&self) -> u64
Get the keepalive interval in seconds. 0 = disabled. Default: 30.
Sourcepub fn recv_buf_size(&self) -> usize
pub fn recv_buf_size(&self) -> usize
Get the receive buffer size. Default: 2 MB.
Sourcepub fn send_buf_size(&self) -> usize
pub fn send_buf_size(&self) -> usize
Get the send buffer size. Default: 2 MB.
Sourcepub fn max_inbound_connections(&self) -> usize
pub fn max_inbound_connections(&self) -> usize
Get the maximum number of inbound connections. Default: 256.
Sourcepub fn advertise_on_nostr(&self) -> bool
pub fn advertise_on_nostr(&self) -> bool
Whether this TCP transport should be advertised on Nostr discovery.
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
bind_addr is unset / unparseable so no port can be inferred.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TcpConfig
impl<'de> Deserialize<'de> for TcpConfig
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 TcpConfig
impl RefUnwindSafe for TcpConfig
impl Send for TcpConfig
impl Sync for TcpConfig
impl Unpin for TcpConfig
impl UnsafeUnpin for TcpConfig
impl UnwindSafe for TcpConfig
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