| 231 | } |
| 232 | |
| 233 | void IOChannel::GetDBNameFromAuthBuf(const char * buf, int buf_size) { |
| 234 | if (buf_size < 36) { |
| 235 | return; |
| 236 | } |
| 237 | |
| 238 | uint32_t client_property = 0; |
| 239 | memcpy(&client_property, buf + 4, 4); |
| 240 | |
| 241 | if (client_property & CLIENT_CONNECT_WITH_DB) { |
| 242 | const char * offset = buf + 36; |
| 243 | //skip username |
| 244 | offset += strlen(offset) + 1; |
| 245 | |
| 246 | //skip authorize data |
| 247 | int len_field_size = 0; |
| 248 | uint64_t len = DecodedLengthBinary(offset, buf_size - (offset - buf), len_field_size); |
| 249 | if (len == (uint64_t)(-1LL)) |
| 250 | return; |
| 251 | offset += len_field_size + len; |
| 252 | |
| 253 | //this is the db's name |
| 254 | if (strlen(offset)) { |
| 255 | db_name_ = std::string(offset, strlen(offset)); |
| 256 | } |
| 257 | LOG_DEBUG("client property %u CLIENT_CONNECT_WITH_DB %d ret db [%s]", |
| 258 | client_property, (int) CLIENT_CONNECT_WITH_DB, db_name_.c_str()); |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | void IOChannel::GetDBNameFromReqBuf(const char * buf, int buf_size) { |
| 263 | if (buf_size > 5) { |
nothing calls this directly
no test coverage detected