mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
Add CanonicalSocketAddr struct (#49)
* Add CanonicalSocketAddr struct to aquatic_common, use in aquatic_udp * udp_bench: fix build error by using CanonicalSocketAddr
This commit is contained in:
parent
f7e0f61119
commit
91dcd3de4d
8 changed files with 92 additions and 65 deletions
|
|
@ -12,6 +12,7 @@ name = "aquatic_udp_bench"
|
|||
[dependencies]
|
||||
anyhow = "1"
|
||||
aquatic_cli_helpers = "0.1.0"
|
||||
aquatic_common = "0.1.0"
|
||||
aquatic_udp = "0.1.0"
|
||||
aquatic_udp_protocol = "0.1.0"
|
||||
crossbeam-channel = "0.5"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use aquatic_common::CanonicalSocketAddr;
|
||||
use crossbeam_channel::{Receiver, Sender};
|
||||
use indicatif::ProgressIterator;
|
||||
use rand::Rng;
|
||||
|
|
@ -14,8 +15,8 @@ use crate::config::BenchConfig;
|
|||
|
||||
pub fn bench_announce_handler(
|
||||
bench_config: &BenchConfig,
|
||||
request_sender: &Sender<(SocketWorkerIndex, ConnectedRequest, SocketAddr)>,
|
||||
response_receiver: &Receiver<(ConnectedResponse, SocketAddr)>,
|
||||
request_sender: &Sender<(SocketWorkerIndex, ConnectedRequest, CanonicalSocketAddr)>,
|
||||
response_receiver: &Receiver<(ConnectedResponse, CanonicalSocketAddr)>,
|
||||
rng: &mut impl Rng,
|
||||
info_hashes: &[InfoHash],
|
||||
) -> (usize, Duration) {
|
||||
|
|
@ -79,7 +80,7 @@ pub fn create_requests(
|
|||
rng: &mut impl Rng,
|
||||
info_hashes: &[InfoHash],
|
||||
number: usize,
|
||||
) -> Vec<(AnnounceRequest, SocketAddr)> {
|
||||
) -> Vec<(AnnounceRequest, CanonicalSocketAddr)> {
|
||||
let pareto = Pareto::new(1., PARETO_SHAPE).unwrap();
|
||||
|
||||
let max_index = info_hashes.len() - 1;
|
||||
|
|
@ -106,7 +107,7 @@ pub fn create_requests(
|
|||
|
||||
requests.push((
|
||||
request,
|
||||
SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 1)),
|
||||
CanonicalSocketAddr::new(SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 1))),
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use aquatic_common::CanonicalSocketAddr;
|
||||
use crossbeam_channel::{Receiver, Sender};
|
||||
use indicatif::ProgressIterator;
|
||||
use rand::Rng;
|
||||
|
|
@ -14,8 +15,8 @@ use crate::config::BenchConfig;
|
|||
|
||||
pub fn bench_scrape_handler(
|
||||
bench_config: &BenchConfig,
|
||||
request_sender: &Sender<(SocketWorkerIndex, ConnectedRequest, SocketAddr)>,
|
||||
response_receiver: &Receiver<(ConnectedResponse, SocketAddr)>,
|
||||
request_sender: &Sender<(SocketWorkerIndex, ConnectedRequest, CanonicalSocketAddr)>,
|
||||
response_receiver: &Receiver<(ConnectedResponse, CanonicalSocketAddr)>,
|
||||
rng: &mut impl Rng,
|
||||
info_hashes: &[InfoHash],
|
||||
) -> (usize, Duration) {
|
||||
|
|
@ -91,7 +92,7 @@ pub fn create_requests(
|
|||
info_hashes: &[InfoHash],
|
||||
number: usize,
|
||||
hashes_per_request: usize,
|
||||
) -> Vec<(ScrapeRequest, SocketAddr)> {
|
||||
) -> Vec<(ScrapeRequest, CanonicalSocketAddr)> {
|
||||
let pareto = Pareto::new(1., PARETO_SHAPE).unwrap();
|
||||
|
||||
let max_index = info_hashes.len() - 1;
|
||||
|
|
@ -114,7 +115,7 @@ pub fn create_requests(
|
|||
|
||||
requests.push((
|
||||
request,
|
||||
SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 1)),
|
||||
CanonicalSocketAddr::new(SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 1))),
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue