From 18a3e9e240249a2a753df6dc8ca207c3e7090ea5 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 16 Aug 2018 01:50:00 +0000 Subject: [PATCH] actually listen to the bind address --- src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 21b23c2..2d35fa5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,7 +17,9 @@ pub mod handler; pub mod hook; use std::collections::HashMap; +use std::net::SocketAddrV4; use std::path::{Path, PathBuf}; +use std::str::FromStr; use std::sync::{mpsc, Mutex}; use std::thread; use std::time::Duration; @@ -180,9 +182,8 @@ pub fn run(config: &Config) -> Result<(), Error> { let v = config.root.clone(); thread::spawn(|| watch(v)); - let addr = ([127, 0, 0, 1], 3000).into(); - - let server = Server::bind(&addr) + let addr: SocketAddrV4 = SocketAddrV4::from_str(config.bind.as_ref())?; + let server = Server::bind(&addr.into()) .serve(|| service_fn_ok(service_fn_wrapper)) .map_err(|e| eprintln!("server error: {}", e)); println!("Listening on {:?}", addr);