[Updt] MTP

This commit is contained in:
Alex Emmet 2026-09-06 21:57:50 +02:00
commit 8a54a360ca
No known key found for this signature in database
14 changed files with 57 additions and 57 deletions

25
Cargo.lock generated
View file

@ -2707,7 +2707,7 @@ dependencies = [
[[package]]
name = "mtp"
version = "0.3.0"
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
dependencies = [
"mtp-client",
"mtp-codec",
@ -2724,7 +2724,7 @@ dependencies = [
[[package]]
name = "mtp-client"
version = "0.3.0"
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
dependencies = [
"mtp-codec",
"mtp-common",
@ -2737,7 +2737,7 @@ dependencies = [
[[package]]
name = "mtp-codec"
version = "0.3.0"
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
dependencies = [
"base64 0.23.1",
"byteorder",
@ -2751,15 +2751,16 @@ dependencies = [
[[package]]
name = "mtp-common"
version = "0.3.0"
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
dependencies = [
"rand 0.10.2",
"thiserror 2.0.20",
]
[[package]]
name = "mtp-core"
version = "0.3.0"
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
dependencies = [
"async-trait",
"mtp-codec",
@ -2771,7 +2772,7 @@ dependencies = [
[[package]]
name = "mtp-crypto"
version = "0.3.0"
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
dependencies = [
"argon2",
"base64 0.22.1",
@ -2794,7 +2795,7 @@ dependencies = [
[[package]]
name = "mtp-files"
version = "0.3.0"
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
dependencies = [
"mtp-crypto",
"rand 0.10.2",
@ -2805,7 +2806,7 @@ dependencies = [
[[package]]
name = "mtp-h3"
version = "0.3.0"
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
dependencies = [
"async-trait",
"bytes",
@ -2822,7 +2823,7 @@ dependencies = [
[[package]]
name = "mtp-host"
version = "0.3.0"
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
dependencies = [
"mtp-codec",
"mtp-common",
@ -2839,7 +2840,7 @@ dependencies = [
[[package]]
name = "mtp-native"
version = "0.3.0"
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
dependencies = [
"async-trait",
"mtp-codec",
@ -2860,7 +2861,7 @@ dependencies = [
[[package]]
name = "mtp-type-map"
version = "0.3.0"
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
dependencies = [
"serde",
"serde_yaml",
@ -2869,7 +2870,7 @@ dependencies = [
[[package]]
name = "mtp-webserver"
version = "0.3.0"
source = "git+https://git.methanium.net/Methanium/mtp.git#780fb6ae3b4288796069977f3f6bbbae7f7a05fe"
source = "git+https://git.methanium.net/Methanium/mtp.git?rev=a135d0f0c2b35147011905f8ee0fc37050f69a6c#a135d0f0c2b35147011905f8ee0fc37050f69a6c"
dependencies = [
"bytes",
"h3",

View file

@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2024"
[dependencies]
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", features = ["client", "crypto"] }
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", rev = "a135d0f0c2b35147011905f8ee0fc37050f69a6c", features = ["client", "crypto"] }
iota-connection = { path = "../iota-connection" }
iota-logger = { path = "../iota-logger" }
iota-util = { path = "../iota-util" }

View file

@ -444,7 +444,7 @@ impl ClientConnection {
let sender_clone = Arc::clone(sender);
drop(sender_guard);
log_cv_out!(&cv);
log_cv_out!(cv);
if let Err(e) = sender_clone.send(cv).await {
return Err(e.to_string());

View file

@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2024"
[dependencies]
mtp = { git = "https://git.methanium.net/Methanium/mtp.git" }
mtp = { git = "https://git.methanium.net/Methanium/mtp.git"}
iota-util = { path = "../iota-util" }
futures = "*"

View file

@ -6,7 +6,7 @@ edition = "2024"
[dependencies]
iota-storage = { path = "../iota-storage" }
iota-util = { path = "../iota-util" }
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", features = ["crypto"] }
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", rev = "a135d0f0c2b35147011905f8ee0fc37050f69a6c", features = ["crypto"] }
[dev-dependencies]
tokio = { version = "1.50.0", features = ["macros", "rt"] }

View file

@ -175,8 +175,8 @@ pub fn apply_verified_relay_content(
let created_at = i64::try_from(context.created_at)
.map_err(|_| "Relay creation time exceeds the local storage range".to_string())?;
match content.message_type.as_str() {
"MessageState" => {
match content.message_type {
CommunicationType::MessageState => {
let partner_id =
relay_number(&content.content, DataType::ChatPartnerId, &context.type_map)
.and_then(|value| i64::try_from(value).ok())
@ -218,7 +218,7 @@ pub fn apply_verified_relay_content(
let _ = partner_id;
Ok(())
}
"MessageSend" => {
CommunicationType::MessageSend => {
let message = relay_string(&content.content, DataType::Content, &context.type_map)
.ok_or_else(|| "Relay MessageSend is missing Content".to_string())?;
let send_time = relay_number(&content.content, DataType::SendTime, &context.type_map)
@ -288,7 +288,7 @@ pub fn apply_verified_relay_content(
.map_err(|error| error.to_string())?;
Ok(())
}
"MessageEdit" => {
CommunicationType::MessageEdit => {
let message = relay_string(&content.content, DataType::Content, &context.type_map)
.ok_or_else(|| "Relay MessageEdit is missing Content".to_string())?;
let send_time = relay_number(&content.content, DataType::SendTime, &context.type_map)
@ -318,7 +318,7 @@ pub fn apply_verified_relay_content(
};
result.map_err(|error| error.to_string())
}
"MessageReactionAdd" | "MessageReactionRemove" => {
CommunicationType::MessageReactionAdd | CommunicationType::MessageReactionRemove => {
let reaction = relay_string(&content.content, DataType::Reaction, &context.type_map)
.filter(|value| !value.is_empty() && value.len() <= 64)
.ok_or_else(|| "Relay reaction is invalid".to_string())?;
@ -330,7 +330,7 @@ pub fn apply_verified_relay_content(
} else {
sender_id
};
let result = if content.message_type == "MessageReactionAdd" {
let result = if content.message_type == CommunicationType::MessageReactionAdd {
chat_files::add_reaction(
storage_owner,
external_user,
@ -349,7 +349,7 @@ pub fn apply_verified_relay_content(
};
result.map_err(|error| error.to_string())
}
"MessageDelete" | "MessageDeleteLive" => {
CommunicationType::MessageDelete | CommunicationType::MessageDeleteLive => {
let send_time = relay_number(&content.content, DataType::SendTime, &context.type_map)
.and_then(|value| i64::try_from(value).ok())
.ok_or_else(|| "Relay MessageDeleteLive is missing SendTime".to_string())?;
@ -365,7 +365,7 @@ pub fn apply_verified_relay_content(
};
result.map_err(|error| error.to_string())
}
"SetChatSecret" => {
CommunicationType::SetChatSecret => {
let frame = CommunicationValue::new(CommunicationType::SetChatSecret)
.with_payload(content.content.clone());
let recipients = chat_secret_recipients(&frame)
@ -441,7 +441,7 @@ pub fn apply_verified_relay_content(
})
.map_err(|error| error.to_string())
}
"AddConversation" => {
CommunicationType::AddConversation => {
let other_id =
relay_number(&content.content, DataType::ChatPartnerId, &context.type_map)
.and_then(|value| i64::try_from(value).ok())
@ -485,7 +485,7 @@ pub fn validate_outgoing_receipt_policy(
context: &VerifiedRelayContext,
content: &VerifiedRelayContent,
) -> Result<(), String> {
if content.message_type != "MessageState" {
if content.message_type != CommunicationType::MessageState {
return Ok(());
}
let state = relay_string(&content.content, DataType::MessageState, &context.type_map)

View file

@ -197,7 +197,7 @@ where
let context = VerifiedRelayContext {
signer_id: metadata.signer_id(),
final_recipient_id: metadata.final_recipient_id(),
message_id: metadata.message_id().to_owned(),
message_id: metadata.message_id().to_string(),
created_at: metadata.created_at(),
type_map,
};
@ -243,7 +243,7 @@ mod tests {
use mtp::codec::SealedRelayBuilder;
use mtp::crypto::{DualSigner, Ed25519Signer, Keyring};
fn relay(message_id: &str) -> Result<(Keyring, Keyring, CommunicationValue), String> {
fn relay(message_id: u128) -> Result<(Keyring, Keyring, CommunicationValue), String> {
let signer_keyring = Keyring::generate();
let recipient_keyring = Keyring::generate();
let signer = DualSigner::new(
@ -253,7 +253,7 @@ mod tests {
)
.map_err(|error| error.to_string())?;
let frame = SealedRelayBuilder::new(
"MessageSend",
mtp::codec::CommunicationType::MessageSend,
mtp::codec::DataValue::Str("payload".into()),
7,
42,
@ -273,7 +273,7 @@ mod tests {
#[tokio::test]
async fn verifies_metadata_with_trusted_signing_key() -> Result<(), String> {
let (signer, recipient, frame) = relay("accepted")?;
let (signer, recipient, frame) = relay(1)?;
let trusted_key = signer.public_key_bundle();
let verified = verify_relay_metadata(&frame, 99, &recipient, move |signer_id| async move {
(signer_id == 7)
@ -285,13 +285,13 @@ mod tests {
assert_eq!(verified.context.signer_id, 7);
assert_eq!(verified.context.final_recipient_id, 42);
assert_eq!(verified.context.message_id, "accepted");
assert_eq!(verified.context.message_id, "1");
Ok(())
}
#[tokio::test]
async fn content_validation_uses_final_recipient_id() -> Result<(), String> {
let (signer, recipient, frame) = relay("final-recipient")?;
let (signer, recipient, frame) = relay(2)?;
let trusted_key = signer.public_key_bundle();
let verified = verify_relay_metadata(&frame, 99, &recipient, move |signer_id| async move {
(signer_id == 7)
@ -309,7 +309,7 @@ mod tests {
#[tokio::test]
async fn rejects_metadata_signed_by_untrusted_key() -> Result<(), String> {
let (_signer, recipient, frame) = relay("wrong-key")?;
let (_signer, recipient, frame) = relay(3)?;
let wrong_signer = Keyring::generate();
let trusted_key = wrong_signer.public_key_bundle();
let result = verify_relay_metadata(&frame, 99, &recipient, move |_| async move {
@ -328,7 +328,7 @@ mod tests {
let signer = Ed25519Signer::new(&signer_keyring.sig_cl_secret_key)
.map_err(|error| error.to_string())?;
let frame = SealedRelayBuilder::new(
"MessageSend",
mtp::codec::CommunicationType::MessageSend,
mtp::codec::DataValue::Str("payload".into()),
7,
42,
@ -337,7 +337,7 @@ mod tests {
.ok_or("invalid test target")?,
&signer,
)
.message_id("classical-only")
.message_id(7_u128)
.created_at(123)
.metadata_recipients(vec![recipient_keyring.public_key_bundle()])
.content_recipients(vec![recipient_keyring.public_key_bundle()])
@ -355,7 +355,7 @@ mod tests {
#[tokio::test]
async fn rejects_outer_sender_before_key_lookup() -> Result<(), String> {
let (_signer, recipient, frame) = relay("outer-sender")?;
let (_signer, recipient, frame) = relay(4)?;
let frame = frame.with_sender(501);
let result = verify_relay_metadata(&frame, 99, &recipient, |_| async {
Err(RelayValidationError::MissingSigningKeys(7))
@ -371,7 +371,7 @@ mod tests {
#[tokio::test]
async fn verification_does_not_commit_replay_state() -> Result<(), String> {
let (signer, recipient, frame) = relay("duplicate")?;
let (signer, recipient, frame) = relay(5)?;
let trusted_key = signer.public_key_bundle();
for _ in 0..2 {
@ -387,7 +387,7 @@ mod tests {
#[test]
fn forwarding_preserves_sealed_payload() -> Result<(), String> {
let (_signer, _recipient, frame) = relay("forwarding")?;
let (_signer, _recipient, frame) = relay(6)?;
let forwarded = forward_verified_relay(&frame, RouteTarget::User(100))
.map_err(|error| error.to_string())?;

View file

@ -12,7 +12,7 @@ iota-storage = { path = "../iota-storage" }
iota-updater = { path = "../iota-updater" }
iota-util = { path = "../iota-util" }
omikron-connector = { path = "../omikron-connector" }
mtp = { git = "https://git.methanium.net/Methanium/mtp.git" }
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", rev = "a135d0f0c2b35147011905f8ee0fc37050f69a6c" }
libc = "0.2"
sysinfo = "0.38.0"
serde_yaml = "0.9"

View file

@ -8,7 +8,7 @@ iota-paths = { path = "../iota-paths" }
iota-state = { path = "../iota-state" }
iota-util = { path = "../iota-util" }
mtp = { git = "https://git.methanium.net/Methanium/mtp.git" }
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", rev = "a135d0f0c2b35147011905f8ee0fc37050f69a6c" }
ratatui = "0.30.0"
json = "0.12.4"

View file

@ -453,7 +453,7 @@ macro_rules! log_cv_in {
$crate::log_cv_internal("> ", &$cv, Some($kind))
};
($cv:expr) => {
$crate::log_cv_internal("> ", &$cv, None)
$crate::log_cv_internal("> ", $cv, None)
};
}
@ -463,6 +463,6 @@ macro_rules! log_cv_out {
$crate::log_cv_internal("< ", &$cv, Some($kind))
};
($cv:expr) => {
$crate::log_cv_internal("< ", &$cv, None)
$crate::log_cv_internal("< ", $cv, None)
};
}

View file

@ -5,7 +5,7 @@ edition = "2024"
[dependencies]
iota-paths = { path = "../iota-paths" }
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", features = [
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", rev = "a135d0f0c2b35147011905f8ee0fc37050f69a6c", features = [
"crypto"
] }

View file

@ -10,7 +10,7 @@ iota-logger = { path = "../iota-logger" }
iota-state = { path = "../iota-state" }
iota-storage = { path = "../iota-storage" }
iota-util = { path = "../iota-util" }
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", features = [
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", rev = "a135d0f0c2b35147011905f8ee0fc37050f69a6c", features = [
"client",
"crypto",
"files",

View file

@ -947,7 +947,7 @@ impl OmikronConnection {
}
fn client_event_from_relay(
message_type: &str,
message_type: CommunicationType,
payload: &DataValue,
signer_id: u64,
recipient_id: u64,
@ -958,7 +958,7 @@ impl OmikronConnection {
let event_id = next_client_event_id();
match message_type {
"MessageSend" => {
CommunicationType::MessageSend => {
let frame = CommunicationValue::new(CommunicationType::MessageSend)
.with_payload(payload.clone());
let content = frame.get_data(DataType::Content)?.clone();
@ -986,7 +986,7 @@ impl OmikronConnection {
.add_typed_default(DataType::Message, typed_container(message)),
)
}
"SetChatSecret" => {
CommunicationType::SetChatSecret => {
let frame = CommunicationValue::new(CommunicationType::SetChatSecret)
.with_payload(payload.clone());
let chat_id = frame.get_data(DataType::ChatId)?.clone();
@ -1014,7 +1014,7 @@ impl OmikronConnection {
),
)
}
"MessageEdit" => {
CommunicationType::MessageEdit => {
let frame = CommunicationValue::new(CommunicationType::MessageEdit)
.with_payload(payload.clone());
Some(
@ -1037,9 +1037,8 @@ impl OmikronConnection {
.add_typed_default(DataType::ChatPartnerId, sender.clone()),
)
}
"MessageReactionAdd" | "MessageReactionRemove" => {
let frame = CommunicationValue::new(CommunicationType::MessageReactionAdd)
.with_payload(payload.clone());
CommunicationType::MessageReactionAdd | CommunicationType::MessageReactionRemove => {
let frame = CommunicationValue::new(message_type).with_payload(payload.clone());
Some(
CommunicationValue::new(CommunicationType::MessageReactionLive)
.with_id(event_id)
@ -1057,11 +1056,11 @@ impl OmikronConnection {
.add_typed_default(DataType::SenderId, sender)
.add_typed_default(
DataType::Accepted,
DataValue::Bool(message_type == "MessageReactionAdd"),
DataValue::Bool(message_type == CommunicationType::MessageReactionAdd),
),
)
}
"MessageDelete" | "MessageDeleteLive" => {
CommunicationType::MessageDelete | CommunicationType::MessageDeleteLive => {
let frame = CommunicationValue::new(CommunicationType::MessageDelete)
.with_payload(payload.clone());
Some(
@ -1076,7 +1075,7 @@ impl OmikronConnection {
.add_typed_default(DataType::ChatPartnerId, sender),
)
}
"AddConversation" if recipient_id < signer_id => {
CommunicationType::AddConversation if recipient_id < signer_id => {
let chat_id = format!("{recipient_id}:{signer_id}");
Some(
CommunicationValue::new(CommunicationType::ChatSecretForward)
@ -1797,7 +1796,7 @@ impl OmikronConnection {
return;
}
client_event = Self::client_event_from_relay(
&content.message_type,
content.message_type,
&content.content,
verified.context.signer_id,
destination,
@ -3187,7 +3186,7 @@ impl OmikronConnection {
let sender_clone = Arc::clone(sender);
drop(sender_guard);
log_cv_out!(&cv);
log_cv_out!(cv);
if let Err(e) = sender_clone.send(cv).await {
self.fail_all_waiting_tasks(format!(

View file

@ -5,7 +5,7 @@ version = "0.1.0"
edition = "2024"
[dependencies]
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", features = ["web-server"] }
mtp = { git = "https://git.methanium.net/Methanium/mtp.git", rev = "a135d0f0c2b35147011905f8ee0fc37050f69a6c", features = ["web-server"] }
bytes = "1"
http = "1"
iota-logger = { path = "../iota-logger" }