use serde::{Deserialize, Serialize};
use crate::security::env_modify::Modules_no_suffix;
use crate::security::{SAuthBasicCtrl, SDetailedAccessAllow};
pub const LUA_LOG_LENGTH_LIMIT: usize = 80;
pub const LUAC_PATH: &'static str = "src/security/lua_bin/luac.exe";
pub const ALLOW_DATA_AUTH : bool = true;
#[derive(Serialize, Deserialize, Debug)]
pub enum AppAuthority {
Default,
Su
}
pub enum RunMode {
Thinker,
Executor
}
#[derive(Serialize, Deserialize, Debug)]
pub struct entity_ro {
pub nickname: String, pub entire_id: String, pub basic_authority: SAuthBasicCtrl, pub runtime_permission: AppAuthority, pub thinker_script: String, pub executor_script_or_compiled: String, pub native_access_no_suffix: Modules_no_suffix, pub lua_access_no_suffix: Modules_no_suffix, pub pkg_path: String, pub command_allow: SDetailedAccessAllow, pub file_access_allow: SDetailedAccessAllow,
}
impl entity_ro {
pub fn merge(mut self, usrdata: &entity_usr) -> Self {
for keypair in usrdata.command_allow_extra.iter() {
let key = keypair.0.clone();
let value = keypair.1.clone();
self.command_allow.insert(key, value);
}
for keypair in usrdata.file_access_allow_extra.iter() {
let key = keypair.0.clone();
let value = keypair.1.clone();
self.file_access_allow.insert(key, value);
}
for basic_auth in usrdata.customize_authority.iter() {
self.basic_authority.insert(basic_auth.0.clone(), basic_auth.1.clone());
}
self
}
}
#[derive(Serialize, Deserialize, Debug)]
pub struct entity_usr { pub flags: Vec<String>, pub customize_authority: SAuthBasicCtrl, pub command_allow_extra: SDetailedAccessAllow,
pub file_access_allow_extra: SDetailedAccessAllow,
}
pub struct Dandelion {
pub path: String, pub exe: String, pub cext: String, pub lext: String, pub data: String, pub log: String, pub meta: String, pub man: String,}
impl Dandelion {
pub fn autofill(path: &str) -> Self {
Dandelion {
exe: format!("{}/{}", path, "exe".to_string()),
cext: format!("{}/{}", path, "cext".to_string()),
lext: format!("{}/{}", path, "lext".to_string()),
data: format!("{}/{}", path, "data".to_string()),
log: format!("{}/{}", path, "log".to_string()),
meta: format!("{}/{}", path, "manifest.ron".to_string()),
path: path.parse().unwrap(),
man: "".to_string(), }
}
}