onionwire/src/dispatch.rs
Sirius DevOps 0ea6fd68c4
All checks were successful
ci / test (pull_request) Successful in 3m9s
[verified] feat(tui): fail-closed /file transfer (1 MiB)
Typed fil frames chunk a local file to the selected friend over the
existing one-shot pipe. Receive-side 1 MiB cap, basename-only names,
hash check before rename, never overwrite. Chat shows [file] name only.
2026-09-10 23:32:06 -04:00

43 lines
887 B
Rust

//! Classify decrypted application plaintext before it hits the message log.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Kind {
Chat,
Loc,
Profile,
Invoice,
Receipt,
Ping,
File,
Drop,
}
pub fn classify(pt: &[u8]) -> Kind {
if pt.starts_with(b"loc ") {
return Kind::Loc;
}
if pt.starts_with(b"prf ") {
return Kind::Profile;
}
if pt.starts_with(b"inv ") {
return Kind::Invoice;
}
if pt.starts_with(b"rcp ") {
return Kind::Receipt;
}
if pt.starts_with(b"png ") {
return Kind::Ping;
}
if pt.starts_with(b"fil ") {
return Kind::File;
}
if pt.len() >= 4
&& pt[0].is_ascii_lowercase()
&& pt[1].is_ascii_lowercase()
&& pt[2].is_ascii_lowercase()
&& pt[3] == b' '
{
return Kind::Drop;
}
Kind::Chat
}