mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 10:15:31 +00:00
udp: initial support for listing peer clients
This commit is contained in:
parent
977349ec03
commit
a74d6aa458
14 changed files with 213 additions and 68 deletions
|
|
@ -11,6 +11,8 @@ readme.workspace = true
|
|||
rust-version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
aquatic_peer_id.workspace = true
|
||||
|
||||
byteorder = "1"
|
||||
either = "1"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
use std::fmt::Debug;
|
||||
use std::net::{Ipv4Addr, Ipv6Addr};
|
||||
|
||||
pub use aquatic_peer_id::{PeerClient, PeerId};
|
||||
|
||||
pub trait Ip: Clone + Copy + Debug + PartialEq + Eq {}
|
||||
|
||||
impl Ip for Ipv4Addr {}
|
||||
|
|
@ -30,9 +32,6 @@ pub struct NumberOfDownloads(pub i32);
|
|||
#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)]
|
||||
pub struct Port(pub u16);
|
||||
|
||||
#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug, PartialOrd, Ord)]
|
||||
pub struct PeerId(pub [u8; 20]);
|
||||
|
||||
#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)]
|
||||
pub struct PeerKey(pub u32);
|
||||
|
||||
|
|
@ -55,19 +54,6 @@ impl quickcheck::Arbitrary for InfoHash {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl quickcheck::Arbitrary for PeerId {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
let mut bytes = [0u8; 20];
|
||||
|
||||
for byte in bytes.iter_mut() {
|
||||
*byte = u8::arbitrary(g);
|
||||
}
|
||||
|
||||
Self(bytes)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl<I: Ip + quickcheck::Arbitrary> quickcheck::Arbitrary for ResponsePeer<I> {
|
||||
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ use std::net::Ipv4Addr;
|
|||
use byteorder::{NetworkEndian, ReadBytesExt, WriteBytesExt};
|
||||
use either::Either;
|
||||
|
||||
use aquatic_peer_id::PeerId;
|
||||
|
||||
use super::common::*;
|
||||
|
||||
const PROTOCOL_IDENTIFIER: i64 = 4_497_486_125_440;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue