summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornamilsk <namilsk@namilsk.tech>2026-02-11 11:38:48 +0300
committernamilsk <namilsk@namilsk.tech>2026-02-11 11:45:05 +0300
commit3271dfc977cc5841731594c308e19aae575c685d (patch)
tree005a343011f98ff400ed578cc1ad2513e700aeef /src
parent14961088a9da16bb1f244f26aaefcadfe07fc8a9 (diff)
Added build features which allows you remove integrated router, code refactoring coming soon
Diffstat (limited to 'src')
-rw-r--r--src/main.rs79
-rw-r--r--src/router/mod.rs3
2 files changed, 52 insertions, 30 deletions
diff --git a/src/main.rs b/src/main.rs
index 0f6b6c6..88d9240 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -6,14 +6,18 @@ mod router;
use crate::cfg::config::Config;
use crate::net::{http_package::HTTPPackage, i2p_package::I2PPackage};
-use crate::pkgtoolkit::Package;
use crate::pkgtoolkit::archive::ArchiveOperations;
use crate::pkgtoolkit::build::BuildOperations;
use crate::pkgtoolkit::git_source::GitSource;
use crate::pkgtoolkit::index::IndexOperations;
use crate::pkgtoolkit::install::InstallOperations;
+use crate::pkgtoolkit::Package;
+
+#[cfg(feature = "integrated-router")]
use crate::router::manager::RouterManager;
+
use clap::{Args, Parser, Subcommand};
+use mesk::cfg::config;
use std::io::Write;
use std::path::Path;
@@ -81,6 +85,7 @@ struct RemoteInstallArgs {
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let cli: Cli = Cli::parse();
+ /*
// Parse config once at the beginning
let config = Config::parse()?;
@@ -101,6 +106,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Integrated router disabled");
None
};
+ */
let result = {
match &cli.command {
@@ -125,6 +131,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
Commands::Build { pkgname } => {
println!("Building package from archive: {}", pkgname);
+ let config = Config::parse()?;
+
let path = Path::new(&pkgname);
if !path.exists() {
return Err(std::io::Error::other(format!(
@@ -192,6 +200,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
path,
args,
} => {
+ let config = Config::parse()?;
if *path {
println!("Installing package from local file: {}", pkgname);
@@ -235,17 +244,18 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
pkg.install()?;
println!("Package '{}' installed successfully.", pkg.name);
} else {
- // Initialize router if it's needed for I2P connections and is enabled
- if !args.http && config.router.integrated_router {
- // Wait for router to be fully started
- if let Some(ref manager) = router_manager {
- println!("Waiting for router to be ready...");
- tokio::time::sleep(std::time::Duration::from_secs(3)).await; // Give router time to start
- if !manager.is_running() {
- eprintln!(
+ #[cfg(feature = "integrated-router")]
+ {
+ if !args.http && config.router.integrated_router {
+ if let Some(ref manager) = router_manager {
+ println!("Waiting for router to be ready...");
+ tokio::time::sleep(std::time::Duration::from_secs(3)).await;
+ if !manager.is_running() {
+ eprintln!(
"Router is not running, cannot proceed with I2P installation"
);
- return Err(std::io::Error::other("Router not running").into());
+ return Err(std::io::Error::other("Router not running").into());
+ }
}
}
}
@@ -308,20 +318,34 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
Commands::GetSource { pkgname } => {
// Initialize router for I2P connections if enabled
- if config.router.integrated_router {
- if let Some(ref manager) = router_manager {
- println!("Waiting for router to be ready...");
- tokio::time::sleep(std::time::Duration::from_secs(2)).await;
- if !manager.is_running() {
- eprintln!("Router is not running, cannot proceed with I2P operation");
- return Err(std::io::Error::other("Router not running").into());
+ let config = Config::parse()?;
+ #[cfg(feature = "integrated-router")]
+ {
+ if config.router.integrated_router {
+ if let Some(ref manager) = router_manager {
+ println!("Waiting for router to be ready...");
+ tokio::time::sleep(std::time::Duration::from_secs(2)).await;
+ if !manager.is_running() {
+ eprintln!(
+ "Router is not running, cannot proceed with I2P operation"
+ );
+ return Err(std::io::Error::other("Router not running").into());
+ }
}
}
+
+ let source_path = GitSource::get_source_by_name(pkgname, &config)?;
}
+
+ #[cfg(feature = "minimal")]
+ {
+ let package = I2PPackage::new();
+ let package_fetch = package.fetch_package(pkgname);
+ }
+
println!("Getting source of {}", pkgname);
- let source_path = GitSource::get_source_by_name(pkgname, &config)?;
- println!("Source code successfully downloaded to: {}", source_path);
+ println!("Source code successfully downloaded to cachedir");
return Ok(());
}
Commands::DefaultConfig {
@@ -332,7 +356,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
} => {
println!("Generating config file");
if cachedir.is_none() && repo.is_none() && buildir.is_none() {
- let config = Config::default().unwrap();
+ let config = Config::default()?;
println!("---- Start of generated config ----");
println!("{}", config);
@@ -363,7 +387,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
return Ok(());
}
Commands::Update => {
- // Initialize router for I2P connections if enabled
+ let config = Config::parse()?;
+
+ #[cfg(feature = "integrated-router")]
+ {
if config.router.integrated_router {
if let Some(ref manager) = router_manager {
println!("Waiting for router to be ready...");
@@ -374,7 +401,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
}
}
-
+ }
println!("Updating index from {}", config.repo.repo_url);
let mut i2p_client = I2PPackage::new(config);
@@ -404,13 +431,5 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
};
- // Shutdown router if it was initialized
- if let Some(ref manager) = router_manager {
- println!("Shutting down integrated router...");
- if let Err(e) = manager.stop().await {
- eprintln!("Error stopping router: {}", e);
- }
- }
-
result
}
diff --git a/src/router/mod.rs b/src/router/mod.rs
index 91da2e5..6426c2e 100644
--- a/src/router/mod.rs
+++ b/src/router/mod.rs
@@ -1,2 +1,5 @@
+
+#[cfg(feature = "integrated-router")]
pub mod manager;
+#[cfg(feature = "integrated-router")]
pub mod router;