Drop pub(crate) and use pub everywhere for now

This commit is contained in:
Nils Andreas Svee committed 2022-10-04 16:25:42 +02:00
1 parent 214ffef6f3
commit 890b3f8c19
5 files changed
+48 -48

No files matched your search

+8 -8
View File
@@ -9,17 +9,17 @@ use std::sync::{Arc, Mutex};
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct ReflectorStats { pub struct ReflectorStats {
pub(crate) down_ewma: f64, pub down_ewma: f64,
pub(crate) up_ewma: f64, pub up_ewma: f64,
pub(crate) last_receive_time_s: f64, pub last_receive_time_s: f64,
} }
pub struct Baseliner { pub struct Baseliner {
pub(crate) config: Config, pub config: Config,
pub(crate) owd_baseline: Arc<Mutex<HashMap<IpAddr, ReflectorStats>>>, pub owd_baseline: Arc<Mutex<HashMap<IpAddr, ReflectorStats>>>,
pub(crate) owd_recent: Arc<Mutex<HashMap<IpAddr, ReflectorStats>>>, pub owd_recent: Arc<Mutex<HashMap<IpAddr, ReflectorStats>>>,
pub(crate) reselect_trigger: Sender<bool>, pub reselect_trigger: Sender<bool>,
pub(crate) stats_receiver: Receiver<PingReply>, pub stats_receiver: Receiver<PingReply>,
} }
impl Baseliner { impl Baseliner {
+20 -20
View File
@@ -54,31 +54,31 @@ impl FromStr for MeasurementType {
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub(crate) struct Config { pub struct Config {
// Network section // Network section
pub(crate) download_interface: String, pub download_interface: String,
pub(crate) upload_interface: String, pub upload_interface: String,
pub(crate) download_base_kbits: f64, pub download_base_kbits: f64,
pub(crate) download_min_kbits: f64, pub download_min_kbits: f64,
pub(crate) upload_base_kbits: f64, pub upload_base_kbits: f64,
pub(crate) upload_min_kbits: f64, pub upload_min_kbits: f64,
// Output section // Output section
pub(crate) log_level: Level, pub log_level: Level,
pub(crate) speed_hist_file: String, pub speed_hist_file: String,
pub(crate) stats_file: String, pub stats_file: String,
pub(crate) suppress_statistics: bool, pub suppress_statistics: bool,
// Advanced section // Advanced section
pub(crate) download_delay_ms: f64, pub download_delay_ms: f64,
pub(crate) high_load_level: f64, pub high_load_level: f64,
pub(crate) min_change_interval: f64, pub min_change_interval: f64,
pub(crate) measurement_type: MeasurementType, pub measurement_type: MeasurementType,
pub(crate) num_reflectors: u8, pub num_reflectors: u8,
pub(crate) reflector_list_file: String, pub reflector_list_file: String,
pub(crate) speed_hist_size: u32, pub speed_hist_size: u32,
pub(crate) tick_interval: f64, pub tick_interval: f64,
pub(crate) upload_delay_ms: f64, pub upload_delay_ms: f64,
} }
impl Config { impl Config {
+10 -10
View File
@@ -29,16 +29,16 @@ pub enum PingError {
#[allow(dead_code)] #[allow(dead_code)]
pub struct PingReply { pub struct PingReply {
pub(crate) reflector: IpAddr, pub reflector: IpAddr,
pub(crate) seq: u16, pub seq: u16,
pub(crate) rtt: i64, pub rtt: i64,
pub(crate) current_time: i64, pub current_time: i64,
pub(crate) down_time: f64, pub down_time: f64,
pub(crate) up_time: f64, pub up_time: f64,
pub(crate) originate_timestamp: i64, pub originate_timestamp: i64,
pub(crate) receive_timestamp: i64, pub receive_timestamp: i64,
pub(crate) transmit_timestamp: i64, pub transmit_timestamp: i64,
pub(crate) last_receive_time_s: f64, pub last_receive_time_s: f64,
} }
fn open_socket(type_: MeasurementType) -> nix::Result<RawFd> { fn open_socket(type_: MeasurementType) -> nix::Result<RawFd> {
+5 -5
View File
@@ -10,11 +10,11 @@ use std::thread::sleep;
use std::time::Duration; use std::time::Duration;
pub struct ReflectorSelector { pub struct ReflectorSelector {
pub(crate) config: Config, pub config: Config,
pub(crate) owd_recent: Arc<Mutex<HashMap<IpAddr, ReflectorStats>>>, pub owd_recent: Arc<Mutex<HashMap<IpAddr, ReflectorStats>>>,
pub(crate) reflector_peers_lock: Arc<RwLock<Vec<IpAddr>>>, pub reflector_peers_lock: Arc<RwLock<Vec<IpAddr>>>,
pub(crate) reflector_pool: Vec<IpAddr>, pub reflector_pool: Vec<IpAddr>,
pub(crate) trigger_channel: Receiver<bool>, pub trigger_channel: Receiver<bool>,
} }
impl ReflectorSelector { impl ReflectorSelector {
+5 -5
View File
@@ -11,24 +11,24 @@ pub enum UtilError {
pub struct Utils {} pub struct Utils {}
impl Utils { impl Utils {
pub(crate) fn a_else_b(a: f64, b: f64) -> f64 { pub fn a_else_b(a: f64, b: f64) -> f64 {
return if a > 0.0 { a } else { b }; return if a > 0.0 { a } else { b };
} }
pub(crate) fn ewma_factor(tick: f64, dur: f64) -> f64 { pub fn ewma_factor(tick: f64, dur: f64) -> f64 {
((0.5_f64).ln() / (dur / tick)).exp() ((0.5_f64).ln() / (dur / tick)).exp()
} }
pub(crate) fn get_current_time() -> Result<(f64, f64), UtilError> { pub fn get_current_time() -> Result<(f64, f64), UtilError> {
let time = clock_gettime(ClockId::CLOCK_MONOTONIC)?; let time = clock_gettime(ClockId::CLOCK_MONOTONIC)?;
Ok((time.tv_sec() as f64, time.tv_nsec() as f64)) Ok((time.tv_sec() as f64, time.tv_nsec() as f64))
} }
#[cfg(target_endian = "big")] #[cfg(target_endian = "big")]
pub(crate) fn to_ne(val: u64) -> u64 { pub fn to_ne(val: u64) -> u64 {
val.to_be() val.to_be()
} }
#[cfg(target_endian = "little")] #[cfg(target_endian = "little")]
pub(crate) fn to_ne(val: u32) -> u32 { pub fn to_ne(val: u32) -> u32 {
val.to_le() val.to_le()
} }
} }