aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main.rs39
1 files changed, 24 insertions, 15 deletions
diff --git a/src/main.rs b/src/main.rs
index 36c5cf9..bee16bb 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -15,7 +15,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use phisher;
-use clap::{clap_app, crate_name, crate_authors, crate_version, crate_description};
+use clap::{ArgMatches, clap_app, crate_name, crate_authors, crate_version, crate_description};
use std::boxed::Box;
use std::error::Error;
use std::fs::{ File, remove_file };
@@ -29,20 +29,8 @@ use std::thread;
use std::time::SystemTime;
fn main() {
- // Set signal handler to clean up on termination.
- ctrlc::set_handler(move || {
- // We don't care about errors in remove_file.
- remove_file("/tmp/phisher").unwrap_or(());
- exit(0);
- }).expect("Couldn't set signal handler!");
-
- let args = clap_app!(app =>
- (name: crate_name!())
- (version: crate_version!())
- (author: crate_authors!())
- (about: crate_description!())
- (@arg PHISHTANK: --phishtank +required +takes_value "The phishtank json data file to use.")
- ).get_matches();
+ let args = get_args();
+ set_sig_handler();
let start_time = SystemTime::now();
let filename = args.value_of("PHISHTANK").unwrap();
@@ -63,6 +51,27 @@ fn main() {
}
}
+fn get_args() -> ArgMatches<'static> {
+ clap_app!(app =>
+ (name: crate_name!())
+ (version: crate_version!())
+ (author: crate_authors!())
+ (about: crate_description!())
+ (@arg PHISHTANK: --phishtank +required +takes_value
+ "The phishtank json data file to use.")
+ ).get_matches()
+}
+
+// Set signal handler to clean up on termination.
+//
+fn set_sig_handler() {
+ ctrlc::set_handler(move || {
+ // We don't care about errors in remove_file.
+ remove_file("/tmp/phisher").unwrap_or(());
+ exit(0);
+ }).expect("Couldn't set signal handler!");
+}
+
fn run_server(tank: Arc<phisher::PhishTank>) -> Result<(), Box<dyn Error>> {
let bind_address = "/tmp/phisher";
let listener = UnixListener::bind(&bind_address)?;