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

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.
pub const NETWORK_DNS: &str = "network.dns";

View File

@ -138,6 +138,7 @@ fn load_component(
}
impl WasmPlugin {
#[expect(clippy::too_many_lines)]
pub async fn on_load(
&self,
context: Arc<Context>,

View File

@ -62,10 +62,13 @@ pub async fn init_plugin(
authors: metadata.authors,
description: metadata.description,
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((
WasmPlugin {

View File

@ -37,11 +37,8 @@ impl pumpkin::plugin::server::HostServer for PluginHostState {
let mut sys = sysinfo::System::new_all();
sys.refresh_all();
let cpu_count = if has_perm(permissions::SYS_INFO) || has_perm(permissions::SYS_INFO_CPU) {
Some(sys.cpus().len() as u32)
} else {
None
};
let cpu_count = (has_perm(permissions::SYS_INFO) || has_perm(permissions::SYS_INFO_CPU))
.then(|| sys.cpus().len() as u32);
let (total_memory, used_memory) =
if has_perm(permissions::SYS_INFO) || has_perm(permissions::SYS_INFO_RAM) {

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).
///
/// Corresponds to the `wasi:sockets/ip-name-lookup` interface.