From 27291adf71f01c69d9b978ac197947bb31484642 Mon Sep 17 00:00:00 2001 From: Good Evening Date: Thu, 2 Aug 2018 22:11:11 +0300 Subject: [PATCH] Small fixes --- data/config.yaml | 6 +++++- lib/exeq/Executor.py | 10 ++++++---- lib/plugin/iscan/tasks/common.py | 2 +- lib/plugin/plugins/Gopher.py | 25 ------------------------- 4 files changed, 12 insertions(+), 31 deletions(-) delete mode 100644 lib/plugin/plugins/Gopher.py diff --git a/data/config.yaml b/data/config.yaml index 5453692..df313ec 100644 --- a/data/config.yaml +++ b/data/config.yaml @@ -25,12 +25,16 @@ services: package: lib.plugin.base.lib.Telegram service: TelegramFeed storage: pool - token: "358947514:" + token: "358947212354:" chats: - id: aiWeipeighah7vufoHa0ieToipooYe if: steps.ftp_apply_tpl: true data.filter: false + - id: ohl7AeGah5uo8cho4nae9Eemaeyae3 + if: + steps.gopher_apply_tpl: true + data.filter: false storage: pool: diff --git a/lib/exeq/Executor.py b/lib/exeq/Executor.py index 6b111de..5c38c8d 100644 --- a/lib/exeq/Executor.py +++ b/lib/exeq/Executor.py @@ -22,14 +22,13 @@ class RQExecutor(Executor): def __run(self): redis_conn = Redis(host=self.lcnf.get('redis').get('host')) jobs = [] - + while self._running: - sleep(self.lcnf.get('delay', 0.2)) + sleep(self.lcnf.get('delay', 0.5)) try: for pn, pipeline in self.cnf.get("pipelines").items(): if pn not in self.cnf.get('core').get('pipelines'): continue - source = Loader.by_id('storage', pipeline.get('source')) for step in pipeline['steps']: q = Queue(step.get('priority', 'normal'), connection=redis_conn) for job_id in jobs: @@ -49,12 +48,15 @@ class RQExecutor(Executor): items = self._data.get(block=False, count=count, filter=filter) # obtain everything else from source if len(items) < count: + source = Loader.by_id('storage', pipeline.get('source')) new_items = source.get(block=False, count=(count - len(items)), filter=filter) items.extend(new_items) source.remove(new_items) if items: - self._data.update(items, {'$set': {'steps.%s' % step['task']: None}}) + for i in items: + i['steps'][step['task']] = None + self._data.update(items) job = q.enqueue("lib.exeq.Task.run", step['task'], items) self._logger.info("%s|%s|%s|%s", job.id, step.get('priority', 'normal'), step['task'], len(items)) jobs.append(job.id) diff --git a/lib/plugin/iscan/tasks/common.py b/lib/plugin/iscan/tasks/common.py index c2de352..2d00d92 100644 --- a/lib/plugin/iscan/tasks/common.py +++ b/lib/plugin/iscan/tasks/common.py @@ -38,7 +38,7 @@ class MasScanTask(Task): gi = GeoIP.open(cnf.get("geoip_dat", "/usr/share/GeoIP/GeoIPCity.dat"), GeoIP.GEOIP_INDEX_CACHE | GeoIP.GEOIP_CHECK_CACHE) ip_list = [i['data']['ip'] for i in items] - port_list = cnf.get("tasks").get(self._id).get("ports") + port_list = self.lcnf.get("ports") self._logger.debug("Starting scan, ip_list=%s, port_list=%s", ip_list, port_list) diff --git a/lib/plugin/plugins/Gopher.py b/lib/plugin/plugins/Gopher.py deleted file mode 100644 index 28818a4..0000000 --- a/lib/plugin/plugins/Gopher.py +++ /dev/null @@ -1,25 +0,0 @@ -import netaddr - -from Config import cnf -from lib.plugin.plugins import BasePlugin - - -class Plugin(BasePlugin): - class TelegramMessage(BasePlugin.TelegramMessage): - def _init(self): - self._name = "Gopher" - - def _generate(self): - - class Pipeline(BasePlugin.Pipeline): - def _init(self): - self._name = "Gopher" - - def run(self): - try: - self._find() - self._push() - except Exception as e: - self._logger.debug("Error occured: %s (%s)", e, self._host['ip']) - else: - self._logger.info("Succeeded for %s" % self._host['ip'])