From 7d6da1bcd6c919dc51e20800b41756f78c94d1c2 Mon Sep 17 00:00:00 2001 From: Samir Talwar Date: Tue, 12 Mar 2024 14:36:01 +0100 Subject: [PATCH] Allow the operator to set the listening host IP address. This is often useful for security reasons, e.g. only listening on localhost or an internal IP when the service is to be proxied. It is also useful in testing on macOS, as running the service bound to a localhost IP (`127.0.0.1` or `::1`) means that the firewall will not be alerted, and so the test will not trigger an allow/deny prompt. --- rust-connector-sdk/src/default_main.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/rust-connector-sdk/src/default_main.rs b/rust-connector-sdk/src/default_main.rs index a01e8bf4..b32ed25a 100644 --- a/rust-connector-sdk/src/default_main.rs +++ b/rust-connector-sdk/src/default_main.rs @@ -56,6 +56,13 @@ struct ServeCommand { configuration: PathBuf, #[arg(long, value_name = "ENDPOINT", env = "OTEL_EXPORTER_OTLP_ENDPOINT")] otlp_endpoint: Option, + #[arg( + long, + value_name = "HOST IP", + env = "HASURA_CONNECTOR_HOST", + default_value_t = net::IpAddr::V4(net::Ipv4Addr::UNSPECIFIED), + )] + host: net::IpAddr, #[arg( long, value_name = "PORT", @@ -67,8 +74,6 @@ struct ServeCommand { service_token_secret: Option, #[arg(long, value_name = "NAME", env = "OTEL_SERVICE_NAME")] service_name: Option, - #[arg(long, env = "HASURA_ENABLE_V2_COMPATIBILITY")] - enable_v2_compatibility: bool, } #[derive(Clone, Parser)] @@ -233,11 +238,8 @@ where serve_command.service_token_secret.clone(), ); - let port = serve_command.port; - let address = net::SocketAddr::new(net::IpAddr::V4(net::Ipv4Addr::UNSPECIFIED), port); - + let address = net::SocketAddr::new(serve_command.host, serve_command.port); println!("Starting server on {}", address); - axum::Server::bind(&address) .serve(router.into_make_service()) .with_graceful_shutdown(async {