Skip to content

Commit 46956ed

Browse files
committed
fixed my own comments
1 parent 934958c commit 46956ed

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ fn build_nmap_arguments<'a>(
212212
/// Goes through all possible IP inputs (files or via argparsing)
213213
/// Parses the string(s) into IPs
214214
fn parse_addresses(opts: &Opts) -> Vec<IpAddr> {
215-
// Construct a new Resolver with default configuration options, DNS.
216215
let mut ips: Vec<IpAddr> = Vec::new();
217216

218217
for ip_or_host in &opts.addresses {
@@ -235,9 +234,8 @@ fn parse_addresses(opts: &Opts) -> Vec<IpAddr> {
235234
}
236235

237236
/// Uses DNS to get the IPS assiocated with host
238-
fn get_ips_from_host(ip_or_host: &String) -> Result<Vec<IpAddr>, std::io::Error> {
237+
fn get_ips_from_host(ip_or_host: &String, resolver: Resolver) -> Result<Vec<IpAddr>, std::io::Error> {
239238
let mut ips: Vec<std::net::IpAddr> = Vec::new();
240-
let resolver = Resolver::new(ResolverConfig::default(), ResolverOpts::default()).unwrap();
241239

242240
match resolver.lookup_ip(&ip_or_host) {
243241
Ok(x) => {
@@ -271,11 +269,13 @@ fn read_ips_from_file(ips: String) -> Result<Vec<std::net::IpAddr>, std::io::Err
271269
/// Call this everytime you have a possible IP_or_host
272270
fn parse_single_ip_or_host(ip_or_host: String) -> Result<Vec<IpAddr>, std::io::Error> {
273271
let mut ips: Vec<IpAddr> = Vec::new();
272+
let resolver = Resolver::new(ResolverConfig::default(), ResolverOpts::default()).unwrap();
273+
274274
match IpCidr::from_str(&ip_or_host) {
275275
Ok(cidr) => cidr.iter().for_each(|ip| ips.push(ip)),
276276
_ => match format!("{}:{}", &ip_or_host, 80).to_socket_addrs() {
277277
Ok(mut iter) => ips.push(iter.nth(0).unwrap().ip()),
278-
_ => match get_ips_from_host(&ip_or_host) {
278+
_ => match get_ips_from_host(&ip_or_host, resolver) {
279279
Ok(hosts) => ips.extend(hosts),
280280
_ => (),
281281
},

0 commit comments

Comments
 (0)