| 405 | |
| 406 | static const char HEX_ALPHA[] = "0123456789ABCDEF"; |
| 407 | void 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 | |
| 430 | inline void UpdateResponseHeader(Controller* cntl) { |
| 431 | DCHECK(cntl->Failed()); |
nothing calls this directly
no test coverage detected