Skip to content

Commit

Permalink
feat(CornerShot): getting rid of slowdowns
Browse files Browse the repository at this point in the history
  • Loading branch information
sagiesec committed Feb 9, 2021
1 parent 3c1be3a commit 79c57d1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
27 changes: 12 additions & 15 deletions cornershot/cornershot.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def _get_next_tasks(self,remaining):
if trgt not in self.already_scanned:
new_tasks.append(bullet)
else:
logger.debug(f"Skipping {trgt}, already scanned...")
logger.info(f"Skipping {trgt}, already scanned...")
self.total_shots -= 1
iterated_shots += 1
remaining -= 1
Expand All @@ -152,23 +152,20 @@ def _shots_manager(self):
remaining = remaining - len(self.current_tasks)

for bt in self.current_tasks:
time.sleep(uniform(0, 0.026))
self.bulletQ.put(bt)

while True:
if self.resultQ.empty():
time.sleep(0.3)
else:
while not self.resultQ.empty():
result = self.resultQ.get()
if result:
destination, target, target_port, state = result
self._merge_result(destination, target, target_port, state)
self.resultQ.task_done()
remaining += 1
self.total_shots -= 1
if self.total_shots < 1:
self.runthreads = False
try:
result = self.resultQ.get(timeout=5)
if result:
destination, target, target_port, state = result
self._merge_result(destination, target, target_port, state)
self.resultQ.task_done()
remaining += 1
self.total_shots -= 1
if self.total_shots < 1:
self.runthreads = False
except (TimeoutError,queue.Empty):
break

self.total_shots = 0
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
setup(
name='cornershot',
python_requires='>=3',
version='0.2.8',
version='0.2.9',
description='Library to test network connectivity',
long_description_content_type='text/markdown',
long_description=long_description,
Expand Down

0 comments on commit 79c57d1

Please sign in to comment.