added -f for foreground

This commit is contained in:
alex 2026-04-28 14:07:19 +08:00
parent f58ead2d29
commit 503a9b9b6c
3 changed files with 18 additions and 1 deletions

View File

@ -75,6 +75,7 @@ depends = "$auto"
assets = [
# executable
["target/release/punchnet", "usr/local/punchnet/punchnet", "755"],
["punchnet.service", "etc/systemd/system/punchnet.service", "755"],
# lib
["libtuntap.so", "usr/lib/", "755"],
]

View File

@ -315,6 +315,7 @@ fn main() {
let cmd = CommandLineInput2::parse();
// println!("port is {}", cmd.port);
let mut should_daemonize = true;
match &cmd.cmd {
Commands::Login(user) => {
let rt = Runtime::new().unwrap();
@ -402,12 +403,21 @@ fn main() {
});
process::exit(0);
}
Commands::AutoRun(runinfo) => {
if runinfo.foreground {
should_daemonize = false;
}
}
Commands::Start(startinfo) => {
if startinfo.foreground {
should_daemonize = false;
}
}
_other => {
// just fall through to next code
}
}
let should_daemonize = true;
#[cfg(not(target_os = "windows"))]
if should_daemonize {

View File

@ -67,6 +67,9 @@ pub struct StartArguments {
// take over dns or not if change /etc/resolv.conf
#[arg(long)]
pub take_dns: bool,
#[arg(short)]
pub foreground: bool,
}
#[derive(Args, Debug)]
@ -110,6 +113,9 @@ pub struct AutoRunArgument {
// take over dns or not if change /etc/resolv.conf
#[arg(long)]
pub take_dns: bool,
#[arg(short)]
pub foreground: bool,
}
#[derive(Args, Debug)]