MCPcopy Create free account
hub / github.com/apache/brpc / AppendServerIdentiy

Method AppendServerIdentiy

src/brpc/controller.cpp:407–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

405
406static const char HEX_ALPHA[] = "0123456789ABCDEF";
407void Controller::AppendServerIdentiy() {
408 if (_server == NULL) {
409 return;
410 }
411 if (is_security_mode()) {
412 _error_text.reserve(_error_text.size() + MD5_DIGEST_LENGTH * 2 + 2);
413 _error_text.push_back('[');
414 char ipbuf[64];
415 int len = snprintf(ipbuf, sizeof(ipbuf), "%s:%d",
416 butil::my_ip_cstr(), _server->listen_address().port);
417 unsigned char digest[MD5_DIGEST_LENGTH];
418 MD5((const unsigned char*)ipbuf, len, digest);
419 for (size_t i = 0; i < sizeof(digest); ++i) {
420 _error_text.push_back(HEX_ALPHA[digest[i] & 0xF]);
421 _error_text.push_back(HEX_ALPHA[digest[i] >> 4]);
422 }
423 _error_text.push_back(']');
424 } else {
425 butil::string_appendf(&_error_text, "[%s:%d]",
426 butil::my_ip_cstr(), _server->listen_address().port);
427 }
428}
429
430inline void UpdateResponseHeader(Controller* cntl) {
431 DCHECK(cntl->Failed());

Callers

nothing calls this directly

Calls 7

snprintfFunction · 0.85
my_ip_cstrFunction · 0.85
string_appendfFunction · 0.85
listen_addressMethod · 0.80
reserveMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected