@@ -47,42 +47,6 @@ def _get_files_from_directory(arg):
4747
4848 return files
4949
50- @staticmethod
51- def _get_ips_from_range (ip_range ):
52- ips = set ()
53- ip_range = ip_range .split ("-" )
54-
55- # parsing the above structure into an array and then making into an IP address with the end value
56- end_ip = "." .join (ip_range [0 ].split ("." )[0 :- 1 ]) + "." + ip_range [1 ]
57-
58- # creating an IPRange object to get all IPs in between
59- range_obj = IPRange (ip_range [0 ], end_ip )
60-
61- for ip in range_obj :
62- ips .add (str (ip ))
63-
64- return ips
65-
66- @staticmethod
67- def _get_ips_from_glob (glob_ips ):
68- ip_glob = IPGlob (glob_ips )
69-
70- ips = set ()
71-
72- for ip in ip_glob :
73- ips .add (str (ip ))
74-
75- return ips
76-
77- @staticmethod
78- def _get_cidr_to_ips (cidr_range ):
79- (ip , cidr ) = cidr_range .split ("/" )
80- mask = 32 - int (cidr )
81- first_ip = struct .unpack (">I" , socket .inet_aton (ip ))[0 ]
82- last_ip = first_ip | ((1 << mask ) - 1 )
83- ips = frozenset ([socket .inet_ntoa (struct .pack ('>I' , x )) for x in range (first_ip , last_ip )])
84- return ips
85-
8650 @staticmethod
8751 def _process_port (port_type ):
8852 if "," in port_type :
@@ -216,7 +180,7 @@ def pre_process_target_spec(target_spec):
216180
217181 def parse_and_group_target_specs (target_specs , nocidr ):
218182 str_targets = set ()
219- ipset_targets = IPSet ()
183+ ips_list = list ()
220184 for target_spec in target_specs :
221185 if (
222186 target_spec .startswith ("." ) or
@@ -233,9 +197,15 @@ def parse_and_group_target_specs(target_specs, nocidr):
233197 elif "*" in target_spec :
234198 target_spec = glob_to_iprange (target_spec )
235199 else : # str IP addresses and str CIDR notations
236- target_spec = (target_spec ,)
237- ipset_targets .update (IPSet (target_spec ))
238- return (str_targets , ipset_targets )
200+ if "/" in target_spec :
201+ target_spec = IPSet ((target_spec ,))
202+ else :
203+ target_spec = [target_spec ]
204+
205+ for i in target_spec :
206+ ips_list .append (str (i ))
207+ print (f"updating: { target_spec } " )
208+ return (str_targets , set (ips_list ))
239209
240210 str_targets , ipset_targets = parse_and_group_target_specs (
241211 target_specs = target_specs ,
@@ -259,6 +229,7 @@ def parse_and_group_target_specs(target_specs, nocidr):
259229 target_specs = exclusion_specs ,
260230 nocidr = arguments .nocidr ,
261231 )
232+
262233 str_targets -= str_exclusions
263234 ipset_targets -= ipset_exclusions
264235
@@ -279,7 +250,7 @@ def process_data_for_tasks_iterator(arguments):
279250 str_targets , ipset_targets = InputHelper ._process_targets (
280251 arguments = arguments ,
281252 )
282- targets_count = len (str_targets ) + ipset_targets . size
253+ targets_count = len (str_targets ) + len ( ipset_targets )
283254
284255 if not targets_count :
285256 raise Exception ("No target provided, or empty target list" )
@@ -298,8 +269,6 @@ def process_data_for_tasks_iterator(arguments):
298269
299270 if arguments .proto :
300271 protocols = arguments .proto .split ("," )
301- # if "," not in arguments.proto, [arguments.proto] is returned by
302- # .split()
303272 else :
304273 protocols = None
305274
0 commit comments