mirror of https://github.com/fafhrd91/actix-net
rename MPTCP enum
This commit is contained in:
parent
786fe7af1f
commit
7ee0c08740
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
## Unreleased - 2023-xx-xx
|
## Unreleased - 2023-xx-xx
|
||||||
|
|
||||||
- Add support for MultiPath TCP (MPTCP) with `Mptcp` enum and `ServerBuilder::mptcp()` method.
|
- Add support for MultiPath TCP (MPTCP) with `MpTcp` enum and `ServerBuilder::mptcp()` method.
|
||||||
- Minimum supported Rust version (MSRV) is now 1.65.
|
- Minimum supported Rust version (MSRV) is now 1.65.
|
||||||
|
|
||||||
## 2.2.0 - 2022-12-21
|
## 2.2.0 - 2022-12-21
|
||||||
|
|
|
@ -14,7 +14,7 @@ use crate::{
|
||||||
|
|
||||||
/// Multipath TCP (MPTCP) preference.
|
/// Multipath TCP (MPTCP) preference.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum Mptcp {
|
pub enum MpTcp {
|
||||||
/// MPTCP will not be used when binding sockets.
|
/// MPTCP will not be used when binding sockets.
|
||||||
Disabled,
|
Disabled,
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ pub struct ServerBuilder {
|
||||||
pub(crate) backlog: u32,
|
pub(crate) backlog: u32,
|
||||||
pub(crate) factories: Vec<Box<dyn InternalServiceFactory>>,
|
pub(crate) factories: Vec<Box<dyn InternalServiceFactory>>,
|
||||||
pub(crate) sockets: Vec<(usize, String, MioListener)>,
|
pub(crate) sockets: Vec<(usize, String, MioListener)>,
|
||||||
pub(crate) mptcp: Mptcp,
|
pub(crate) mptcp: MpTcp,
|
||||||
pub(crate) exit: bool,
|
pub(crate) exit: bool,
|
||||||
pub(crate) listen_os_signals: bool,
|
pub(crate) listen_os_signals: bool,
|
||||||
pub(crate) cmd_tx: UnboundedSender<ServerCommand>,
|
pub(crate) cmd_tx: UnboundedSender<ServerCommand>,
|
||||||
|
@ -58,7 +58,7 @@ impl ServerBuilder {
|
||||||
factories: Vec::new(),
|
factories: Vec::new(),
|
||||||
sockets: Vec::new(),
|
sockets: Vec::new(),
|
||||||
backlog: 2048,
|
backlog: 2048,
|
||||||
mptcp: MPTCP::Disabled,
|
mptcp: MpTcp::Disabled,
|
||||||
exit: false,
|
exit: false,
|
||||||
listen_os_signals: true,
|
listen_os_signals: true,
|
||||||
cmd_tx,
|
cmd_tx,
|
||||||
|
@ -294,7 +294,7 @@ impl ServerBuilder {
|
||||||
pub(super) fn bind_addr<S: ToSocketAddrs>(
|
pub(super) fn bind_addr<S: ToSocketAddrs>(
|
||||||
addr: S,
|
addr: S,
|
||||||
backlog: u32,
|
backlog: u32,
|
||||||
mptcp: &MPTCP,
|
mptcp: &MpTcp,
|
||||||
) -> io::Result<Vec<MioTcpListener>> {
|
) -> io::Result<Vec<MioTcpListener>> {
|
||||||
let mut opt_err = None;
|
let mut opt_err = None;
|
||||||
let mut success = false;
|
let mut success = false;
|
||||||
|
|
|
@ -21,7 +21,7 @@ mod worker;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use self::socket::FromStream;
|
pub use self::socket::FromStream;
|
||||||
pub use self::{
|
pub use self::{
|
||||||
builder::{ServerBuilder, MPTCP},
|
builder::{MpTcp, ServerBuilder},
|
||||||
handle::ServerHandle,
|
handle::ServerHandle,
|
||||||
server::Server,
|
server::Server,
|
||||||
service::ServerServiceFactory,
|
service::ServerServiceFactory,
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub(crate) use {
|
||||||
mio::net::UnixListener as MioUnixListener, std::os::unix::net::UnixListener as StdUnixListener,
|
mio::net::UnixListener as MioUnixListener, std::os::unix::net::UnixListener as StdUnixListener,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::builder::MPTCP;
|
use crate::builder::MpTcp;
|
||||||
|
|
||||||
pub(crate) enum MioListener {
|
pub(crate) enum MioListener {
|
||||||
Tcp(MioTcpListener),
|
Tcp(MioTcpListener),
|
||||||
|
@ -225,7 +225,7 @@ mod unix_impl {
|
||||||
pub(crate) fn create_mio_tcp_listener(
|
pub(crate) fn create_mio_tcp_listener(
|
||||||
addr: StdSocketAddr,
|
addr: StdSocketAddr,
|
||||||
backlog: u32,
|
backlog: u32,
|
||||||
mptcp: &Mptcp,
|
mptcp: &MpTcp,
|
||||||
) -> io::Result<MioTcpListener> {
|
) -> io::Result<MioTcpListener> {
|
||||||
use socket2::{Domain, Protocol, Socket, Type};
|
use socket2::{Domain, Protocol, Socket, Type};
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ pub(crate) fn create_mio_tcp_listener(
|
||||||
let socket = match Socket::new(Domain::for_address(addr), Type::STREAM, Some(protocol)) {
|
let socket = match Socket::new(Domain::for_address(addr), Type::STREAM, Some(protocol)) {
|
||||||
Ok(sock) => sock,
|
Ok(sock) => sock,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
if mptcp == &Mptcp::TcpFallback {
|
if matches!(mptcp, MpTcp::TcpFallback) {
|
||||||
Socket::new(Domain::for_address(addr), Type::STREAM, Some(Protocol::TCP))?
|
Socket::new(Domain::for_address(addr), Type::STREAM, Some(Protocol::TCP))?
|
||||||
} else {
|
} else {
|
||||||
return Err(err);
|
return Err(err);
|
||||||
|
@ -268,7 +268,7 @@ mod tests {
|
||||||
assert_eq!(format!("{}", addr), "127.0.0.1:8080");
|
assert_eq!(format!("{}", addr), "127.0.0.1:8080");
|
||||||
|
|
||||||
let addr: StdSocketAddr = "127.0.0.1:0".parse().unwrap();
|
let addr: StdSocketAddr = "127.0.0.1:0".parse().unwrap();
|
||||||
let lst = create_mio_tcp_listener(addr, 128, &MPTCP::Disabled).unwrap();
|
let lst = create_mio_tcp_listener(addr, 128, &MpTcp::Disabled).unwrap();
|
||||||
let lst = MioListener::Tcp(lst);
|
let lst = MioListener::Tcp(lst);
|
||||||
assert!(format!("{:?}", lst).contains("TcpListener"));
|
assert!(format!("{:?}", lst).contains("TcpListener"));
|
||||||
assert!(format!("{}", lst).contains("127.0.0.1"));
|
assert!(format!("{}", lst).contains("127.0.0.1"));
|
||||||
|
|
Loading…
Reference in New Issue