summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeuin <[email protected]>2022-03-28 21:10:59 +0800
committerKeuin <[email protected]>2022-03-28 21:10:59 +0800
commit46b838656a9cd4725c6b1cc58f5be55097a4ac58 (patch)
tree4ae4e07bbfe814f3f8dbf853d78f3fdc734513b6
parent3c8531e8a4d3a23c2f4f3875bc30d2cbe103ec47 (diff)
Bugfix: Specify `localhost` listen endpoint will cause a panic.v0.5.1
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--src/main.rs8
3 files changed, 8 insertions, 4 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 7bfb59e..c61a8d6 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -829,7 +829,7 @@ dependencies = [
[[package]]
name = "kimikuri_rs"
-version = "0.5.0"
+version = "0.5.1"
dependencies = [
"bs58",
"futures",
diff --git a/Cargo.toml b/Cargo.toml
index 84bd6d3..1d54179 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "kimikuri_rs"
-version = "0.5.0"
+version = "0.5.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
diff --git a/src/main.rs b/src/main.rs
index e85b74e..d54a97c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,7 +1,7 @@
use std::{io, path};
use std::collections::HashMap;
use std::convert::Infallible;
-use std::net::SocketAddr;
+use std::net::{SocketAddr, ToSocketAddrs};
use std::str::FromStr;
use teloxide::prelude2::*;
@@ -104,7 +104,11 @@ async fn main() {
info!("Starting HTTP server...");
let endpoint: SocketAddr = config.listen.parse()
- .expect("Cannot parse `listen` as endpoint.");
+ .unwrap_or_else(|_| config.listen
+ .to_socket_addrs()
+ .expect("Cannot resolve endpoint.")
+ .next()
+ .expect("Cannot resolve endpoint."));
info!("Start listening on {}", endpoint);
tokio::spawn(warp::serve(routes).run(endpoint));