add password protocol extension, simplify protocol extension api

This commit is contained in:
Toshit Chawda 2024-04-13 16:29:20 -07:00
parent b0d1038a3c
commit 481128e4f5
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
3 changed files with 343 additions and 58 deletions

View file

@ -444,7 +444,9 @@ impl Packet {
return Err(WispError::PacketTooSmall);
}
if let Some(builder) = extension_builders.iter().find(|x| x.get_id() == id) {
extensions.push(builder.build(bytes.copy_to_bytes(length), role))
if let Ok(extension) = builder.build_from_bytes(bytes.copy_to_bytes(length), role) {
extensions.push(extension)
}
} else {
bytes.advance(length)
}