Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,13 @@ async fn run(
spacebot::update::spawn_update_checker(api_state.update_status.clone());

let _http_handle = if config.api.enabled {
let bind: std::net::SocketAddr = format!("{}:{}", config.api.bind, config.api.port)
// IPv6 addresses need brackets when combined with port: [::]:19898
let bind_str = if config.api.bind.contains(':') {
format!("[{}]:{}", config.api.bind, config.api.port)
} else {
format!("{}:{}", config.api.bind, config.api.port)
};
let bind: std::net::SocketAddr = bind_str
.parse()
.context("invalid API bind address")?;
let http_shutdown = shutdown_rx.clone();
Expand Down
6 changes: 5 additions & 1 deletion src/messaging/webhook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ impl Messaging for WebhookAdapter {
.route("/health", get(handle_health))
.with_state(state);

let bind = format!("{}:{}", self.bind, self.port);
let bind = if self.bind.contains(':') {
format!("[{}]:{}", self.bind, self.port)
} else {
format!("{}:{}", self.bind, self.port)
};
let listener = tokio::net::TcpListener::bind(&bind)
.await
.with_context(|| format!("failed to bind webhook server to {bind}"))?;
Expand Down