This commit is contained in:
parent
bbb9a2d6c2
commit
1efcb8837c
2 changed files with 34 additions and 24 deletions
|
|
@ -539,7 +539,8 @@ impl MTPClient {
|
||||||
.add_typed_default(DataType::Version, DataValue::Str(version_str.clone()))
|
.add_typed_default(DataType::Version, DataValue::Str(version_str.clone()))
|
||||||
.add_typed_default(DataType::PublicKeys, DataValue::Bytes(pk_bytes.clone()));
|
.add_typed_default(DataType::PublicKeys, DataValue::Bytes(pk_bytes.clone()));
|
||||||
if let Some(desc) = &config.description {
|
if let Some(desc) = &config.description {
|
||||||
register = register.add_typed_default(DataType::Description, DataValue::Str(desc.clone()));
|
register =
|
||||||
|
register.add_typed_default(DataType::Description, DataValue::Str(desc.clone()));
|
||||||
}
|
}
|
||||||
if let Err(e) = sender.send(®ister).await {
|
if let Err(e) = sender.send(®ister).await {
|
||||||
sender.close();
|
sender.close();
|
||||||
|
|
|
||||||
|
|
@ -251,7 +251,9 @@ impl MTPHost {
|
||||||
Some(v) => v,
|
Some(v) => v,
|
||||||
None => return Err(AcceptError::MissingVersion),
|
None => return Err(AcceptError::MissingVersion),
|
||||||
};
|
};
|
||||||
let negotiated = match self.registry.negotiate(std::slice::from_ref(&client_version))
|
let negotiated = match self
|
||||||
|
.registry
|
||||||
|
.negotiate(std::slice::from_ref(&client_version))
|
||||||
{
|
{
|
||||||
Some(v) => v,
|
Some(v) => v,
|
||||||
None => return Err(AcceptError::UnsupportedVersion(client_version)),
|
None => return Err(AcceptError::UnsupportedVersion(client_version)),
|
||||||
|
|
@ -288,7 +290,9 @@ impl MTPHost {
|
||||||
Some(v) => v,
|
Some(v) => v,
|
||||||
None => return Err(AcceptError::MissingVersion),
|
None => return Err(AcceptError::MissingVersion),
|
||||||
};
|
};
|
||||||
let negotiated = match self.registry.negotiate(std::slice::from_ref(&client_version))
|
let negotiated = match self
|
||||||
|
.registry
|
||||||
|
.negotiate(std::slice::from_ref(&client_version))
|
||||||
{
|
{
|
||||||
Some(v) => v,
|
Some(v) => v,
|
||||||
None => return Err(AcceptError::UnsupportedVersion(client_version)),
|
None => return Err(AcceptError::UnsupportedVersion(client_version)),
|
||||||
|
|
@ -435,7 +439,16 @@ impl MTPHost {
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
|
|
||||||
self.complete_auth_handshake(sender, receiver, flow, response_type, &version_str, client_version, description).await
|
self.complete_auth_handshake(
|
||||||
|
sender,
|
||||||
|
receiver,
|
||||||
|
flow,
|
||||||
|
response_type,
|
||||||
|
&version_str,
|
||||||
|
client_version,
|
||||||
|
description,
|
||||||
|
)
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -455,7 +468,7 @@ impl MTPHost {
|
||||||
description: Option<String>,
|
description: Option<String>,
|
||||||
) -> Result<Option<MTPConnection>, AcceptError> {
|
) -> Result<Option<MTPConnection>, AcceptError> {
|
||||||
use mtp_crypto::{
|
use mtp_crypto::{
|
||||||
auth, verify_ed25519, verify_ml_dsa, Ed25519Signer, MlDsaSigner, SignatureScheme,
|
Ed25519Signer, MlDsaSigner, SignatureScheme, auth, verify_ed25519, verify_ml_dsa,
|
||||||
};
|
};
|
||||||
|
|
||||||
let tm = mtp_codec::TypeMap::latest();
|
let tm = mtp_codec::TypeMap::latest();
|
||||||
|
|
@ -688,7 +701,9 @@ impl MTPHost {
|
||||||
})?,
|
})?,
|
||||||
_ => {
|
_ => {
|
||||||
sender.close();
|
sender.close();
|
||||||
return Err(AcceptError::AuthenticationFailed("missing public keys".into()));
|
return Err(AcceptError::AuthenticationFailed(
|
||||||
|
"missing public keys".into(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let pk_bytes = bundle.as_bytes();
|
let pk_bytes = bundle.as_bytes();
|
||||||
|
|
@ -696,10 +711,7 @@ impl MTPHost {
|
||||||
.complete_auth_handshake(
|
.complete_auth_handshake(
|
||||||
sender,
|
sender,
|
||||||
receiver,
|
receiver,
|
||||||
Flow::Register {
|
Flow::Register { bundle, pk_bytes },
|
||||||
bundle,
|
|
||||||
pk_bytes,
|
|
||||||
},
|
|
||||||
mtp_codec::CommunicationType::RegisterResponse,
|
mtp_codec::CommunicationType::RegisterResponse,
|
||||||
&version_str,
|
&version_str,
|
||||||
client_version,
|
client_version,
|
||||||
|
|
@ -718,20 +730,17 @@ impl MTPHost {
|
||||||
if cid > 0
|
if cid > 0
|
||||||
&& let Some(bundle) = (self.config.get_existing_user)(cid).await
|
&& let Some(bundle) = (self.config.get_existing_user)(cid).await
|
||||||
{
|
{
|
||||||
return self
|
return self
|
||||||
.complete_auth_handshake(
|
.complete_auth_handshake(
|
||||||
sender,
|
sender,
|
||||||
receiver,
|
receiver,
|
||||||
Flow::Login {
|
Flow::Login { id: cid, bundle },
|
||||||
id: cid,
|
mtp_codec::CommunicationType::IdentificationResponse,
|
||||||
bundle,
|
&version_str,
|
||||||
},
|
client_version,
|
||||||
mtp_codec::CommunicationType::IdentificationResponse,
|
description,
|
||||||
&version_str,
|
)
|
||||||
client_version,
|
.await;
|
||||||
description,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unknown (or zero) client id → unauthenticated connection.
|
// Unknown (or zero) client id → unauthenticated connection.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue