aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHristo Venev <hristo@venev.name>2019-09-30 14:54:09 +0300
committerHristo Venev <hristo@venev.name>2019-09-30 15:34:34 +0300
commite7e12e4c27ba462a9f8e6ec15373d00c3d72bb24 (patch)
tree67ac67cdb3c7cc6fa9db8b097f9be3db4cbaebd9
parent5cd9be6edd6cfc6f492907709eb1cfda4a99923f (diff)
Lowercase errors.
-rw-r--r--src/fileutil.rs2
-rw-r--r--src/manager/builder.rs16
-rw-r--r--src/manager/mod.rs22
-rw-r--r--src/wg.rs6
4 files changed, 29 insertions, 17 deletions
diff --git a/src/fileutil.rs b/src/fileutil.rs
index d00575b..c124fae 100644
--- a/src/fileutil.rs
+++ b/src/fileutil.rs
@@ -18,7 +18,7 @@ impl Drop for Temp {
if self.path.as_os_str().is_empty() {
return;
}
- fs::remove_file(&self.path).expect("Failed to clean up temporary file");
+ fs::remove_file(&self.path).expect("failed to clean up temporary file");
}
}
diff --git a/src/manager/builder.rs b/src/manager/builder.rs
index 037d2a9..9580d07 100644
--- a/src/manager/builder.rs
+++ b/src/manager/builder.rs
@@ -38,9 +38,9 @@ impl fmt::Display for Error {
f,
"{} [{}]/[{}]: {}",
if self.important {
- "Invalid peer"
+ "invalid peer"
} else {
- "Misconfigured peer"
+ "misconfigured peer"
},
self.src,
self.peer,
@@ -108,7 +108,7 @@ impl<'a> ConfigBuilder<'a> {
if p.peer.public_key == self.public_key {
self.err.push(Error::new(
- "The local peer cannot be a road warrior",
+ "the local peer cannot be a road warrior",
src,
&p.peer,
true,
@@ -122,7 +122,7 @@ impl<'a> ConfigBuilder<'a> {
ent
} else {
self.err
- .push(Error::new("Unknown base peer", src, &p.peer, true));
+ .push(Error::new("unknown base peer", src, &p.peer, true));
return;
};
add_peer(&mut self.err, ent, src, &p.peer)
@@ -140,7 +140,7 @@ fn insert_peer<'b>(
) -> &'b mut model::Peer {
match c.peers.entry(p.public_key) {
hash_map::Entry::Occupied(ent) => {
- err.push(Error::new("Duplicate public key", src, p, true));
+ err.push(Error::new("duplicate public key", src, p, true));
ent.into_mut()
}
hash_map::Entry::Vacant(ent) => {
@@ -169,7 +169,7 @@ fn find_psk<'a>(
if let Some(ref want_src) = &want.source {
if *want_src != src.name {
- return Err(Error::new("Peer source not allowed", src, p, true));
+ return Err(Error::new("peer source not allowed", src, p, true));
}
}
@@ -199,9 +199,9 @@ fn add_peer(err: &mut Vec<Error>, ent: &mut model::Peer, src: &Source, p: &proto
if removed {
let msg = if added {
- "Some IPs removed"
+ "some IPs removed"
} else {
- "All IPs removed"
+ "all IPs removed"
};
err.push(Error::new(msg, src, p, !added));
}
diff --git a/src/manager/mod.rs b/src/manager/mod.rs
index 0d180a6..20ec061 100644
--- a/src/manager/mod.rs
+++ b/src/manager/mod.rs
@@ -33,7 +33,7 @@ pub struct Manager {
impl Manager {
pub fn new(ifname: OsString, c: config::Config) -> io::Result<Self> {
let runtime_directory = c.runtime_directory.ok_or_else(|| {
- io::Error::new(io::ErrorKind::InvalidInput, "Runtime directory required")
+ io::Error::new(io::ErrorKind::InvalidInput, "runtime directory required")
})?;
let mut state_path = runtime_directory.clone();
state_path.push("state.json");
@@ -122,7 +122,7 @@ impl Manager {
}
Err(io::Error::new(
io::ErrorKind::Other,
- format!("Failed to update required source [{}]", &s.config.url),
+ format!("failed to update required source [{}]", &s.config.url),
))
}
@@ -196,9 +196,21 @@ impl Manager {
let t_cfg = now + time_to_cfg;
if config != self.current {
- eprintln!("<5>Applying configuration update");
- for err in &errors {
- eprintln!("<{}>{}", if err.important() { '4' } else { '5' }, err);
+ if errors.is_empty() {
+ eprintln!("<5>Applying configuration update");
+ } else {
+ eprint!(
+ "<{}>New update contains errors: ",
+ if errors.iter().any(|err| err.important()) {
+ '4'
+ } else {
+ '5'
+ }
+ );
+ for err in &errors {
+ eprint!("{}; ", err);
+ }
+ eprintln!("applying anyway");
}
self.dev.apply_diff(&self.current, &config)?;
self.current_update(&config);
diff --git a/src/wg.rs b/src/wg.rs
index c210974..6a13d4e 100644
--- a/src/wg.rs
+++ b/src/wg.rs
@@ -44,7 +44,7 @@ impl Device {
let r = proc.output()?;
if !r.status.success() {
- return Err(io::Error::new(io::ErrorKind::Other, "Child process failed"));
+ return Err(io::Error::new(io::ErrorKind::Other, "child process failed"));
}
let mut out = r.stdout;
@@ -52,7 +52,7 @@ impl Device {
out.remove(out.len() - 1);
}
model::Key::from_bytes(&out)
- .map_err(|_| io::Error::new(io::ErrorKind::InvalidData, "Invalid public key"))
+ .map_err(|_| io::Error::new(io::ErrorKind::InvalidData, "invalid public key"))
}
pub fn apply_diff(&mut self, old: &model::Config, new: &model::Config) -> io::Result<()> {
@@ -133,7 +133,7 @@ impl Device {
let r = proc.status()?;
mem::drop(tmps);
if !r.success() {
- return Err(io::Error::new(io::ErrorKind::Other, "Child process failed"));
+ return Err(io::Error::new(io::ErrorKind::Other, "child process failed"));
}
Ok(())
}