ksud: Add support for module webui
This commit is contained in:
@@ -7,7 +7,7 @@ use android_logger::Config;
|
||||
#[cfg(target_os = "android")]
|
||||
use log::LevelFilter;
|
||||
|
||||
use crate::{apk_sign, debug, defs, event, module, utils};
|
||||
use crate::{apk_sign, debug, defs, event, module, server, utils};
|
||||
|
||||
/// KernelSU userspace cli
|
||||
#[derive(Parser, Debug)]
|
||||
@@ -182,6 +182,16 @@ enum Module {
|
||||
|
||||
/// Shrink module image size
|
||||
Shrink,
|
||||
|
||||
/// Serve module webroot
|
||||
Serve {
|
||||
/// module id
|
||||
id: String,
|
||||
|
||||
/// port
|
||||
#[arg(default_value = "8080")]
|
||||
port: u16,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(clap::Subcommand, Debug)]
|
||||
@@ -262,6 +272,7 @@ pub fn run() -> Result<()> {
|
||||
Module::Disable { id } => module::disable_module(&id),
|
||||
Module::List => module::list_modules(),
|
||||
Module::Shrink => module::shrink_ksu_images(),
|
||||
Module::Serve { id, port } => server::serve_module(&id, port),
|
||||
}
|
||||
}
|
||||
Commands::Install => event::install(),
|
||||
|
||||
@@ -30,6 +30,7 @@ pub const SYSTEM_RW_DIR: &str = concatcp!(MODULE_DIR, ".rw/");
|
||||
pub const TEMP_DIR: &str = "/debug_ramdisk";
|
||||
pub const TEMP_DIR_LEGACY: &str = "/sbin";
|
||||
|
||||
pub const MODULE_WEB_DIR: &str = "webroot";
|
||||
pub const DISABLE_FILE_NAME: &str = "disable";
|
||||
pub const UPDATE_FILE_NAME: &str = "update";
|
||||
pub const REMOVE_FILE_NAME: &str = "remove";
|
||||
|
||||
@@ -11,6 +11,7 @@ mod mount;
|
||||
mod profile;
|
||||
mod restorecon;
|
||||
mod sepolicy;
|
||||
mod server;
|
||||
mod utils;
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
|
||||
@@ -663,10 +663,12 @@ fn _list_modules(path: &str) -> Vec<HashMap<String, String>> {
|
||||
let enabled = !path.join(defs::DISABLE_FILE_NAME).exists();
|
||||
let update = path.join(defs::UPDATE_FILE_NAME).exists();
|
||||
let remove = path.join(defs::REMOVE_FILE_NAME).exists();
|
||||
let web = path.join(defs::MODULE_WEB_DIR).exists();
|
||||
|
||||
module_prop_map.insert("enabled".to_owned(), enabled.to_string());
|
||||
module_prop_map.insert("update".to_owned(), update.to_string());
|
||||
module_prop_map.insert("remove".to_owned(), remove.to_string());
|
||||
module_prop_map.insert("web".to_owned(), web.to_string());
|
||||
|
||||
if result.is_err() {
|
||||
warn!("Failed to parse module.prop: {}", module_prop.display());
|
||||
|
||||
@@ -319,6 +319,6 @@ pub fn punch_hole(src: impl AsRef<Path>) -> Result<()> {
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "linux", target_os = "android")))]
|
||||
pub fn punch_hole(src: impl AsRef<Path>) -> Result<()> {
|
||||
pub fn punch_hole(src: impl AsRef<Path>) -> Result<()> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user