1 Commits
1.0.3 ... async

Author SHA1 Message Date
10345fbce6 Moving to async 2023-07-26 01:26:55 +03:00
3 changed files with 11 additions and 7 deletions

3
Cargo.lock generated
View File

@ -1043,7 +1043,7 @@ checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78"
[[package]] [[package]]
name = "rexec" name = "rexec"
version = "1.0.2" version = "1.0.3"
dependencies = [ dependencies = [
"brace-expand", "brace-expand",
"clap 4.3.4", "clap 4.3.4",
@ -1056,6 +1056,7 @@ dependencies = [
"log", "log",
"massh", "massh",
"regex", "regex",
"tokio",
"whoami", "whoami",
] ]

View File

@ -12,6 +12,7 @@ authors = ["AB <gh@hexor.ru>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
tokio = { version = "1", features = ["full"] }
dns-lookup = "2.0.2" dns-lookup = "2.0.2"
log = "0.4.0" log = "0.4.0"
env_logger = "0.10.0" env_logger = "0.10.0"

View File

@ -94,11 +94,11 @@ fn expand_string(s: &str) -> Vec<Host> {
let start = r.find('[').unwrap(); let start = r.find('[').unwrap();
let end = r.find(']').unwrap(); let end = r.find(']').unwrap();
let colon = r.find(':').unwrap(); let colon = r.find(':').unwrap();
let low = r[start + 1..colon].parse::<i32>().unwrap(); let low = r[start+1..colon].parse::<i32>().unwrap();
let high = r[colon + 1..end].parse::<i32>().unwrap(); let high = r[colon+1..end].parse::<i32>().unwrap();
result.retain(|s| s != &r); result.retain(|s| s != &r);
for val in expand_range(low, high) { for val in expand_range(low, high) {
let new_str = format!("{}{}{}", &r[..start], val, &r[end + 1..]); let new_str = format!("{}{}{}", &r[..start], val, &r[end+1..]);
result.push(new_str); result.push(new_str);
} }
} }
@ -107,10 +107,10 @@ fn expand_string(s: &str) -> Vec<Host> {
let r = r.clone(); let r = r.clone();
let start = r.find('{').unwrap(); let start = r.find('{').unwrap();
let end = r.find('}').unwrap(); let end = r.find('}').unwrap();
let list = &r[start + 1..end]; let list = &r[start+1..end];
result.retain(|s| s != &r); result.retain(|s| s != &r);
for val in expand_list(list) { for val in expand_list(list) {
let new_str = format!("{}{}{}", &r[..start], val, &r[end + 1..]); let new_str = format!("{}{}{}", &r[..start], val, &r[end+1..]);
result.push(new_str); result.push(new_str);
} }
} }
@ -124,7 +124,8 @@ fn expand_string(s: &str) -> Vec<Host> {
hosts hosts
} }
fn main() { #[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::Builder::from_env(Env::default().default_filter_or("info")) env_logger::Builder::from_env(Env::default().default_filter_or("info"))
.format_timestamp(None) .format_timestamp(None)
.format_target(false) .format_target(false)
@ -241,4 +242,5 @@ fn main() {
} else { } else {
warn!("Stopped"); warn!("Stopped");
} }
Ok(())
} }