🏗️ Elegant & Highly Performant Async Gemini Server Framework for the Modern Age
async framework gemini-protocol protocol gemini rust
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(router): Add set_listener_address

Fuwn 56fc17cd b7b664c6

+31 -5
+31 -5
src/router.rs
··· 107 107 async_modules: Arc<AsyncMutex<Vec<Box<dyn AsyncModule + Send>>>>, 108 108 modules: Arc<Mutex<Vec<Box<dyn Module + Send>>>>, 109 109 fix_path: bool, 110 + listener_address: String, 110 111 } 111 112 112 113 impl Router { ··· 319 320 } 320 321 321 322 #[cfg(feature = "tokio")] 322 - let listener = 323 - tokio::net::TcpListener::bind(format!("0.0.0.0:{}", self.port)).await?; 323 + let listener = tokio::net::TcpListener::bind(format!( 324 + "{}:{}", 325 + self.listener_address, self.port 326 + )) 327 + .await?; 324 328 #[cfg(feature = "async-std")] 325 - let listener = 326 - async_std::net::TcpListener::bind(format!("0.0.0.0:{}", self.port)) 327 - .await?; 329 + let listener = async_std::net::TcpListener::bind(format!( 330 + "{}:{}", 331 + self.listener_address, self.port 332 + )) 333 + .await?; 328 334 329 335 #[cfg(feature = "logger")] 330 336 info!("windmark is listening for connections"); ··· 975 981 976 982 self 977 983 } 984 + 985 + /// Specify a custom listener address. 986 + /// 987 + /// Defaults to `"0.0.0.0"`. 988 + /// 989 + /// # Examples 990 + /// 991 + /// ```rust 992 + /// windmark::router::Router::new().set_listener_address("[::]"); 993 + /// ``` 994 + pub fn set_listener_address( 995 + &mut self, 996 + address: impl Into<String> + AsRef<str>, 997 + ) -> &mut Self { 998 + self.listener_address = address.into(); 999 + 1000 + self 1001 + } 978 1002 } 1003 + 979 1004 impl Default for Router { 980 1005 fn default() -> Self { 981 1006 Self { ··· 1010 1035 fix_path: false, 1011 1036 private_key_content: None, 1012 1037 certificate_content: None, 1038 + listener_address: "0.0.0.0".to_string(), 1013 1039 } 1014 1040 } 1015 1041 }