Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ libp2p-stream = { version = "0.4.0-alpha", path = "protocols/stream" }
libp2p-swarm = { version = "0.47.0", path = "swarm" }
libp2p-swarm-derive = { version = "=0.35.1", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required.
libp2p-swarm-test = { version = "0.6.0", path = "swarm-test" }
libp2p-tcp = { version = "0.44.0", path = "transports/tcp" }
libp2p-tcp = { version = "0.44.1", path = "transports/tcp" }
libp2p-tls = { version = "0.6.2", path = "transports/tls" }
libp2p-uds = { version = "0.43.1", path = "transports/uds" }
libp2p-upnp = { version = "0.6.0", path = "protocols/upnp" }
Expand Down
4 changes: 4 additions & 0 deletions transports/tcp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.44.1
- Expose `socket2`'s `set_linger` config option.
See [PR XXXX](https://github.com/libp2p/rust-libp2p/pull/5955)

## 0.44.0

- Remove `async-std` support.
Expand Down
2 changes: 1 addition & 1 deletion transports/tcp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-tcp"
edition.workspace = true
rust-version = { workspace = true }
description = "TCP/IP transport protocol for libp2p"
version = "0.44.0"
version = "0.44.1"
authors = ["Parity Technologies <[email protected]>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
12 changes: 12 additions & 0 deletions transports/tcp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ pub struct Config {
ttl: Option<u32>,
/// `TCP_NODELAY` to set for opened sockets.
nodelay: bool,
/// `SO_LINGER` to set for opened sockets,
/// by default is `None`.
linger: Option<Duration>,
/// Size of the listen backlog for listen sockets.
backlog: u32,
}
Expand Down Expand Up @@ -137,6 +140,7 @@ impl Config {
Self {
ttl: None,
nodelay: true, // Disable Nagle's algorithm by default.
linger: None,
backlog: 1024,
}
}
Expand All @@ -159,6 +163,12 @@ impl Config {
self
}

/// Configures the `SO_LINGER` option for new sockets.
pub fn linger(mut self, duration: Option<Duration>) -> Self {
self.linger = duration;
self
}

/// Configures port reuse for local sockets, which implies
/// reuse of listening ports for outgoing connections to
/// enhance NAT traversal capabilities.
Expand Down Expand Up @@ -196,6 +206,8 @@ impl Config {
if let Some(ttl) = self.ttl {
socket.set_ttl_v4(ttl)?;
}

socket.set_linger(self.linger)?;
socket.set_tcp_nodelay(self.nodelay)?;
socket.set_reuse_address(true)?;
#[cfg(all(unix, not(any(target_os = "solaris", target_os = "illumos"))))]
Expand Down
Loading