Client auth, Encryption module
This commit is contained in:
parent
8075c49835
commit
7a16d6b483
3 changed files with 1029 additions and 6 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -228,11 +228,15 @@ impl OmikronConnection {
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if cv.is_type(CommunicationType::iota_connected) {
|
||||
log_in!(PrintType::Omega, "IOTA connected");
|
||||
if let Some(iota_id) = cv.get_data(DataTypes::iota_id).and_then(|v| v.as_i64()) {
|
||||
user_online_tracker::track_iota_connection(iota_id, omikron_id).await;
|
||||
let mut user_ids = JsonValue::Array(Vec::new());
|
||||
if let Ok(users) = sql::get_users_by_iota_id(iota_id).await {
|
||||
for user in users {
|
||||
let _ = user_ids.push(JsonValue::from(user.0));
|
||||
user_online_tracker::track_user_status(
|
||||
user.0,
|
||||
ConnectionType::UserOffline,
|
||||
|
|
@ -240,7 +244,17 @@ impl OmikronConnection {
|
|||
)
|
||||
.await;
|
||||
}
|
||||
} else {
|
||||
log_in!(PrintType::General, "SQL error, when loading users for IOTA");
|
||||
}
|
||||
self.send_message(
|
||||
&CommunicationValue::new(CommunicationType::iota_user_data)
|
||||
.with_id(cv.get_id())
|
||||
.add_data(DataTypes::user_ids, user_ids),
|
||||
)
|
||||
.await;
|
||||
} else {
|
||||
log_in!(PrintType::General, "No IOTA ID found");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
1004
src/util/crypto_util.rs
Normal file
1004
src/util/crypto_util.rs
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue