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

Function ComputeChannelSignature

src/brpc/channel.cpp:79–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79static ChannelSignature ComputeChannelSignature(const ChannelOptions& opt) {
80 if (opt.auth == NULL &&
81 !opt.has_ssl_options() &&
82 opt.client_host.empty() &&
83 opt.device_name.empty() &&
84 opt.connection_group.empty() &&
85 opt.hc_option.health_check_path.empty()) {
86 // Returning zeroized result by default is more intuitive for users.
87 return ChannelSignature();
88 }
89 uint32_t seed = 0;
90 std::string buf;
91 buf.reserve(1024);
92 butil::MurmurHash3_x64_128_Context mm_ctx;
93 do {
94 buf.clear();
95 butil::MurmurHash3_x64_128_Init(&mm_ctx, seed);
96
97 if (!opt.connection_group.empty()) {
98 buf.append("|conng=");
99 buf.append(opt.connection_group);
100 }
101 if (!opt.client_host.empty()) {
102 buf.append("|clih=");
103 buf.append(opt.client_host);
104 }
105 if (!opt.device_name.empty()) {
106 buf.append("|devn=");
107 buf.append(opt.device_name);
108 }
109 if (opt.auth) {
110 buf.append("|auth=");
111 buf.append((char*)&opt.auth, sizeof(opt.auth));
112 }
113 if (!opt.hc_option.health_check_path.empty()) {
114 buf.append("|health_check_path=");
115 buf.append(opt.hc_option.health_check_path);
116 buf.append("|health_check_timeout_ms=");
117 buf.append(std::to_string(opt.hc_option.health_check_timeout_ms));
118 }
119 if (opt.has_ssl_options()) {
120 const ChannelSSLOptions& ssl = opt.ssl_options();
121 buf.push_back('|');
122 buf.append(ssl.ciphers);
123 buf.push_back('|');
124 buf.append(ssl.protocols);
125 buf.push_back('|');
126 buf.append(ssl.sni_name);
127 const VerifyOptions& verify = ssl.verify;
128 buf.push_back('|');
129 buf.append((char*)&verify.verify_depth, sizeof(verify.verify_depth));
130 buf.push_back('|');
131 buf.append(verify.ca_file_path);
132 } else {
133 // All disabled ChannelSSLOptions are the same
134 }
135 if (opt.socket_mode == SOCKET_MODE_RDMA) {
136 buf.append("|rdma");

Callers 3

~ChannelMethod · 0.85
InitSingleMethod · 0.85
InitMethod · 0.85

Calls 9

ChannelSignatureClass · 0.85
has_ssl_optionsMethod · 0.45
emptyMethod · 0.45
reserveMethod · 0.45
clearMethod · 0.45
appendMethod · 0.45
push_backMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected