@@ -2,7 +2,7 @@ pub mod config;
22pub mod plugin;
33
44use std:: convert:: Infallible ;
5- use std:: net:: SocketAddr ;
5+ use std:: net:: { IpAddr , Ipv4Addr , SocketAddr } ;
66use std:: path:: PathBuf ;
77use std:: str:: FromStr ;
88use std:: sync:: Arc ;
@@ -14,6 +14,7 @@ use hyper::server::conn::http1;
1414use hyper:: { Method , Request , Response } ;
1515use hyper_util:: rt:: TokioIo ;
1616use hyper_util:: service:: TowerToHyperService ;
17+ use local_ip_address:: local_ip;
1718use tokio:: net:: TcpListener ;
1819use tokio:: runtime:: Runtime ;
1920use tower:: ServiceBuilder ;
@@ -22,6 +23,8 @@ use tower_http::cors::{Any, CorsLayer};
2223use self :: config:: Config ;
2324use self :: plugin:: ExternalFunctions ;
2425
26+ const ALL_INTERFACES_IPV4 : Ipv4Addr = Ipv4Addr :: new ( 0 , 0 , 0 , 0 ) ;
27+
2528pub struct Server {
2629 config : Config ,
2730}
@@ -39,6 +42,14 @@ impl Server {
3942 let config = PathBuf :: from_str ( "./config.toml" ) ?;
4043 let handle = Arc :: new ( rt. handle ( ) . to_owned ( ) ) ;
4144
45+ println ! ( "Listening on http://{}" , addr) ;
46+
47+ if matches ! ( addr. ip( ) , IpAddr :: V4 ( ALL_INTERFACES_IPV4 ) ) {
48+ if let Ok ( local_ip) = local_ip ( ) {
49+ println ! ( "Local Network on http://{}" , local_ip) ;
50+ }
51+ }
52+
4253 unsafe {
4354 functions
4455 . load ( Arc :: clone ( & handle) , config, plugin_library)
@@ -49,9 +60,6 @@ impl Server {
4960 let ( stream, _) = listener. accept ( ) . await ?;
5061 let io = TokioIo :: new ( stream) ;
5162 let functions = Arc :: clone ( & functions) ;
52-
53- println ! ( "{:#?}" , self . config) ;
54-
5563 let cors = if self . config . cors {
5664 Some (
5765 CorsLayer :: new ( )
0 commit comments