[Fix] Stability

This commit is contained in:
Alex Emmet 2026-08-28 13:22:59 +02:00
commit 8160f8d0cb
No known key found for this signature in database
44 changed files with 796 additions and 1296 deletions

View file

@ -5,56 +5,12 @@ edition = "2024"
[dependencies]
mtp = { git = "https://git.methanium.net/Methanium/mtp.git" }
iota-logger = { path = "../iota-logger" }
iota-util = { path = "../iota-util" }
iota-storage = { path = "../iota-storage" }
iota-state = { path = "../iota-state" }
iota-auth = { path = "../iota-auth" }
actix-web = { version = "4", features = ["rustls-0_23"] }
actix-web-actors = "4"
aes-gcm = "0.10.3"
async-trait = "0.1.89"
base64 = "0.22.1"
chrono = "0.4.43"
crossterm = "*"
dashmap = "6.1.0"
futures = "*"
futures-util = "*"
hex = "*"
hkdf = "0.12.4"
hyper = { version = "1.8.1", features = [
"capi",
"client",
"full",
"http1",
"http2",
"nightly",
"server",
] }
hyper-util = { version = "*" }
json = "*"
lazy_static = "1.5.0"
once_cell = "1.21.3"
open = "5.3.3"
pnet = "0.35.0"
rand = "0.8"
rand_core = { version = "0.6", features = ["getrandom", "std"] }
ratatui = "0.30.0"
reqwest = "0.13.2"
rusqlite = "0.40.0"
rustls = { version = "0.23.37", features = ["aws-lc-rs"] }
rustls-pemfile = "2.2.0"
serde_json = "1.0.149"
sha2 = "0.11.0"
strum = "0.28.0"
strum_macros = "0.28.0"
sysinfo = "0.39.0"
tokio = { version = "1.50.0", features = ["full"] }
tokio-tungstenite = { version = "*", features = ["native-tls"] }
tungstenite = "*"
uuid = { version = "*", features = ["v4"] }
walkdir = "2.5.0"
warp = "*"
x448 = { version = "*" }
zip = "6.0.0"

View file

