aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/channel
diff options
context:
space:
mode:
authorGravatar ncteisen <ncteisen@gmail.com>2018-10-31 19:44:19 -0700
committerGravatar ncteisen <ncteisen@gmail.com>2018-10-31 19:44:19 -0700
commit77895eec56f029dbfd00054dcffc603fa492d054 (patch)
treeee4f914ad99b7980185349daae8ab8b4886bcab5 /src/core/lib/channel
parentfa4894e110c7a70837d366d9f50066a06b01f848 (diff)
use b64, handle localhost
Diffstat (limited to 'src/core/lib/channel')
-rw-r--r--src/core/lib/channel/channelz.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/core/lib/channel/channelz.cc b/src/core/lib/channel/channelz.cc
index cd98b29b1e..376885cdd8 100644
--- a/src/core/lib/channel/channelz.cc
+++ b/src/core/lib/channel/channelz.cc
@@ -36,6 +36,7 @@
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/exec_ctx.h"
+#include "src/core/lib/slice/b64.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/server.h"
@@ -303,11 +304,16 @@ static void PopulateSocketAddressJson(grpc_json* json, const char* name,
} else {
char* host = nullptr;
char* port = nullptr;
- GPR_ASSERT(gpr_split_host_port(host_port, &host, &port));
- if (port != nullptr) {
- port_num = atoi(port);
+ if (strcmp(uri->scheme, "localhost") == 0) {
+ host = gpr_strdup("::1");
+ port_num = atoi(uri->path);
+ } else {
+ GPR_ASSERT(gpr_split_host_port(host_port, &host, &port));
+ if (port != nullptr) {
+ port_num = atoi(port);
+ }
}
- char* b64_host = gpr_string_base64_encode(host);
+ char* b64_host = grpc_base64_encode(host, strlen(host), false, false);
json_iterator =
grpc_json_create_child(json_iterator, json, "tcpip_address", nullptr,
GRPC_JSON_OBJECT, false);