[Add] Docs & patches
This commit is contained in:
parent
bd660b2afb
commit
420831cd09
3 changed files with 29 additions and 3 deletions
8
host/src/engine.rs
Normal file → Executable file
8
host/src/engine.rs
Normal file → Executable file
|
|
@ -309,6 +309,12 @@ impl HandshakeEngine {
|
||||||
) || registration
|
) || registration
|
||||||
|| first_msg.get_data(DataType::PublicKeys).is_some()
|
|| first_msg.get_data(DataType::PublicKeys).is_some()
|
||||||
|| claimed_client_id.is_some_and(|client_id| client_id != 0);
|
|| claimed_client_id.is_some_and(|client_id| client_id != 0);
|
||||||
|
tracing::info!(
|
||||||
|
claimed_client_id = ?claimed_client_id,
|
||||||
|
registration,
|
||||||
|
authentication_requested,
|
||||||
|
"classified MTP opening authentication mode"
|
||||||
|
);
|
||||||
if authentication_requested {
|
if authentication_requested {
|
||||||
let attempt = crate::config::AuthenticationAttempt {
|
let attempt = crate::config::AuthenticationAttempt {
|
||||||
peer_network_identity: _authentication_context.peer_network_identity.clone(),
|
peer_network_identity: _authentication_context.peer_network_identity.clone(),
|
||||||
|
|
@ -566,6 +572,7 @@ impl HandshakeEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unknown or zero ID: fall back to guest
|
// Unknown or zero ID: fall back to guest
|
||||||
|
tracing::info!("allocating MTP guest identity");
|
||||||
let guest_id_lease = match self.assign_guest_id().await {
|
let guest_id_lease = match self.assign_guest_id().await {
|
||||||
Ok(lease) => lease,
|
Ok(lease) => lease,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
|
|
@ -574,6 +581,7 @@ impl HandshakeEngine {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let guest_id = guest_id_lease.id;
|
let guest_id = guest_id_lease.id;
|
||||||
|
tracing::info!(guest_id, "allocated MTP guest identity");
|
||||||
send_accepted_generic(sender, &negotiated, tm, Some(guest_id))
|
send_accepted_generic(sender, &negotiated, tm, Some(guest_id))
|
||||||
.await
|
.await
|
||||||
.map_err(AcceptError::Send)?;
|
.map_err(AcceptError::Send)?;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use crate::{
|
||||||
connection::{DecodeRejectionCounters, RuntimePolicy, classify_decode_error},
|
connection::{DecodeRejectionCounters, RuntimePolicy, classify_decode_error},
|
||||||
framing::{RetryClassifier, write_frame},
|
framing::{RetryClassifier, write_frame},
|
||||||
};
|
};
|
||||||
use mtp_codec::{CommunicationValue, DecodeLimits, TypeMap};
|
use mtp_codec::{CommunicationValue, DataType, DecodeLimits, TypeMap};
|
||||||
use mtp_common::CommunicationError;
|
use mtp_common::CommunicationError;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::atomic::{AtomicU64, Ordering};
|
use std::sync::atomic::{AtomicU64, Ordering};
|
||||||
|
|
@ -67,6 +67,15 @@ impl<C: TransportConnection> GenericSender<C> {
|
||||||
if self.connection.close_reason().is_some() {
|
if self.connection.close_reason().is_some() {
|
||||||
return Err(CommunicationError::StreamClosed);
|
return Err(CommunicationError::StreamClosed);
|
||||||
}
|
}
|
||||||
|
if let Some(version) = value.get_str(DataType::Version) {
|
||||||
|
tracing::debug!(
|
||||||
|
message_type = ?value.get_type(),
|
||||||
|
version,
|
||||||
|
connected = ?value.get_data(DataType::Connected),
|
||||||
|
client_id = ?value.get_data(DataType::Id),
|
||||||
|
"sending MTP handshake response frame"
|
||||||
|
);
|
||||||
|
}
|
||||||
match self.policy.send_mode {
|
match self.policy.send_mode {
|
||||||
crate::SendMode::SingleStreamPerMessage => {
|
crate::SendMode::SingleStreamPerMessage => {
|
||||||
let mut stream = self.open().await?;
|
let mut stream = self.open().await?;
|
||||||
|
|
|
||||||
|
|
@ -99,10 +99,19 @@ impl WasmClient {
|
||||||
return Err(js_error(message));
|
return Err(js_error(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let missing_version = || {
|
||||||
|
js_error(format!(
|
||||||
|
"host omitted a valid negotiated protocol version (response_type={:?}, connected={:?}, frame_len={})",
|
||||||
|
outcome.get_type(),
|
||||||
|
outcome.get_data(DataType::Connected),
|
||||||
|
outcome_bytes.len(),
|
||||||
|
))
|
||||||
|
};
|
||||||
|
|
||||||
let negotiated_version = match outcome.get_data(DataType::Version) {
|
let negotiated_version = match outcome.get_data(DataType::Version) {
|
||||||
Some(DataValue::Str(version)) => mtp_codec::Version::parse(version)
|
Some(DataValue::Str(version)) => mtp_codec::Version::parse(version)
|
||||||
.ok_or_else(|| js_error("host omitted a valid negotiated protocol version"))?,
|
.ok_or_else(|| missing_version())?,
|
||||||
_ => return Err(js_error("host omitted a valid negotiated protocol version")),
|
_ => return Err(missing_version()),
|
||||||
};
|
};
|
||||||
if negotiated_version != PROTOCOL_VERSION {
|
if negotiated_version != PROTOCOL_VERSION {
|
||||||
return Err(js_error(
|
return Err(js_error(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue