Drop pub(crate) and use pub everywhere for now
This commit is contained in:
1 parent
214ffef6f3
commit
890b3f8c19
5 files changed
+48
-48
No files matched your search
+8
-8
@@ -9,17 +9,17 @@ use std::sync::{Arc, Mutex};
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct ReflectorStats {
|
||||
pub(crate) down_ewma: f64,
|
||||
pub(crate) up_ewma: f64,
|
||||
pub(crate) last_receive_time_s: f64,
|
||||
pub down_ewma: f64,
|
||||
pub up_ewma: f64,
|
||||
pub last_receive_time_s: f64,
|
||||
}
|
||||
|
||||
pub struct Baseliner {
|
||||
pub(crate) config: Config,
|
||||
pub(crate) owd_baseline: Arc<Mutex<HashMap<IpAddr, ReflectorStats>>>,
|
||||
pub(crate) owd_recent: Arc<Mutex<HashMap<IpAddr, ReflectorStats>>>,
|
||||
pub(crate) reselect_trigger: Sender<bool>,
|
||||
pub(crate) stats_receiver: Receiver<PingReply>,
|
||||
pub config: Config,
|
||||
pub owd_baseline: Arc<Mutex<HashMap<IpAddr, ReflectorStats>>>,
|
||||
pub owd_recent: Arc<Mutex<HashMap<IpAddr, ReflectorStats>>>,
|
||||
pub reselect_trigger: Sender<bool>,
|
||||
pub stats_receiver: Receiver<PingReply>,
|
||||
}
|
||||
|
||||
impl Baseliner {
|
||||
|
||||
+20
-20
@@ -54,31 +54,31 @@ impl FromStr for MeasurementType {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct Config {
|
||||
pub struct Config {
|
||||
// Network section
|
||||
pub(crate) download_interface: String,
|
||||
pub(crate) upload_interface: String,
|
||||
pub(crate) download_base_kbits: f64,
|
||||
pub(crate) download_min_kbits: f64,
|
||||
pub(crate) upload_base_kbits: f64,
|
||||
pub(crate) upload_min_kbits: f64,
|
||||
pub download_interface: String,
|
||||
pub upload_interface: String,
|
||||
pub download_base_kbits: f64,
|
||||
pub download_min_kbits: f64,
|
||||
pub upload_base_kbits: f64,
|
||||
pub upload_min_kbits: f64,
|
||||
|
||||
// Output section
|
||||
pub(crate) log_level: Level,
|
||||
pub(crate) speed_hist_file: String,
|
||||
pub(crate) stats_file: String,
|
||||
pub(crate) suppress_statistics: bool,
|
||||
pub log_level: Level,
|
||||
pub speed_hist_file: String,
|
||||
pub stats_file: String,
|
||||
pub suppress_statistics: bool,
|
||||
|
||||
// Advanced section
|
||||
pub(crate) download_delay_ms: f64,
|
||||
pub(crate) high_load_level: f64,
|
||||
pub(crate) min_change_interval: f64,
|
||||
pub(crate) measurement_type: MeasurementType,
|
||||
pub(crate) num_reflectors: u8,
|
||||
pub(crate) reflector_list_file: String,
|
||||
pub(crate) speed_hist_size: u32,
|
||||
pub(crate) tick_interval: f64,
|
||||
pub(crate) upload_delay_ms: f64,
|
||||
pub download_delay_ms: f64,
|
||||
pub high_load_level: f64,
|
||||
pub min_change_interval: f64,
|
||||
pub measurement_type: MeasurementType,
|
||||
pub num_reflectors: u8,
|
||||
pub reflector_list_file: String,
|
||||
pub speed_hist_size: u32,
|
||||
pub tick_interval: f64,
|
||||
pub upload_delay_ms: f64,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
|
||||
+10
-10
@@ -29,16 +29,16 @@ pub enum PingError {
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub struct PingReply {
|
||||
pub(crate) reflector: IpAddr,
|
||||
pub(crate) seq: u16,
|
||||
pub(crate) rtt: i64,
|
||||
pub(crate) current_time: i64,
|
||||
pub(crate) down_time: f64,
|
||||
pub(crate) up_time: f64,
|
||||
pub(crate) originate_timestamp: i64,
|
||||
pub(crate) receive_timestamp: i64,
|
||||
pub(crate) transmit_timestamp: i64,
|
||||
pub(crate) last_receive_time_s: f64,
|
||||
pub reflector: IpAddr,
|
||||
pub seq: u16,
|
||||
pub rtt: i64,
|
||||
pub current_time: i64,
|
||||
pub down_time: f64,
|
||||
pub up_time: f64,
|
||||
pub originate_timestamp: i64,
|
||||
pub receive_timestamp: i64,
|
||||
pub transmit_timestamp: i64,
|
||||
pub last_receive_time_s: f64,
|
||||
}
|
||||
|
||||
fn open_socket(type_: MeasurementType) -> nix::Result<RawFd> {
|
||||
|
||||
@@ -10,11 +10,11 @@ use std::thread::sleep;
|
||||
use std::time::Duration;
|
||||
|
||||
pub struct ReflectorSelector {
|
||||
pub(crate) config: Config,
|
||||
pub(crate) owd_recent: Arc<Mutex<HashMap<IpAddr, ReflectorStats>>>,
|
||||
pub(crate) reflector_peers_lock: Arc<RwLock<Vec<IpAddr>>>,
|
||||
pub(crate) reflector_pool: Vec<IpAddr>,
|
||||
pub(crate) trigger_channel: Receiver<bool>,
|
||||
pub config: Config,
|
||||
pub owd_recent: Arc<Mutex<HashMap<IpAddr, ReflectorStats>>>,
|
||||
pub reflector_peers_lock: Arc<RwLock<Vec<IpAddr>>>,
|
||||
pub reflector_pool: Vec<IpAddr>,
|
||||
pub trigger_channel: Receiver<bool>,
|
||||
}
|
||||
|
||||
impl ReflectorSelector {
|
||||
|
||||
+5
-5
@@ -11,24 +11,24 @@ pub enum UtilError {
|
||||
pub struct 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 };
|
||||
}
|
||||
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()
|
||||
}
|
||||
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)?;
|
||||
Ok((time.tv_sec() as f64, time.tv_nsec() as f64))
|
||||
}
|
||||
|
||||
#[cfg(target_endian = "big")]
|
||||
pub(crate) fn to_ne(val: u64) -> u64 {
|
||||
pub fn to_ne(val: u64) -> u64 {
|
||||
val.to_be()
|
||||
}
|
||||
|
||||
#[cfg(target_endian = "little")]
|
||||
pub(crate) fn to_ne(val: u32) -> u32 {
|
||||
pub fn to_ne(val: u32) -> u32 {
|
||||
val.to_le()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user