MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / parse_authentication

Method parse_authentication

src/protocol/parser.rs:290–329  ·  view source on GitHub ↗
(
        &self,
        length: usize,
        reader: &mut BufferReader<'_>,
    )

Source from the content-addressed store, hash-verified

288 }
289
290 fn parse_authentication(
291 &self,
292 length: usize,
293 reader: &mut BufferReader<'_>,
294 ) -> Result<BackendMessage> {
295 let code = reader.int32()?;
296 let message = match code {
297 0 => AuthenticationMessage::Ok(AuthenticationOk { length }),
298 3 => AuthenticationMessage::Cleartext(AuthenticationCleartextPassword { length }),
299 5 => {
300 let salt = reader.bytes(4)?;
301 AuthenticationMessage::Md5(AuthenticationMD5Password { length, salt })
302 }
303 10 => {
304 let mut mechanisms = Vec::new();
305 loop {
306 let mechanism = reader.cstring()?;
307 if mechanism.is_empty() {
308 break;
309 }
310 mechanisms.push(mechanism);
311 }
312 AuthenticationMessage::Sasl(AuthenticationSasl { length, mechanisms })
313 }
314 11 => {
315 let data = reader.string(length.saturating_sub(8))?;
316 AuthenticationMessage::SaslContinue(AuthenticationSaslContinue { length, data })
317 }
318 12 => {
319 let data = reader.string(length.saturating_sub(8))?;
320 AuthenticationMessage::SaslFinal(AuthenticationSaslFinal { length, data })
321 }
322 other => {
323 return Err(anyhow!(
324 "Unknown authentication message type {other} (length={length})"
325 ));
326 }
327 };
328 Ok(BackendMessage::Authentication(message))
329 }
330
331 fn parse_error_message(
332 &self,

Callers 1

handle_packetMethod · 0.80

Calls 5

int32Method · 0.80
bytesMethod · 0.80
cstringMethod · 0.80
pushMethod · 0.80
stringMethod · 0.80

Tested by

no test coverage detected