Client auth, Encryption module

This commit is contained in:
Alex-Emmet 2026-01-18 21:42:57 +01:00
commit 5b5fbce22f
15 changed files with 2008 additions and 1003 deletions

View file

@ -250,6 +250,7 @@ pub enum CommunicationType {
get_user_data,
get_iota_data,
iota_user_data,
change_user_data,
change_iota_data,
@ -342,6 +343,7 @@ impl CommunicationType {
"getuserdata" => CommunicationType::get_user_data,
"getiotadata" => CommunicationType::get_iota_data,
"iotauserdata" => CommunicationType::iota_user_data,
"changeuserdata" => CommunicationType::change_user_data,
"changeiotadata" => CommunicationType::change_iota_data,
@ -362,11 +364,11 @@ impl CommunicationType {
#[derive(Debug, Clone)]
pub struct CommunicationValue {
pub id: Uuid,
pub comm_type: CommunicationType,
pub sender: i64,
pub receiver: i64,
pub data: HashMap<DataTypes, JsonValue>,
id: Uuid,
comm_type: CommunicationType,
sender: i64,
receiver: i64,
data: HashMap<DataTypes, JsonValue>,
}
#[allow(dead_code)]
@ -421,7 +423,10 @@ impl CommunicationValue {
self.data.get(&key)
}
pub(crate) fn is_type(&self, p0: CommunicationType) -> bool {
pub fn get_type(&self) -> CommunicationType {
self.comm_type.clone()
}
pub fn is_type(&self, p0: CommunicationType) -> bool {
self.comm_type == p0
}
pub fn to_json(&self) -> JsonValue {

View file

@ -15,7 +15,7 @@ pub fn log_cv(cv: &CommunicationValue) {
let args = [cv.get_data(DataTypes::accepted).unwrap().as_str().unwrap()];
log_message(format(&"identification_response", &args));
} else {
log_message_trans(format!("{:?}", &cv.comm_type));
log_message_trans(format!("{:?}", &cv.get_type()));
}
tokio::spawn(async move {
*UNIQUE.write().await = true;

View file

@ -348,11 +348,7 @@ impl OmikronConnection {
}
if cv.is_type(CommunicationType::identification_response) {
if let Some(accepted) = cv.get_data(DataTypes::accepted) {
if accepted.as_str().unwrap_or("0") != "0" {
log_message(format!("Omikron connected: {}", accepted.to_string()));
} else {
log_message("omikron_connection_failed");
}
}
return;
}

1004
src/util/crypto_util.rs Normal file

File diff suppressed because it is too large Load diff