@ -40,7 +40,7 @@ impl Community {
let mut buf = [0u8; 56];
let mut rng = OsRng;
rng.fill_bytes(&mut buf);
let private_key = Secret::from_bytes(&buf).unwrap();
let private_key = Secret::from(buf);
let public_key = PublicKey::from(&private_key);
Community {
name: String::new(),
@ -58,7 +58,7 @@ impl Community {
let mut buf = [0u8; 56];
let mut rng = OsRng;
rng.fill_bytes(&mut buf);
let private_key = Secret::from_bytes(&buf).unwrap();
let private_key = Secret::from(buf);
let public_key = PublicKey::from(&private_key);
let c = Community {
name,
@ -125,7 +125,7 @@ impl Community {
self.members.clone()
}
pub fn get_private_key(&self) -> Secret {
Secret::from_bytes(self.private_key.as_bytes()).unwrap()
Secret::from(*self.private_key.as_bytes())
}
pub fn get_public_key(&self) -> &PublicKey {
&self.public_key
@ -222,12 +222,14 @@ impl Community {
for interactable in target_interactables.iter() {
if interactable.get_name() == name {
if interactable.get_codec() == "category" {
let category: &Category =
interactable.as_any().downcast_ref::<Category>().unwrap();
let Some(category) = interactable.as_any().downcast_ref::<Category>() else {
return CommunicationValue::new(CommunicationType::ErrorInternal);
};
// cannot move a value of type dyn Interactable the size of dyn Interactable cannot be statically determined (rustc E0161)
return category
.get_child(path.to_string(), name.to_string())
.unwrap()
.ok_or(CommunicationValue::new(CommunicationType::ErrorInternal))
.unwrap_or_else(|error| return error)
.run_function(cv.clone())
.await;
} else {
@ -267,7 +269,7 @@ impl Community {
let mut data = JsonValue::new_object();
let mut permissions = JsonValue::new_array();
for perm in self.permissions.get(user).unwrap() {
for perm in self.permissions.get(user).into_iter().flatten() {
if let Ok(_) = permissions.push(perm.to_string()) {}
}
@ -287,10 +289,10 @@ impl Community {
}
pub async fn load(name: &String) -> Option<Arc<Community>> {
let file_contents = file_util::load_file(&format!("communities/{}/", name), "config.json");
let json_content = json::parse(&file_contents).unwrap();
let json_content = json::parse(&file_contents).ok()?;
let user_data = file_util::load_file(&format!("communities/{}/", name), "users.json");
let user_json: JsonValue = json::parse(&user_data).unwrap();
let user_json: JsonValue = json::parse(&user_data).ok()?;
let mut users = Vec::new();
let mut permissions: HashMap<i64, Vec<Permission>> = HashMap::new();
@ -318,25 +320,17 @@ pub async fn load(name: &String) -> Option<Arc<Community>> {
};
let community = Community {
name: json_content["name"].as_str().unwrap().to_string(),
name: json_content["name"].as_str()?.to_string(),
owner_id: Arc::new(RwLock::new(json_content["owner_id"].as_i64().unwrap_or(0))),
members: users,
roles,
permissions,
private_key: Secret::from_bytes(
&STANDARD
.decode(json_content["private_key"].as_str().unwrap())
.unwrap(),
)
.unwrap(),
public_key: PublicKey::from(
&Secret::from_bytes(
&STANDARD
.decode(json_content["private_key"].as_str().unwrap())
.unwrap(),
)
.unwrap(),
),
&STANDARD.decode(json_content["private_key"].as_str()?).ok()?,
)?,
public_key: PublicKey::from(&Secret::from_bytes(
&STANDARD.decode(json_content["private_key"].as_str()?).ok()?,
)?),
interactables: Arc::new(RwLock::new(Vec::new())),
connections: Arc::new(RwLock::new(HashMap::new())),
};
@ -346,7 +340,7 @@ pub async fn load(name: &String) -> Option<Arc<Community>> {
file_util::get_children(&format!("communities/{}/interactables/", name));
for file in interactable_files {
if file.contains(".json") {
let name = file.split('.').next().unwrap().to_string();
let Some(name) = file.split('.').next().map(str::to_string) else { continue };
let interactable: Box<dyn Interactable> =
registry::load(comarc.clone(), String::new(), name).await;
comarc.add_interactable(Arc::new(interactable)).await;

View file

@ -52,7 +52,9 @@ impl CommunityConnection {
pub async fn send_message(&self, message: &CommunicationValue) {
let mut sender = self.sender.write().await; // Access the SplitSink
let message_text = Message::Text(Utf8Bytes::from(message.to_json().to_string()));
sender.send(message_text).await.unwrap(); // Send the message via the SplitSink
if let Err(error) = sender.send(message_text).await {
log::error!("failed to send community message: {error}");
}
}
pub async fn get_community(&self) -> Option<Arc<Community>> {
self.community.read().await.clone()
@ -94,14 +96,15 @@ impl CommunityConnection {
}
}
async fn handle_function(&self, cv: CommunicationValue) {
let name = cv.get_data(DataType::Name).unwrap().as_str().unwrap();
let path = cv.get_data(DataType::Path).unwrap().as_str().unwrap();
let function = cv.get_data(DataType::Function).unwrap().as_str().unwrap();
let Some(name) = cv.get_data(DataType::Name).as_str() else { return };
let Some(path) = cv.get_data(DataType::Path).as_str() else { return };
let Some(function) = cv.get_data(DataType::Function).as_str() else { return };
let result = self
.get_community()
.await
.unwrap()
.ok_or(())
.unwrap_or_else(|_| return)
.run_function(self.get_user_id().await, name, path, function, &cv)
.await;
@ -364,13 +367,9 @@ impl CommunityConnection {
pub async fn handle_close(self: Arc<Self>) {
if self.is_identified().await {
if self.get_user_id().await != 0 {
self.community
.read()
.await
.as_ref()
.unwrap()
.remove_connection(self.clone())
.await;
if let Some(community) = self.community.read().await.as_ref() {
community.remove_connection(self.clone()).await;
}
}
}
}

View file

@ -30,14 +30,13 @@ impl Category {
.find(|child| child.get_name() == &name)
.cloned()
} else {
let sub_module = path.split("/").next().unwrap();
let sub_module = path.split('/').next()?;
let next = self
.children
.iter()
.find(|child| child.get_name() == sub_module)
.unwrap();
.find(|child| child.get_name() == sub_module)?;
if next.get_codec() == "category" {
let next_cat = next.as_any().downcast_ref::<Category>().unwrap();
let next_cat = next.as_any().downcast_ref::<Category>()?;
next_cat.get_child(path, name)
} else {
Some(next.clone())