summaryrefslogtreecommitdiff
path: root/src/config/mod.rs
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2018-10-14 20:23:45 -0400
committerAaron Hill <aa1ronham@gmail.com>2018-10-17 21:19:10 -0400
commit1f09d2797c4061e2f15146af061a24a71c1e10af (patch)
tree97371be709998131261839a0cce46e1304f467d3 /src/config/mod.rs
parent204cb428b38c119922ed596f27b3f36a6b33366f (diff)
downloadroughenough-1f09d2797c4061e2f15146af061a24a71c1e10af.zip
Add MemoryConfig
Diffstat (limited to 'src/config/mod.rs')
-rw-r--r--src/config/mod.rs27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs
index b70bbd5..658669a 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -34,6 +34,9 @@ pub use self::file::FileConfig;
mod environment;
pub use self::environment::EnvironmentConfig;
+mod memory;
+pub use self::memory::MemoryConfig;
+
use Error;
use key::KeyProtection;
@@ -89,7 +92,14 @@ pub trait ServerConfig {
fn key_protection(&self) -> &KeyProtection;
/// Convenience function to create a `SocketAddr` from the provided `interface` and `port`
- fn socket_addr(&self) -> Result<SocketAddr, Error>;
+ fn socket_addr(&self) -> Result<SocketAddr, Error> {
+ let addr = format!("{}:{}", self.interface(), self.port());
+ match addr.parse() {
+ Ok(v) => Ok(v),
+ Err(_) => Err(Error::InvalidConfiguration(addr)),
+ }
+
+ }
}
/// Factory function to create a `ServerConfig` _trait object_ based on the value
@@ -112,21 +122,6 @@ pub fn make_config(arg: &str) -> Result<Box<ServerConfig>, Error> {
}
}
-/// Creates a config suitable for fuzzing a server instance
-/// This is intended to create a minimal useable config
-/// that allows a server to respond to requests.
-#[cfg(fuzzing)]
-pub fn make_fuzzing_config(port: u16) -> Box<ServerConfig> {
- return Box(EnvironmentConfig {
- port,
- interface: "127.0.0.1".to_string(),
- seed: hex::decode("a32049da0ffde0ded92ce10a0230d35fe615ec8461c14986baa63fe3b3bac3db").unwrap(),
- batch_size: DEFAULT_BATCH_SIZE,
- status_interval: DEFAULT_STATUS_INTERVAL,
- key_protection: KeyProtection::Plaintext
- })
-}
-
///
/// Validate configuration settings. Returns `true` if the config is valid, `false` otherwise.
///