mirror of
https://github.com/dndx/phantun.git
synced 2025-04-20 18:59:29 +08:00
No need to use modulo operation, AtomicU16 will wrap.
This commit is contained in:
parent
40af62d14a
commit
ea9b6575fc
@ -406,7 +406,7 @@ impl Stack {
|
|||||||
/// the connection attempt failed.
|
/// the connection attempt failed.
|
||||||
pub async fn connect(&self, addr: SocketAddr) -> Option<Socket> {
|
pub async fn connect(&self, addr: SocketAddr) -> Option<Socket> {
|
||||||
for _ in 1024..u16::MAX {
|
for _ in 1024..u16::MAX {
|
||||||
let mut local_port = self.last_used_port.fetch_add(1, Ordering::SeqCst) % u16::MAX;
|
let mut local_port = self.last_used_port.fetch_add(1, Ordering::SeqCst);
|
||||||
if local_port < u16::MAX - 1024 {
|
if local_port < u16::MAX - 1024 {
|
||||||
local_port += 1024;
|
local_port += 1024;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user