Created
October 25, 2018 14:28
-
-
Save kallisti5/d536bc09e9f54760b791dd53b91b7f5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let args: Vec<String> = env::args().collect(); | |
if args.len() != 2 { | |
println!("Usage: {} <hostname>", args[0]); | |
process::exit(1); | |
} | |
let mut hostname = &args[1].clone().to_string(); | |
let mut steps = vec![render_simple(hostname.clone())]; | |
let mut zone_steps: Vec<String> = Vec::new(); | |
let types = [Rtype::Cname, Rtype::A]; | |
for rtype in types.iter() { | |
let results = match probe_records(hostname.clone(), *rtype) { | |
Ok(o) => o, | |
Err(e) => { | |
println!("Error: {:?}", e); | |
continue; | |
}, | |
}; | |
if *rtype == Rtype::Cname { | |
let mut text = vec!("CNAME Record".to_string()); | |
if results.len() > 1 { | |
println!("WARN: Multiple CNAME records for {}!", hostname); | |
} else if results.len() == 0 { | |
continue; | |
} | |
text.extend(results.clone()); | |
steps.push(render_complex(text)); | |
hostname = &results[0].clone(); | |
continue; | |
} | |
if *rtype == Rtype::A { | |
let mut text = vec!("A Record".to_string()); | |
text.extend(results.clone()); | |
steps.push(render_complex(text)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment