Skip to content

Commit f3b0e50

Browse files
committed
Listen on both IPv4 and IPv6 in grpc examples
Use "localhost" instead of "[::1]", as it resolves to IPv4 and/or IPv6 addresses depending on what the system supports. PiperOrigin-RevId: 290139289 Change-Id: I5c289a7e30699a8798a792863b728e11da687f2e
1 parent a97bcda commit f3b0e50

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

asylo/examples/grpc_server/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,11 @@ ABSL_FLAG(int32_t, server_max_lifetime, 300,
289289

290290
ABSL_FLAG(int32_t, port, 0, "Port that the server listens to");
291291

292-
constexpr char kServerAddress[] = "[::1]";
292+
constexpr char kServerAddress[] = "localhost";
293293
```
294294
295-
The address `[::1]` indicates that the server should run locally. Default port
296-
value 0 indicates that the port will be chosen by the operating system.
295+
The `localhost` address indicates that the server should run locally. Default
296+
port value 0 indicates that the port will be chosen by the operating system.
297297
298298
#### gRPC server util module
299299

asylo/examples/grpc_server/grpc_server_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class GrpcServerTest : public ::testing::Test {
7474
// returns the translated word, else returns a non-OK status.
7575
asylo::StatusOr<std::string> MakeRpc(const std::string &input_word) {
7676
std::unique_ptr<TranslatorClient> client;
77-
ASYLO_ASSIGN_OR_RETURN(
78-
client, TranslatorClient::Create(absl::StrCat("[::1]:", server_port_)));
77+
ASYLO_ASSIGN_OR_RETURN(client, TranslatorClient::Create(absl::StrCat(
78+
"localhost:", server_port_)));
7979
return client->GrpcGetTranslation(input_word);
8080
}
8181

asylo/examples/grpc_server/grpc_server_util.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace examples {
3131
namespace grpc_server {
3232
namespace {
3333

34-
constexpr char kServerAddress[] = "[::1]";
34+
constexpr char kServerAddress[] = "localhost";
3535
constexpr char kEnclaveName[] = "grpc_server";
3636

3737
} // namespace

asylo/examples/secure_grpc/grpc_client_main.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "asylo/util/logging.h"
2828
#include "asylo/util/status.h"
2929

30-
constexpr char kServerAddress[] = "[::1]";
30+
constexpr char kServerAddress[] = "localhost";
3131

3232
ABSL_FLAG(std::string, enclave_path, "", "Path to enclave to load");
3333
ABSL_FLAG(int32_t, port, 0, "Port that the server listens to");

asylo/examples/secure_grpc/grpc_server_util.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace examples {
3636
namespace secure_grpc {
3737
namespace {
3838

39-
constexpr char kServerAddress[] = "[::1]";
39+
constexpr char kServerAddress[] = "localhost";
4040
constexpr char kEnclaveName[] = "secure_grpc_server";
4141

4242
} // namespace

asylo/examples/secure_grpc/secure_grpc_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ class GrpcServerTest : public ::testing::Test {
111111
// the same grpc::Status as the stub function call. If the RPC is successful,
112112
// returns the translated word, else returns a non-OK status.
113113
asylo::StatusOr<std::string> MakeRpc(const std::string &input_word) {
114-
return GrpcClientEnclaveGetTranslation(absl::StrCat("[::1]:", server_port_),
115-
input_word);
114+
return GrpcClientEnclaveGetTranslation(
115+
absl::StrCat("localhost:", server_port_), input_word);
116116
}
117117

118118
private:

0 commit comments

Comments
 (0)