This commit is contained in:
Alexander Medvedev committed 2026-04-30 20:02:24 +02:00
1 parent bdc9b79e42
commit c61e170b47
5 files changed
+8 -16

No files matched your search

-4
View File
@@ -1,7 +1,3 @@
/// Constants for plugin permissions.
///
/// Use these in your `PluginMetadata` to request access to specific host features.
/// Allows the plugin to perform DNS resolution. /// Allows the plugin to perform DNS resolution.
pub const NETWORK_DNS: &str = "network.dns"; pub const NETWORK_DNS: &str = "network.dns";
@@ -138,6 +138,7 @@ fn load_component(
} }
impl WasmPlugin { impl WasmPlugin {
#[expect(clippy::too_many_lines)]
pub async fn on_load( pub async fn on_load(
&self, &self,
context: Arc<Context>, context: Arc<Context>,
@@ -62,10 +62,13 @@ pub async fn init_plugin(
authors: metadata.authors, authors: metadata.authors,
description: metadata.description, description: metadata.description,
dependencies: metadata.dependencies, dependencies: metadata.dependencies,
permissions: metadata.permissions.clone(), permissions: metadata.permissions,
}; };
store.data_mut().permissions = metadata.permissions.clone(); store
.data_mut()
.permissions
.clone_from(&metadata.permissions);
Ok(( Ok((
WasmPlugin { WasmPlugin {
@@ -37,11 +37,8 @@ impl pumpkin::plugin::server::HostServer for PluginHostState {
let mut sys = sysinfo::System::new_all(); let mut sys = sysinfo::System::new_all();
sys.refresh_all(); sys.refresh_all();
let cpu_count = if has_perm(permissions::SYS_INFO) || has_perm(permissions::SYS_INFO_CPU) { let cpu_count = (has_perm(permissions::SYS_INFO) || has_perm(permissions::SYS_INFO_CPU))
Some(sys.cpus().len() as u32) .then(|| sys.cpus().len() as u32);
} else {
None
};
let (total_memory, used_memory) = let (total_memory, used_memory) =
if has_perm(permissions::SYS_INFO) || has_perm(permissions::SYS_INFO_RAM) { if has_perm(permissions::SYS_INFO) || has_perm(permissions::SYS_INFO_RAM) {
-5
View File
@@ -1,8 +1,3 @@
/// Constants for plugin permissions.
///
/// Plugins can request these permissions in their metadata to access specific
/// host features.
/// Allows the plugin to perform DNS resolution (resolving hostnames to IP addresses). /// Allows the plugin to perform DNS resolution (resolving hostnames to IP addresses).
/// ///
/// Corresponds to the `wasi:sockets/ip-name-lookup` interface. /// Corresponds to the `wasi:sockets/ip-name-lookup` interface.