Fix minor clippy issues #19
No files matched your search
+2
-2
@@ -43,13 +43,13 @@ impl FromStr for MeasurementType {
|
|||||||
type Err = ConfigError;
|
type Err = ConfigError;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
return match s.to_lowercase().as_str() {
|
match s.to_lowercase().as_str() {
|
||||||
"icmp" => Ok(MeasurementType::Icmp),
|
"icmp" => Ok(MeasurementType::Icmp),
|
||||||
"icmp-timestamps" => Ok(MeasurementType::IcmpTimestamps),
|
"icmp-timestamps" => Ok(MeasurementType::IcmpTimestamps),
|
||||||
"ntp" => Ok(MeasurementType::Ntp),
|
"ntp" => Ok(MeasurementType::Ntp),
|
||||||
"tcp-timestamps" => Ok(MeasurementType::TcpTimestamps),
|
"tcp-timestamps" => Ok(MeasurementType::TcpTimestamps),
|
||||||
&_ => Err(ConfigError::InvalidMeasurementType(s.to_string())),
|
&_ => Err(ConfigError::InvalidMeasurementType(s.to_string())),
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -226,7 +226,7 @@ impl Netlink {
|
|||||||
|
|
||||||
if _type.eq(type_to_look_for) {
|
if _type.eq(type_to_look_for) {
|
||||||
let qdisc = Qdisc {
|
let qdisc = Qdisc {
|
||||||
ifindex: p.tcm_ifindex as i32,
|
ifindex: p.tcm_ifindex,
|
||||||
parent: p.tcm_parent,
|
parent: p.tcm_parent,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -133,12 +133,12 @@ pub trait PingSender {
|
|||||||
for reflector in reflectors.iter() {
|
for reflector in reflectors.iter() {
|
||||||
let addr: SockAddr = match reflector.is_ipv4() {
|
let addr: SockAddr = match reflector.is_ipv4() {
|
||||||
true => {
|
true => {
|
||||||
let ip4 = Ipv4Addr::from_str(&*reflector.to_string()).unwrap();
|
let ip4 = Ipv4Addr::from_str(&reflector.to_string()).unwrap();
|
||||||
let sock4 = SocketAddrV4::new(ip4, 0);
|
let sock4 = SocketAddrV4::new(ip4, 0);
|
||||||
sock4.into()
|
sock4.into()
|
||||||
}
|
}
|
||||||
false => {
|
false => {
|
||||||
let ip6 = Ipv6Addr::from_str(&*reflector.to_string()).unwrap();
|
let ip6 = Ipv6Addr::from_str(&reflector.to_string()).unwrap();
|
||||||
let sock6 = SocketAddrV6::new(ip6, 0, 0, 0);
|
let sock6 = SocketAddrV6::new(ip6, 0, 0, 0);
|
||||||
sock6.into()
|
sock6.into()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -318,6 +318,7 @@ impl Ratecontroller {
|
|||||||
speed_hist_fd_inner = File::options()
|
speed_hist_fd_inner = File::options()
|
||||||
.create(true)
|
.create(true)
|
||||||
.write(true)
|
.write(true)
|
||||||
|
.truncate(true)
|
||||||
.open(self.config.speed_hist_file.as_str())?;
|
.open(self.config.speed_hist_file.as_str())?;
|
||||||
|
|
||||||
speed_hist_fd_inner.write_all("time,counter,upspeed,downspeed\n".as_bytes())?;
|
speed_hist_fd_inner.write_all("time,counter,upspeed,downspeed\n".as_bytes())?;
|
||||||
@@ -328,6 +329,7 @@ impl Ratecontroller {
|
|||||||
stats_fd_inner = File::options()
|
stats_fd_inner = File::options()
|
||||||
.create(true)
|
.create(true)
|
||||||
.write(true)
|
.write(true)
|
||||||
|
.truncate(true)
|
||||||
.open(self.config.stats_file.as_str())?;
|
.open(self.config.stats_file.as_str())?;
|
||||||
|
|
||||||
stats_fd_inner.write_all(
|
stats_fd_inner.write_all(
|
||||||
@@ -348,11 +350,6 @@ impl Ratecontroller {
|
|||||||
|
|
||||||
(self.state_dl.current_bytes, self.state_ul.current_bytes) =
|
(self.state_dl.current_bytes, self.state_ul.current_bytes) =
|
||||||
get_interface_stats(&self.config, self.down_direction, self.up_direction)?;
|
get_interface_stats(&self.config, self.down_direction, self.up_direction)?;
|
||||||
if self.state_dl.current_bytes == -1 || self.state_ul.current_bytes == -1 {
|
|
||||||
warn!(
|
|
||||||
"One or both Netlink stats could not be read. Skipping rate control algorithm");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.update_deltas();
|
self.update_deltas();
|
||||||
self.calculate_rate(Direction::Down)?;
|
self.calculate_rate(Direction::Down)?;
|
||||||
|
|||||||
@@ -52,13 +52,13 @@ impl ReflectorSelector {
|
|||||||
|
|
||||||
// Include all current peers
|
// Include all current peers
|
||||||
for reflector in reflectors_peers.iter() {
|
for reflector in reflectors_peers.iter() {
|
||||||
debug!("Current peer: {}", reflector.to_string());
|
debug!("Current peer: {}", reflector);
|
||||||
next_peers.push(*reflector);
|
next_peers.push(*reflector);
|
||||||
}
|
}
|
||||||
|
|
||||||
for _ in 1..20 {
|
for _ in 1..20 {
|
||||||
let next_candidate = self.reflector_pool.choose(&mut rng).unwrap();
|
let next_candidate = self.reflector_pool.choose(&mut rng).unwrap();
|
||||||
debug!("Next candidate: {}", next_candidate.to_string());
|
debug!("Next candidate: {}", next_candidate);
|
||||||
next_peers.push(*next_candidate);
|
next_peers.push(*next_candidate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,12 +84,9 @@ impl ReflectorSelector {
|
|||||||
if owd_recent.contains_key(&peer) {
|
if owd_recent.contains_key(&peer) {
|
||||||
let rtt = (owd_recent[&peer].down_ewma + owd_recent[&peer].up_ewma) as u64;
|
let rtt = (owd_recent[&peer].down_ewma + owd_recent[&peer].up_ewma) as u64;
|
||||||
candidates.push((peer, rtt));
|
candidates.push((peer, rtt));
|
||||||
info!("Candidate reflector: {} RTT: {}", peer.to_string(), rtt);
|
info!("Candidate reflector: {} RTT: {}", peer, rtt);
|
||||||
} else {
|
} else {
|
||||||
info!(
|
info!("No data found from candidate reflector: {} - skipping", peer);
|
||||||
"No data found from candidate reflector: {} - skipping",
|
|
||||||
peer.to_string()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +96,9 @@ impl ReflectorSelector {
|
|||||||
// Now we will just limit the candidates down to 2 * num_reflectors
|
// Now we will just limit the candidates down to 2 * num_reflectors
|
||||||
let mut num_reflectors = self.config.num_reflectors;
|
let mut num_reflectors = self.config.num_reflectors;
|
||||||
let candidate_pool_num = (2 * num_reflectors) as usize;
|
let candidate_pool_num = (2 * num_reflectors) as usize;
|
||||||
candidates = candidates[0..candidate_pool_num - 1].to_vec();
|
if candidates.len() > candidate_pool_num {
|
||||||
|
candidates.truncate(candidate_pool_num);
|
||||||
|
}
|
||||||
|
|
||||||
for (candidate, rtt) in candidates.iter() {
|
for (candidate, rtt) in candidates.iter() {
|
||||||
info!("Fastest candidate {}: {}", candidate, rtt);
|
info!("Fastest candidate {}: {}", candidate, rtt);
|
||||||
@@ -118,10 +117,7 @@ impl ReflectorSelector {
|
|||||||
let mut new_peers = Vec::new();
|
let mut new_peers = Vec::new();
|
||||||
for i in 0..num_reflectors {
|
for i in 0..num_reflectors {
|
||||||
new_peers.push(candidates[i as usize].0);
|
new_peers.push(candidates[i as usize].0);
|
||||||
info!(
|
info!("New selected peer: {}", candidates[i as usize].0);
|
||||||
"New selected peer: {}",
|
|
||||||
candidates[i as usize].0.to_string()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*reflectors_peers = new_peers;
|
*reflectors_peers = new_peers;
|
||||||
|
|||||||
Reference in new issue
Block a user