From ac132fb1eeb5bd3de521fab65ccd4dd2549de616 Mon Sep 17 00:00:00 2001 From: Al Liu Date: Sun, 28 Apr 2024 01:18:48 +0800 Subject: [PATCH] WIP --- core/src/lib.rs | 64 ++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/core/src/lib.rs b/core/src/lib.rs index befb1f0..f4cd686 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -60,8 +60,8 @@ pub mod tests { use std::net::SocketAddr; use nodecraft::resolver::AddressResolver; - #[cfg(not(windows))] - use parking_lot::Mutex; + // #[cfg(not(windows))] + // use parking_lot::Mutex; pub use paste; use self::{delegate::Delegate, error::Error, transport::Transport}; @@ -120,44 +120,44 @@ pub mod tests { /// Any error type used for testing. pub type AnyError = Box; - #[cfg(not(windows))] - static IPV4_BIND_NUM: Mutex = Mutex::new(10); - #[cfg(not(windows))] - static IPV6_BIND_NUM: Mutex = Mutex::new(10); + // #[cfg(not(windows))] + // static IPV4_BIND_NUM: Mutex = Mutex::new(10); + // #[cfg(not(windows))] + // static IPV6_BIND_NUM: Mutex = Mutex::new(10); /// Returns the next socket addr v4 pub fn next_socket_addr_v4(_network: u8) -> SocketAddr { - #[cfg(not(windows))] - { - let mut mu = IPV4_BIND_NUM.lock(); - let addr: SocketAddr = format!("127.0.{}.{}:0", _network, *mu).parse().unwrap(); - *mu += 1; - if *mu > 255 { - *mu = 10; - } - - addr - } - - #[cfg(windows)] + // #[cfg(not(windows))] + // { + // let mut mu = IPV4_BIND_NUM.lock(); + // let addr: SocketAddr = format!("127.0.{}.{}:0", _network, *mu).parse().unwrap(); + // *mu += 1; + // if *mu > 255 { + // *mu = 10; + // } + + // addr + // } + + // #[cfg(windows)] "127.0.0.1:0".parse().unwrap() } /// Returns the next socket addr v6 pub fn next_socket_addr_v6() -> SocketAddr { - #[cfg(not(windows))] - { - let mut mu = IPV6_BIND_NUM.lock(); - let addr: SocketAddr = format!("[fc00::1:{}]:0", *mu).parse().unwrap(); - *mu += 1; - if *mu > 255 { - *mu = 10; - } - - addr - } - - #[cfg(windows)] + // #[cfg(not(windows))] + // { + // let mut mu = IPV6_BIND_NUM.lock(); + // let addr: SocketAddr = format!("[fc00::1:{}]:0", *mu).parse().unwrap(); + // *mu += 1; + // if *mu > 255 { + // *mu = 10; + // } + + // addr + // } + + // #[cfg(windows)] "[::1]:0".parse().unwrap() }