From 455003d0e924414db339395e8367166e7820c5da Mon Sep 17 00:00:00 2001 From: Alberto Sartori Date: Mon, 24 Feb 2025 14:16:42 +0100 Subject: just serve: allow clients to access execution endpoint with a different address To properly use `just serve`, both the client and the serve instance must talk to the very same execution endpoint. Typically, both the client and serve can reach out to the execution endpoint via the same IP address. However, it might be possible that the client and a serve instance know the same execution endpoint by means of differnet IP addresses. For example, the client knows the execution endpoint address through an _external_ IP address, while the serve instance, deployed within the same network infrastructure, only knows the _internal_ IP address. This patch adds the subkey `"client address"` -- of the key `"execution endpoint"` -- in the serve configuration file, to specify the alternative pair `address:port` used by the client. --- src/buildtool/main/serve.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/buildtool/main/serve.cpp') diff --git a/src/buildtool/main/serve.cpp b/src/buildtool/main/serve.cpp index 531074c3..5d5f49fb 100644 --- a/src/buildtool/main/serve.cpp +++ b/src/buildtool/main/serve.cpp @@ -415,6 +415,22 @@ void ReadJustServeConfig(gsl::not_null const& clargs) { } clargs->endpoint.remote_execution_address = address->String(); } + // read the address used by the client + auto client_address = + exec_endpoint->Get("client address", Expression::none_t{}); + if (client_address.IsNotNull()) { + if (not client_address->IsString()) { + Logger::Log( + LogLevel::Error, + "In serve service config file {}:\nValue for execution " + "endpoint key \"client address\" has to be a string, but " + "found {}", + clargs->serve.config.string(), + client_address->ToString()); + std::exit(kExitFailure); + } + clargs->serve.client_remote_address = client_address->String(); + } if (not ParseRetryCliOptions(serve_config, &clargs->retry)) { std::exit(kExitFailure); } -- cgit v1.2.3