mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 18:25:30 +00:00
ws: remove pub visibility where not needed
This commit is contained in:
parent
193ad1689f
commit
66232df6d2
2 changed files with 12 additions and 12 deletions
|
|
@ -54,7 +54,7 @@ pub fn run(config: Config) -> ::anyhow::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_workers(config: Config, state: State) -> anyhow::Result<()> {
|
fn run_workers(config: Config, state: State) -> anyhow::Result<()> {
|
||||||
let num_peers = config.socket_workers + config.request_workers;
|
let num_peers = config.socket_workers + config.request_workers;
|
||||||
|
|
||||||
let request_mesh_builder = MeshBuilder::partial(num_peers, SHARED_IN_CHANNEL_SIZE);
|
let request_mesh_builder = MeshBuilder::partial(num_peers, SHARED_IN_CHANNEL_SIZE);
|
||||||
|
|
@ -150,7 +150,7 @@ pub fn run_workers(config: Config, state: State) -> anyhow::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_tls_config(config: &Config) -> anyhow::Result<rustls::ServerConfig> {
|
fn create_tls_config(config: &Config) -> anyhow::Result<rustls::ServerConfig> {
|
||||||
let certs = {
|
let certs = {
|
||||||
let f = File::open(&config.network.tls_certificate_path)?;
|
let f = File::open(&config.network.tls_certificate_path)?;
|
||||||
let mut f = BufReader::new(f);
|
let mut f = BufReader::new(f);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ use crate::config::Config;
|
||||||
use crate::SHARED_IN_CHANNEL_SIZE;
|
use crate::SHARED_IN_CHANNEL_SIZE;
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
|
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
|
||||||
pub enum PeerStatus {
|
enum PeerStatus {
|
||||||
Seeding,
|
Seeding,
|
||||||
Leeching,
|
Leeching,
|
||||||
Stopped,
|
Stopped,
|
||||||
|
|
@ -31,7 +31,7 @@ impl PeerStatus {
|
||||||
///
|
///
|
||||||
/// Likely, the last branch will be taken most of the time.
|
/// Likely, the last branch will be taken most of the time.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_event_and_bytes_left(event: AnnounceEvent, opt_bytes_left: Option<usize>) -> Self {
|
fn from_event_and_bytes_left(event: AnnounceEvent, opt_bytes_left: Option<usize>) -> Self {
|
||||||
if let AnnounceEvent::Stopped = event {
|
if let AnnounceEvent::Stopped = event {
|
||||||
Self::Stopped
|
Self::Stopped
|
||||||
} else if let Some(0) = opt_bytes_left {
|
} else if let Some(0) = opt_bytes_left {
|
||||||
|
|
@ -43,15 +43,15 @@ impl PeerStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct Peer {
|
struct Peer {
|
||||||
pub connection_meta: ConnectionMeta,
|
pub connection_meta: ConnectionMeta,
|
||||||
pub status: PeerStatus,
|
pub status: PeerStatus,
|
||||||
pub valid_until: ValidUntil,
|
pub valid_until: ValidUntil,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type PeerMap = AHashIndexMap<PeerId, Peer>;
|
type PeerMap = AHashIndexMap<PeerId, Peer>;
|
||||||
|
|
||||||
pub struct TorrentData {
|
struct TorrentData {
|
||||||
pub peers: PeerMap,
|
pub peers: PeerMap,
|
||||||
pub num_seeders: usize,
|
pub num_seeders: usize,
|
||||||
pub num_leechers: usize,
|
pub num_leechers: usize,
|
||||||
|
|
@ -68,16 +68,16 @@ impl Default for TorrentData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type TorrentMap = AHashIndexMap<InfoHash, TorrentData>;
|
type TorrentMap = AHashIndexMap<InfoHash, TorrentData>;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct TorrentMaps {
|
struct TorrentMaps {
|
||||||
pub ipv4: TorrentMap,
|
pub ipv4: TorrentMap,
|
||||||
pub ipv6: TorrentMap,
|
pub ipv6: TorrentMap,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TorrentMaps {
|
impl TorrentMaps {
|
||||||
pub fn clean(&mut self, config: &Config, access_list: &Arc<AccessListArcSwap>) {
|
fn clean(&mut self, config: &Config, access_list: &Arc<AccessListArcSwap>) {
|
||||||
let mut access_list_cache = create_access_list_cache(access_list);
|
let mut access_list_cache = create_access_list_cache(access_list);
|
||||||
|
|
||||||
Self::clean_torrent_map(config, &mut access_list_cache, &mut self.ipv4);
|
Self::clean_torrent_map(config, &mut access_list_cache, &mut self.ipv4);
|
||||||
|
|
@ -236,7 +236,7 @@ async fn handle_request_stream<S>(
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_announce_request(
|
fn handle_announce_request(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
rng: &mut SmallRng,
|
rng: &mut SmallRng,
|
||||||
torrent_maps: &mut TorrentMaps,
|
torrent_maps: &mut TorrentMaps,
|
||||||
|
|
@ -374,7 +374,7 @@ pub fn handle_announce_request(
|
||||||
out_messages.push((request_sender_meta, out_message));
|
out_messages.push((request_sender_meta, out_message));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_scrape_request(
|
fn handle_scrape_request(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
torrent_maps: &mut TorrentMaps,
|
torrent_maps: &mut TorrentMaps,
|
||||||
out_messages: &mut Vec<(ConnectionMeta, OutMessage)>,
|
out_messages: &mut Vec<(ConnectionMeta, OutMessage)>,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue