summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStuart Stock <stuart@int08h.com>2019-02-10 16:38:04 -0600
committerStuart Stock <stuart@int08h.com>2019-02-10 16:38:04 -0600
commit62e6dd64a276dbf8e10cbe6a4111f0cfb98d163f (patch)
tree727219fe93d5e59d7ec0231722b9c8d89e7d544e /src
parent7cb1f24a4822ea28db40ebb67d909802bb2bb440 (diff)
downloadroughenough-62e6dd64a276dbf8e10cbe6a4111f0cfb98d163f.zip
Generally improved log and error messages
Diffstat (limited to 'src')
-rw-r--r--src/bin/roughenough-server.rs40
-rw-r--r--src/config/mod.rs17
-rw-r--r--src/server.rs2
3 files changed, 28 insertions, 31 deletions
diff --git a/src/bin/roughenough-server.rs b/src/bin/roughenough-server.rs
index 88c8e83..b0b5819 100644
--- a/src/bin/roughenough-server.rs
+++ b/src/bin/roughenough-server.rs
@@ -45,29 +45,25 @@ macro_rules! check_ctrlc {
fn polling_loop(config: Box<ServerConfig>) {
let mut server = Server::new(config);
-
- info!("Long-term public key : {}", server.get_public_key());
- info!("Online public key : {}", server.get_online_key());
- info!(
- "Max response batch size : {}",
- server.get_config().batch_size()
- );
- info!(
- "Status updates every : {} seconds",
- server.get_config().status_interval().as_secs()
- );
- info!(
- "Server listening on : {}:{}",
- server.get_config().interface(),
- server.get_config().port()
+ let cfg = server.get_config(); // borrow config that was moved above
+
+ info!("Long-term public key : {}", server.get_public_key());
+ info!("Online public key : {}", server.get_online_key());
+ info!("Max response batch size : {}", cfg.batch_size());
+ info!("Status updates every : {} seconds", cfg.status_interval().as_secs());
+ info!("Server listening on : {}:{}", cfg.interface(), cfg.port());
+ if let Some(hc_port) = cfg.health_check_port() {
+ info!("TCP health check : {}:{}", cfg.interface(), hc_port);
+ } else {
+ info!("TCP health check : disabled");
+ }
+ info!("Client req/resp tracking : {}",
+ if cfg.client_stats_enabled() { "per-client" } else { "aggregated" }
);
-
- if let Some(hc_port) = server.get_config().health_check_port() {
- info!(
- "TCP health check : {}:{}",
- server.get_config().interface(),
- hc_port
- );
+ if cfg.fault_percentage() > 0 {
+ info!("Deliberate response errors : ~{}%", cfg.fault_percentage());
+ } else {
+ info!("Deliberate response errors : disabled");
}
let kr = server.get_keep_running();
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 263fcb4..70da38e 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -145,25 +145,26 @@ pub fn is_valid_config(cfg: &Box<dyn ServerConfig>) -> bool {
let mut is_valid = true;
if cfg.port() == 0 {
- error!("unset port: {}", cfg.port());
+ error!("server port not set: {}", cfg.port());
is_valid = false;
}
+
if cfg.interface().is_empty() {
- error!("interface is missing");
+ error!("'interface' is missing");
is_valid = false;
}
+
if cfg.seed().is_empty() {
- error!("seed value is missing");
+ error!("'seed' value is missing");
is_valid = false;
- }
- if *cfg.kms_protection() == KmsProtection::Plaintext && cfg.seed().len() != 32 {
- error!("plaintext seed value must be 32 characters long");
+ } else if *cfg.kms_protection() == KmsProtection::Plaintext && cfg.seed().len() != SEED_LENGTH as usize {
+ error!("plaintext seed value must be 32 characters long, found {}", cfg.seed().len());
is_valid = false;
- }
- if *cfg.kms_protection() != KmsProtection::Plaintext && cfg.seed().len() <= 32 {
+ } else if *cfg.kms_protection() != KmsProtection::Plaintext && cfg.seed().len() <= SEED_LENGTH as usize {
error!("KMS use enabled but seed value is too short to be an encrypted blob");
is_valid = false;
}
+
if cfg.batch_size() < 1 || cfg.batch_size() > 64 {
error!(
"batch_size {} is invalid; valid range 1-64",
diff --git a/src/server.rs b/src/server.rs
index 9f93b60..85411ce 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -219,7 +219,7 @@ impl Server {
pub fn process_events(&mut self, events: &mut Events) -> bool {
self.poll
.poll(events, self.poll_duration)
- .expect("poll failed");
+ .expect("server event poll failed; cannot recover");
for msg in events.iter() {
match msg.token() {