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
|
||||
|
||||
- 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.
|
||||
|
||||
## 2.2.0 - 2022-12-21
|
||||
|
|
|
@ -14,7 +14,7 @@ use crate::{
|
|||
|
||||
/// Multipath TCP (MPTCP) preference.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Mptcp {
|
||||
pub enum MpTcp {
|
||||
/// MPTCP will not be used when binding sockets.
|
||||
Disabled,
|
||||
|
||||
|
@ -33,7 +33,7 @@ pub struct ServerBuilder {
|
|||
pub(crate) backlog: u32,
|
||||
pub(crate) factories: Vec<Box<dyn InternalServiceFactory>>,
|
||||
pub(crate) sockets: Vec<(usize, String, MioListener)>,
|
||||
pub(crate) mptcp: Mptcp,
|
||||
pub(crate) mptcp: MpTcp,
|
||||
pub(crate) exit: bool,
|
||||
pub(crate) listen_os_signals: bool,
|
||||
pub(crate) cmd_tx: UnboundedSender<ServerCommand>,
|
||||
|
@ -58,7 +58,7 @@ impl ServerBuilder {
|
|||
factories: Vec::new(),
|
||||
sockets: Vec::new(),
|
||||
backlog: 2048,
|
||||
mptcp: MPTCP::Disabled,
|
||||
mptcp: MpTcp::Disabled,
|
||||
exit: false,
|
||||
listen_os_signals: true,
|
||||
cmd_tx,
|
||||
|
@ -294,7 +294,7 @@ impl ServerBuilder {
|
|||
pub(super) fn bind_addr<S: ToSocketAddrs>(
|
||||
addr: S,
|
||||
backlog: u32,
|
||||
mptcp: &MPTCP,
|
||||
mptcp: &MpTcp,
|
||||
) -> io::Result<Vec<MioTcpListener>> {
|
||||
let mut opt_err = None;
|
||||
let mut success = false;
|
||||
|
|
|
@ -21,7 +21,7 @@ mod worker;
|
|||
#[doc(hidden)]
|
||||
pub use self::socket::FromStream;
|
||||
pub use self::{
|
||||
builder::{ServerBuilder, MPTCP},
|
||||
builder::{MpTcp, ServerBuilder},
|
||||
handle::ServerHandle,
|
||||
server::Server,
|
||||
service::ServerServiceFactory,
|
||||
|
|
|
@ -11,7 +11,7 @@ pub(crate) use {
|
|||
mio::net::UnixListener as MioUnixListener, std::os::unix::net::UnixListener as StdUnixListener,
|
||||
};
|
||||
|
||||
use crate::builder::MPTCP;
|
||||
use crate::builder::MpTcp;
|
||||
|
||||
pub(crate) enum MioListener {
|
||||
Tcp(MioTcpListener),
|
||||
|
@ -225,7 +225,7 @@ mod unix_impl {
|
|||
pub(crate) fn create_mio_tcp_listener(
|
||||
addr: StdSocketAddr,
|
||||
backlog: u32,
|
||||
mptcp: &Mptcp,
|
||||
mptcp: &MpTcp,
|
||||
) -> io::Result<MioTcpListener> {
|
||||
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)) {
|
||||
Ok(sock) => sock,
|
||||
Err(err) => {
|
||||
if mptcp == &Mptcp::TcpFallback {
|
||||
if matches!(mptcp, MpTcp::TcpFallback) {
|
||||
Socket::new(Domain::for_address(addr), Type::STREAM, Some(Protocol::TCP))?
|
||||
} else {
|
||||
return Err(err);
|
||||
|
@ -268,7 +268,7 @@ mod tests {
|
|||
assert_eq!(format!("{}", addr), "127.0.0.1:8080");
|
||||
|
||||
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);
|
||||
assert!(format!("{:?}", lst).contains("TcpListener"));
|
||||
assert!(format!("{}", lst).contains("127.0.0.1"));
|
||||
|
|
Loading…
Reference in New Issue