diff options
author | Aaron Hill <aa1ronham@gmail.com> | 2018-10-14 20:01:11 -0400 |
---|---|---|
committer | Aaron Hill <aa1ronham@gmail.com> | 2018-10-17 21:19:10 -0400 |
commit | 7df8c58cad6a99c84a66b00763d92aab61c190f7 (patch) | |
tree | 7d3966bbf00236534a2e43dddd888b2fe042ee52 /src | |
parent | f08fc14e801d386e4633fd098e3775986dfd13ca (diff) | |
download | roughenough-7df8c58cad6a99c84a66b00763d92aab61c190f7.zip |
More cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/server.rs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/server.rs b/src/server.rs index 17a58f0..e195d19 100644 --- a/src/server.rs +++ b/src/server.rs @@ -1,6 +1,4 @@ -use std::env; use std::io::ErrorKind; -use std::process; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::Arc; use std::time::Duration; @@ -15,13 +13,12 @@ use mio::net::UdpSocket; use mio::{Events, Poll, PollOpt, Ready, Token}; use mio_extras::timer::Timer; -use config; use config::ServerConfig; use kms; use key::{LongTermKey, OnlineKey}; use merkle::MerkleTree; use {Error, RtMessage, Tag}; -use {MIN_REQUEST_LENGTH, VERSION}; +use MIN_REQUEST_LENGTH; macro_rules! check_ctrlc { @@ -51,7 +48,6 @@ pub struct Server { num_bad_requests: u64, socket: UdpSocket, - fake_client_socket: UdpSocket, keep_running: Arc<AtomicBool>, poll_duration: Option<Duration>, timer: Timer<()>, @@ -62,12 +58,16 @@ pub struct Server { buf: [u8; 65_536], public_key: String, + + // Used to send requests to outselves in fuzing mode + #[cfg(fuzzing)] + fake_client_socket: UdpSocket, } impl Server { pub fn new(config: Box<ServerConfig>) -> Server { - let mut online_key = OnlineKey::new(); + let online_key = OnlineKey::new(); let public_key: String; let cert_bytes = { @@ -83,7 +83,6 @@ impl Server { let sock_addr = config.socket_addr().expect(""); let socket = UdpSocket::bind(&sock_addr).expect("failed to bind to socket"); - let fake_client_socket = UdpSocket::bind(&"127.0.0.1:0".parse().unwrap()).unwrap(); let poll_duration = Some(Duration::from_millis(100)); @@ -96,8 +95,8 @@ impl Server { //poll.register(&timer, STATUS, Ready::readable(), PollOpt::edge()) // .unwrap(); - let mut merkle = MerkleTree::new(); - let mut requests = Vec::with_capacity(config.batch_size() as usize); + let merkle = MerkleTree::new(); + let requests = Vec::with_capacity(config.batch_size() as usize); Server { @@ -108,7 +107,6 @@ impl Server { response_counter, num_bad_requests: 0, socket, - fake_client_socket, keep_running, poll_duration, timer, @@ -118,7 +116,11 @@ impl Server { requests, buf: [0u8; 65_536], - public_key + public_key, + + + #[cfg(fuzzing)] + fake_client_socket: UdpSocket::bind(&"127.0.0.1:0".parse().unwrap()).unwrap() } } |