From a937bdbd7d32f77aef015ed2936100f293a14df3 Mon Sep 17 00:00:00 2001 From: mohuva13 Date: Fri, 11 Aug 2023 18:38:33 +0330 Subject: [PATCH] Apply DNS with args -n1 -n2 --- src/main.rs | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 7c24308..3e4830b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,10 @@ -use std::io::Write; use nix::unistd::Uid; mod applyer; use applyer::apply::run_loading as run_loading; use applyer::apply::chattr_cmd as chattr_cmd; use applyer::apply::copy_dns_file as copy_dns_file; +use crate::cash_creator::create_cash_dns::export_chosen_dns; mod all_dns; mod cash_creator; @@ -23,6 +23,36 @@ fn main() { } + // Fast apply dns with args + let args: Vec = std::env::args().collect(); + if args.len() == 5 { + if args[1] == "-n1" && args[3] == "-n2" { + // check dns is valid or not + let mut dns1 = args[2].clone(); + let mut dns2 = args[4].clone(); + if dns1.split(".").collect::>().len() == 4 && dns2.split(".").collect::>().len() == 4 { + + // chattr -i /etc/resolv.conf + chattr_cmd("-i"); + + export_chosen_dns(dns1.clone(), dns2.clone()); + copy_dns_file(); + + { + run_loading("100"); + } + + println!("\n Done!"); + println!("\n GitHub: Mohuva13"); + std::process::exit(0); + + }else { + println!("Invalid DNS!"); + std::process::exit(1); + } + + } + } let dns_list = all_dns::dns_loader::load_dns();