34 lines
1.1 KiB
Rust
34 lines
1.1 KiB
Rust
use addr::parse_domain_name;
|
|
|
|
use super::{au, default, uk, whois_base::Whois};
|
|
|
|
pub fn select_whois_server(domain: String) -> Result<Box<dyn Whois>, String> {
|
|
let domain = parse_domain_name(&domain.as_str());
|
|
match domain {
|
|
Ok(val) => match val.suffix() {
|
|
"com.au" => Ok(Box::new(au::_Whois::new())),
|
|
"org.au" => Ok(Box::new(au::_Whois::new())),
|
|
"net.au" => Ok(Box::new(au::_Whois::new())),
|
|
"co.uk" => Ok(Box::new(uk::_Whois::new())),
|
|
"au" => Ok(Box::new(au::_Whois::new())),
|
|
_ => Ok(Box::new(default::_Whois::new())),
|
|
},
|
|
Err(_) => Err(String::from("Failed to select whois server")),
|
|
}
|
|
}
|
|
|
|
// impl RegexQuery {
|
|
// pub fn new(expression: String) -> RegexQuery {
|
|
// let re = Regex::new(&expression).unwrap();
|
|
// RegexQuery { re }
|
|
// }
|
|
|
|
// pub fn get_matches(&self, haystack: &str) -> Vec<String> {
|
|
// let mut results = vec![];
|
|
// for (_, [_, rex2]) in self.re.captures_iter(haystack).map(|c| c.extract()) {
|
|
// results.push(String::from(rex2.trim()));
|
|
// }
|
|
// results
|
|
// }
|
|
// }
|