mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 10:45:30 +00:00
Move some code from aquatic_udp into aquatic_common
This commit is contained in:
parent
1b8d74e26d
commit
5c83af9f88
10 changed files with 111 additions and 82 deletions
|
|
@ -1,31 +1,17 @@
|
|||
use std::net::{SocketAddr, IpAddr};
|
||||
use std::sync::{Arc, atomic::AtomicUsize};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use hashbrown::HashMap;
|
||||
use indexmap::IndexMap;
|
||||
use parking_lot::Mutex;
|
||||
|
||||
pub use aquatic_common::ValidUntil;
|
||||
pub use bittorrent_udp::types::*;
|
||||
|
||||
|
||||
pub const MAX_PACKET_SIZE: usize = 4096;
|
||||
|
||||
|
||||
/// Peer or connection valid until this instant
|
||||
///
|
||||
/// Used instead of "last seen" or similar to hopefully prevent arithmetic
|
||||
/// overflow when cleaning.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct ValidUntil(pub Instant);
|
||||
|
||||
|
||||
impl ValidUntil {
|
||||
pub fn new(offset_seconds: u64) -> Self {
|
||||
Self(Instant::now() + Duration::from_secs(offset_seconds))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct ConnectionKey {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue