query: add NAT optflag

This commit is contained in:
Denis Drakhnia 2023-10-23 08:00:49 +03:00
parent d1693d41aa
commit b954c7a1f6
1 changed files with 8 additions and 2 deletions

View File

@ -102,6 +102,7 @@ pub fn parse() -> Cli {
opts.optflag("d", "debug", "output debug");
opts.optflag("F", "force-color", "force colored output");
opts.optflag("k", "key", "send challenge key to master");
opts.optflag("n", "nat", "query servers behind NAT");
let help = format!("query filter [default: {:?}]", cli.filter);
opts.optopt("f", "filter", &help, "FILTER");
@ -173,16 +174,21 @@ pub fn parse() -> Cli {
if let Some(s) = matches.opt_str("filter") {
let mut filter = String::with_capacity(cli.filter.len() + s.len());
if !s.contains("\\gamedir") {
if !s.contains("\\gamedir\\") {
filter.push_str("\\gamedir\\valve");
}
if !s.contains("\\clver") {
if !s.contains("\\clver\\") {
filter.push_str("\\clver\\0.20");
}
filter.push_str(&s);
cli.filter = filter;
}
if !cli.filter.contains("\\nat\\") {
let s = if matches.opt_present("nat") { "1" } else { "0" };
cli.filter.push_str(&format!("\\nat\\{}", s));
}
if matches.opt_present("key") {
let key = fastrand::u32(..);
cli.key = Some(key);