mirror of
https://github.com/egor-white/zaprett.git
synced 2025-12-10 13:30:23 +05:00
use println instead info
This commit is contained in:
10
rust/Cargo.lock
generated
10
rust/Cargo.lock
generated
@@ -327,6 +327,14 @@ version = "2.3.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "135b12329e5e3ce057a9f972339ea52bc954fe1e9358ef27f95e89716fbc5424"
|
checksum = "135b12329e5e3ce057a9f972339ea52bc954fe1e9358ef27f95e89716fbc5424"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iptables"
|
||||||
|
version = "0.6.0"
|
||||||
|
dependencies = [
|
||||||
|
"lazy_static",
|
||||||
|
"regex",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iptables"
|
name = "iptables"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
@@ -951,7 +959,7 @@ dependencies = [
|
|||||||
"clap",
|
"clap",
|
||||||
"daemonize",
|
"daemonize",
|
||||||
"getset",
|
"getset",
|
||||||
"iptables",
|
"iptables 0.6.0 (git+https://github.com/sqlerrorthing/rust-iptables.git?branch=feat%2Fadd-android)",
|
||||||
"libc",
|
"libc",
|
||||||
"libnfqws",
|
"libnfqws",
|
||||||
"log",
|
"log",
|
||||||
|
|||||||
Submodule rust/crates/libnfqws/zapret updated: 0b8e0dc97d...1408c38522
@@ -1,5 +1,4 @@
|
|||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use log::info;
|
|
||||||
use zaprett::cli::CliApp;
|
use zaprett::cli::CliApp;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
@@ -9,7 +8,7 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
let cli = CliApp::parse();
|
let cli = CliApp::parse();
|
||||||
match &cli.cmd() {
|
match &cli.cmd() {
|
||||||
Some(cmd) => cmd.exec().await?,
|
Some(cmd) => cmd.exec().await?,
|
||||||
None => info!("zaprett installed. Join us: t.me/zaprett_module")
|
None => println!("zaprett installed. Join us: t.me/zaprett_module"),
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
use std::borrow::Cow;
|
|
||||||
use nix::unistd::{Pid, Uid};
|
|
||||||
use anyhow::bail;
|
|
||||||
use tokio::fs;
|
|
||||||
use nix::sys::signal::{kill, Signal};
|
|
||||||
use log::info;
|
|
||||||
use tokio::fs::File;
|
|
||||||
use regex::Regex;
|
|
||||||
use tokio::io::AsyncReadExt;
|
|
||||||
use sysctl::Sysctl;
|
|
||||||
use crate::iptables_rust::{clear_iptables_rules, setup_iptables_rules};
|
|
||||||
use crate::{DEFAULT_START, MODULE_PATH, ZAPRETT_DIR_PATH};
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::daemon::daemonize_nfqws;
|
use crate::daemon::daemonize_nfqws;
|
||||||
|
use crate::iptables_rust::{clear_iptables_rules, setup_iptables_rules};
|
||||||
|
use crate::{DEFAULT_START, MODULE_PATH, ZAPRETT_DIR_PATH};
|
||||||
|
use anyhow::bail;
|
||||||
|
use log::info;
|
||||||
|
use nix::sys::signal::{Signal, kill};
|
||||||
|
use nix::unistd::{Pid, Uid};
|
||||||
|
use regex::Regex;
|
||||||
|
use std::borrow::Cow;
|
||||||
|
use sysctl::Sysctl;
|
||||||
|
use tokio::fs;
|
||||||
|
use tokio::fs::File;
|
||||||
|
use tokio::io::AsyncReadExt;
|
||||||
|
|
||||||
pub async fn start_service() -> anyhow::Result<()> {
|
pub async fn start_service() -> anyhow::Result<()> {
|
||||||
if !Uid::effective().is_root() {
|
if !Uid::effective().is_root() {
|
||||||
bail!("Running not from root, exiting");
|
bail!("Running not from root, exiting");
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("Starting zaprett service...");
|
println!("Starting zaprett service...");
|
||||||
|
|
||||||
let tmp_dir = MODULE_PATH.join("/tmp");
|
let tmp_dir = MODULE_PATH.join("/tmp");
|
||||||
if tmp_dir.exists() {
|
if tmp_dir.exists() {
|
||||||
@@ -30,7 +30,8 @@ pub async fn start_service() -> anyhow::Result<()> {
|
|||||||
File::open(ZAPRETT_DIR_PATH.join("config.json"))
|
File::open(ZAPRETT_DIR_PATH.join("config.json"))
|
||||||
.await
|
.await
|
||||||
.expect("cannot open config.json")
|
.expect("cannot open config.json")
|
||||||
.read_to_string(&mut config_contents).await?;
|
.read_to_string(&mut config_contents)
|
||||||
|
.await?;
|
||||||
|
|
||||||
let config: Config = serde_json::from_str(&config_contents).expect("invalid json");
|
let config: Config = serde_json::from_str(&config_contents).expect("invalid json");
|
||||||
|
|
||||||
@@ -61,7 +62,7 @@ pub async fn start_service() -> anyhow::Result<()> {
|
|||||||
setup_iptables_rules().expect("setup iptables rules");
|
setup_iptables_rules().expect("setup iptables rules");
|
||||||
|
|
||||||
daemonize_nfqws(&strat_modified).await;
|
daemonize_nfqws(&strat_modified).await;
|
||||||
info!("zaprett service started!");
|
println!("zaprett service started!");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user