File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ use warp::http::{StatusCode, Uri};
99use rust_embed:: RustEmbed ;
1010use warp:: reply:: json;
1111use serde_json:: json;
12- use std:: net:: IpAddr ;
12+ use std:: net:: { IpAddr } ;
1313use structopt:: StructOpt ;
1414
1515#[ derive( RustEmbed ) ]
@@ -18,10 +18,10 @@ struct Static;
1818
1919#[ derive( Debug , StructOpt ) ]
2020struct Opt {
21- #[ structopt( long, default_value = "localhost " ) ]
21+ #[ structopt( long, default_value = "127.0.0.1" , help = "Bind to address ") ]
2222 host : String ,
2323
24- #[ structopt( long, default_value = "3030" ) ]
24+ #[ structopt( long, default_value = "3030" , help = "Bind to port" ) ]
2525 port : u16 ,
2626}
2727
@@ -77,9 +77,14 @@ async fn main() {
7777
7878 let opt = Opt :: from_args ( ) ;
7979
80- log:: info!( "Starting server on http://{}:{}" , opt. host, opt. port) ;
80+ let addr: IpAddr = opt. host . parse :: < IpAddr > ( ) . unwrap_or_else ( |_| {
81+ log:: error!( "Invalid IP address" ) ;
82+ std:: process:: exit ( 1 ) ;
83+ } ) ;
84+
85+ log:: info!( "Starting server on http://{}:{}" , addr, opt. port) ;
8186 warp:: serve ( iptables. or ( redirect) . or ( static_files) . or ( error) . with ( cors) )
82- . run ( ( opt . host . parse :: < IpAddr > ( ) . unwrap ( ) , opt. port ) )
87+ . run ( ( addr , opt. port ) )
8388 . await ;
8489
8590}
You can’t perform that action at this time.
0 commit comments