diff --git a/README.md b/README.md index 48ba5cc..a82bdd8 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ Adding carriers, target and ports is achieved via the *add_shots* method. Once r from cornershot import CornerShot cs = CornerShot("username", "password", "fqdn") cs.add_shots(carriers=["192.168.1.1"],targets=["192.168.1.2","192.168.1.3"]) +cs.lock_and_load() results = cs.open_fire() ``` diff --git a/cornershot/__main__.py b/cornershot/__main__.py index 24035f1..8b01719 100644 --- a/cornershot/__main__.py +++ b/cornershot/__main__.py @@ -110,6 +110,7 @@ def parse_port_ranges(ranges): cs = CornerShot(args.user, args.password, args.domain, workers=args.threads) cs.add_shots(parse_ip_ranges(args.carrier), parse_ip_ranges(args.target), target_ports=parse_port_ranges(args.tports)) + cs.lock_and_load() cs.open_fire() except KeyboardInterrupt: diff --git a/cornershot/cornershot.py b/cornershot/cornershot.py index f014126..df3c3b2 100644 --- a/cornershot/cornershot.py +++ b/cornershot/cornershot.py @@ -66,9 +66,6 @@ def add_shots(self, destinations, targets, target_ports=None, destination_ports= else: self.shot_gen = self._shots_generator(destinations, targets, target_ports, destination_ports) - self.shot_gen, sg_sum = itertools.tee(self.shot_gen) - self.total_shots = sum(1 for _ in sg_sum) - def _shots_generator(self, destinations, targets, target_ports, destination_ports=None): for destination in destinations: for target in targets: @@ -141,6 +138,10 @@ def open_fire(self,blocking=True): main_thread = threading.Thread(target=self._shots_manager,daemon=True) main_thread.start() + def lock_and_load(self): + self.shot_gen, sg_sum = itertools.tee(self.shot_gen) + self.total_shots = sum(1 for _ in sg_sum) + def read_results(self): return self.results diff --git a/setup.py b/setup.py index b77587c..b9b3c89 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ setup( name='cornershot', python_requires='>=3', - version='0.1.8', + version='0.2.0', description='Library to test network connectivity', long_description_content_type='text/markdown', long_description=long_description,