aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConrad Ludgate <conradludgate@gmail.com>2023-10-21 12:30:56 +0100
committerGitHub <noreply@github.com>2023-10-21 12:30:56 +0100
commitd202afeaf5e81532217b6e6227990cf52b507604 (patch)
tree3f3dfd870167eeec8021fc77a429803b99e95230
parentAdd fish support for `enter_accept` (#1315) (diff)
downloadatuin-d202afeaf5e81532217b6e6227990cf52b507604.zip
allow binding server to hostname (#1318)
-rw-r--r--atuin-server/src/lib.rs10
-rw-r--r--atuin/src/command/server.rs8
2 files changed, 6 insertions, 12 deletions
diff --git a/atuin-server/src/lib.rs b/atuin-server/src/lib.rs
index 007ad5c9..6778b099 100644
--- a/atuin-server/src/lib.rs
+++ b/atuin-server/src/lib.rs
@@ -1,9 +1,6 @@
#![forbid(unsafe_code)]
-use std::{
- future::Future,
- net::{IpAddr, SocketAddr, TcpListener},
-};
+use std::{future::Future, net::TcpListener};
use atuin_server_database::Database;
use axum::Server;
@@ -43,13 +40,12 @@ async fn shutdown_signal() {
pub async fn launch<Db: Database>(
settings: Settings<Db::Settings>,
- host: String,
+ host: &str,
port: u16,
) -> Result<()> {
- let host = host.parse::<IpAddr>()?;
launch_with_listener::<Db>(
settings,
- TcpListener::bind(SocketAddr::new(host, port)).context("could not connect to socket")?,
+ TcpListener::bind((host, port)).context("could not connect to socket")?,
shutdown_signal(),
)
.await
diff --git a/atuin/src/command/server.rs b/atuin/src/command/server.rs
index b56fde28..bfecdd75 100644
--- a/atuin/src/command/server.rs
+++ b/atuin/src/command/server.rs
@@ -37,12 +37,10 @@ impl Cmd {
match self {
Self::Start { host, port } => {
let settings = Settings::new().wrap_err("could not load server settings")?;
- let host = host
- .as_ref()
- .map_or(settings.host.clone(), std::string::ToString::to_string);
- let port = port.map_or(settings.port, |p| p);
+ let host = host.as_ref().unwrap_or(&settings.host).clone();
+ let port = port.unwrap_or(settings.port);
- launch::<Postgres>(settings, host, port).await
+ launch::<Postgres>(settings, &host, port).await
}
Self::DefaultConfig => {
println!("{}", example_config());