summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStuart Stock <stuart@int08h.com>2018-10-21 17:30:57 -0500
committerStuart Stock <stuart@int08h.com>2018-10-21 17:30:57 -0500
commit68788da97001f27702f5b9c7b2812dcab7bec24a (patch)
tree1f05a4ca7815e383705706ed758e10b81d068f03 /src
parent608e43e4843fef6081ce3cac2186e0291b73e0cb (diff)
downloadroughenough-68788da97001f27702f5b9c7b2812dcab7bec24a.zip
Changes to keep Clippy happy
Diffstat (limited to 'src')
-rw-r--r--src/bin/roughenough-client.rs29
-rw-r--r--src/bin/roughenough-kms.rs3
-rw-r--r--src/config/environment.rs10
-rw-r--r--src/config/file.rs2
-rw-r--r--src/merkle.rs2
-rw-r--r--src/message.rs3
-rw-r--r--src/server.rs8
-rw-r--r--src/tag.rs4
8 files changed, 32 insertions, 29 deletions
diff --git a/src/bin/roughenough-client.rs b/src/bin/roughenough-client.rs
index 570dc47..9318417 100644
--- a/src/bin/roughenough-client.rs
+++ b/src/bin/roughenough-client.rs
@@ -108,15 +108,16 @@ impl ResponseHandler {
.as_slice()
.read_u32::<LittleEndian>()
.unwrap();
- let mut verified = false;
- if self.pub_key.is_some() {
+ let verified = if self.pub_key.is_some() {
self.validate_dele();
self.validate_srep();
self.validate_merkle();
self.validate_midpoint(midpoint);
- verified = true;
- }
+ true
+ } else {
+ false
+ };
ParsedResponse {
verified,
@@ -161,11 +162,7 @@ impl ResponseHandler {
let hash = root_from_paths(index as usize, &self.nonce, paths);
- assert_eq!(
- Vec::from(hash),
- srep[&Tag::ROOT],
- "Nonce not in merkle tree!"
- );
+ assert_eq!(hash, srep[&Tag::ROOT], "Nonce not in merkle tree!");
}
fn validate_midpoint(&self, midpoint: u64) {
@@ -180,11 +177,13 @@ impl ResponseHandler {
assert!(
midpoint >= mint,
- "Response midpoint {} lies before delegation span ({}, {})"
+ "Response midpoint {} lies before delegation span ({}, {})",
+ midpoint, mint, maxt
);
assert!(
midpoint <= maxt,
- "Response midpoint {} lies after delegation span ({}, {})"
+ "Response midpoint {} lies after delegation span ({}, {})",
+ midpoint, mint, maxt
);
}
@@ -279,13 +278,15 @@ fn main() {
let nonce = create_nonce();
let mut socket = UdpSocket::bind("0.0.0.0:0").expect("Couldn't open UDP socket");
let request = make_request(&nonce);
- file.as_mut()
- .map(|f| f.write_all(&request).expect("Failed to write to file!"));
+
+ if let Some(f) = file.as_mut() {
+ f.write_all(&request).expect("Failed to write to file!")
+ }
requests.push((nonce, request, socket));
}
- for &mut (_, ref request, ref mut socket) in requests.iter_mut() {
+ for &mut (_, ref request, ref mut socket) in &mut requests {
socket.send_to(request, addr).unwrap();
}
diff --git a/src/bin/roughenough-kms.rs b/src/bin/roughenough-kms.rs
index 8b3b26a..389d076 100644
--- a/src/bin/roughenough-kms.rs
+++ b/src/bin/roughenough-kms.rs
@@ -108,6 +108,7 @@ pub fn main() {
#[cfg(feature = "gcpkms")]
gcp_kms(kms_key, &plaintext_seed);
} else {
- warn!("KMS support is not enabled, nothing to do");
+ warn!("KMS support was not compiled, nothing to do.");
+ warn!("For information on KMS support see the Roughenough documentation.");
}
}
diff --git a/src/config/environment.rs b/src/config/environment.rs
index 5edb6d0..d051d6d 100644
--- a/src/config/environment.rs
+++ b/src/config/environment.rs
@@ -65,7 +65,7 @@ impl EnvironmentConfig {
if let Ok(port) = env::var(ROUGHENOUGH_PORT) {
cfg.port = port
.parse()
- .expect(format!("invalid port: {}", port).as_ref());
+ .unwrap_or_else(|_| panic!("invalid port: {}", port));
};
if let Ok(interface) = env::var(ROUGHENOUGH_INTERFACE) {
@@ -80,21 +80,21 @@ impl EnvironmentConfig {
if let Ok(batch_size) = env::var(ROUGHENOUGH_BATCH_SIZE) {
cfg.batch_size = batch_size
.parse()
- .expect(format!("invalid batch_size: {}", batch_size).as_ref());
+ .unwrap_or_else(|_| panic!("invalid batch_size: {}", batch_size));
};
if let Ok(status_interval) = env::var(ROUGHENOUGH_STATUS_INTERVAL) {
let val: u16 = status_interval
.parse()
- .expect(format!("invalid status_interval: {}", status_interval).as_ref());
+ .unwrap_or_else(|_| panic!("invalid status_interval: {}", status_interval));
- cfg.status_interval = Duration::from_secs(val as u64);
+ cfg.status_interval = Duration::from_secs(u64::from(val));
};
if let Ok(key_protection) = env::var(ROUGHENOUGH_KEY_PROTECTION) {
cfg.key_protection = key_protection
.parse()
- .expect(format!("invalid key_protection value: {}", key_protection).as_ref());
+ .unwrap_or_else(|_| panic!("invalid key_protection value: {}", key_protection));
}
Ok(cfg)
diff --git a/src/config/file.rs b/src/config/file.rs
index b0f8b4d..b1e856b 100644
--- a/src/config/file.rs
+++ b/src/config/file.rs
@@ -90,7 +90,7 @@ impl FileConfig {
.as_str()
.unwrap()
.parse()
- .expect(format!("invalid key_protection value: {:?}", value).as_ref());
+ .unwrap_or_else(|_| panic!("invalid key_protection value: {:?}", value));
config.key_protection = val
}
unknown => {
diff --git a/src/merkle.rs b/src/merkle.rs
index e34a5b4..69e6c00 100644
--- a/src/merkle.rs
+++ b/src/merkle.rs
@@ -62,7 +62,7 @@ impl MerkleTree {
pub fn compute_root(&mut self) -> Hash {
assert!(
- self.levels[0].len() > 0,
+ !self.levels[0].is_empty(),
"Must have at least one leaf to hash!"
);
diff --git a/src/message.rs b/src/message.rs
index bd11bf7..429a5e5 100644
--- a/src/message.rs
+++ b/src/message.rs
@@ -192,7 +192,8 @@ impl RtMessage {
return Some(&self.values[i]);
}
}
- return None;
+
+ None
}
/// Returns the number of tag/value pairs in the message
diff --git a/src/server.rs b/src/server.rs
index 26f9428..a187508 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -155,7 +155,7 @@ impl Server {
/// Returns a reference counted pointer the this server's `keep_running` value.
pub fn get_keep_running(&self) -> Arc<AtomicBool> {
- return self.keep_running.clone();
+ self.keep_running.clone()
}
// extract the client's nonce from its request
@@ -316,17 +316,17 @@ impl Server {
/// Returns a reference to the server's long-term public key
pub fn get_public_key(&self) -> &str {
- return &self.public_key;
+ &self.public_key
}
/// Returns a reference to the server's on-line (delegated) key
pub fn get_online_key(&self) -> &OnlineKey {
- return &self.online_key;
+ &self.online_key
}
/// Returns a reference to the `ServerConfig` this server was configured with
pub fn get_config(&self) -> &Box<ServerConfig> {
- return &self.config;
+ &self.config
}
#[cfg(fuzzing)]
diff --git a/src/tag.rs b/src/tag.rs
index 7996663..14d6b04 100644
--- a/src/tag.rs
+++ b/src/tag.rs
@@ -40,8 +40,8 @@ pub enum Tag {
impl Tag {
/// Translates a tag into its on-the-wire representation
- pub fn wire_value(&self) -> &'static [u8] {
- match *self {
+ pub fn wire_value(self) -> &'static [u8] {
+ match self {
Tag::CERT => b"CERT",
Tag::DELE => b"DELE",
Tag::INDX => b"INDX",