Skip to content
Closed

temp PR #7207

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
56 changes: 56 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/goose-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ rustls = { version = "0.23", features = ["ring"] }
uuid = { workspace = true }
once_cell = { workspace = true }
dirs = { workspace = true }
rcgen = "0.13"
axum-server = { version = "0.8.0", features = ["tls-rustls"] }

[target.'cfg(windows)'.dependencies]
winreg = { version = "0.55.0" }
Expand Down
1 change: 1 addition & 0 deletions crates/goose-server/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub async fn check_token(
if request.uri().path() == "/status"
|| request.uri().path() == "/mcp-ui-proxy"
|| request.uri().path() == "/mcp-app-proxy"
|| request.uri().path() == "/mcp-app-guest"
{
return Ok(next.run(request).await);
}
Expand Down
22 changes: 17 additions & 5 deletions crates/goose-server/src/commands/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ use crate::configuration;
use crate::state;
use anyhow::Result;
use axum::middleware;
use axum_server::Handle;
use goose_server::auth::check_token;
use goose_server::tls::self_signed_config;
use tower_http::cors::{Any, CorsLayer};
use tracing::info;

// Graceful shutdown signal
#[cfg(unix)]
async fn shutdown_signal() {
use tokio::signal::unix::{signal, SignalKind};
Expand Down Expand Up @@ -47,17 +48,28 @@ pub async fn run() -> Result<()> {
))
.layer(cors);

let listener = tokio::net::TcpListener::bind(settings.socket_addr()).await?;
info!("listening on {}", listener.local_addr()?);
let addr = settings.socket_addr();
let tls_config = self_signed_config().await?;

let handle = Handle::new();
let shutdown_handle = handle.clone();
tokio::spawn(async move {
shutdown_signal().await;
shutdown_handle.graceful_shutdown(None);
});

info!("listening on https://{}", addr);

let tunnel_manager = app_state.tunnel_manager.clone();
tokio::spawn(async move {
tunnel_manager.check_auto_start().await;
});

axum::serve(listener, app)
.with_graceful_shutdown(shutdown_signal())
axum_server::bind_rustls(addr, tls_config)
.handle(handle)
.serve(app.into_make_service())
.await?;

info!("server shutdown complete");
Ok(())
}
1 change: 1 addition & 0 deletions crates/goose-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub mod error;
pub mod openapi;
pub mod routes;
pub mod state;
pub mod tls;
pub mod tunnel;

// Re-export commonly used items
Expand Down
Loading
Loading