@@ -212,7 +212,6 @@ fn build_nmap_arguments<'a>(
212
212
/// Goes through all possible IP inputs (files or via argparsing)
213
213
/// Parses the string(s) into IPs
214
214
fn parse_addresses ( opts : & Opts ) -> Vec < IpAddr > {
215
- // Construct a new Resolver with default configuration options, DNS.
216
215
let mut ips: Vec < IpAddr > = Vec :: new ( ) ;
217
216
218
217
for ip_or_host in & opts. addresses {
@@ -235,9 +234,8 @@ fn parse_addresses(opts: &Opts) -> Vec<IpAddr> {
235
234
}
236
235
237
236
/// 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 > {
239
238
let mut ips: Vec < std:: net:: IpAddr > = Vec :: new ( ) ;
240
- let resolver = Resolver :: new ( ResolverConfig :: default ( ) , ResolverOpts :: default ( ) ) . unwrap ( ) ;
241
239
242
240
match resolver. lookup_ip ( & ip_or_host) {
243
241
Ok ( x) => {
@@ -271,11 +269,13 @@ fn read_ips_from_file(ips: String) -> Result<Vec<std::net::IpAddr>, std::io::Err
271
269
/// Call this everytime you have a possible IP_or_host
272
270
fn parse_single_ip_or_host ( ip_or_host : String ) -> Result < Vec < IpAddr > , std:: io:: Error > {
273
271
let mut ips: Vec < IpAddr > = Vec :: new ( ) ;
272
+ let resolver = Resolver :: new ( ResolverConfig :: default ( ) , ResolverOpts :: default ( ) ) . unwrap ( ) ;
273
+
274
274
match IpCidr :: from_str ( & ip_or_host) {
275
275
Ok ( cidr) => cidr. iter ( ) . for_each ( |ip| ips. push ( ip) ) ,
276
276
_ => match format ! ( "{}:{}" , & ip_or_host, 80 ) . to_socket_addrs ( ) {
277
277
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 ) {
279
279
Ok ( hosts) => ips. extend ( hosts) ,
280
280
_ => ( ) ,
281
281
} ,
0 commit comments