From 02085c5e2e39624c7ea6d094dc2b5b63a783fe02 Mon Sep 17 00:00:00 2001 From: Michel Oosterhof Date: Wed, 27 Apr 2016 12:46:09 +0400 Subject: [PATCH] twisted style --- twisted/plugins/cowrie_plugin.py | 33 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/twisted/plugins/cowrie_plugin.py b/twisted/plugins/cowrie_plugin.py index 75e8865b..167cc61b 100644 --- a/twisted/plugins/cowrie_plugin.py +++ b/twisted/plugins/cowrie_plugin.py @@ -81,9 +81,9 @@ class CowrieServiceMaker(object): cfg = readConfigFile(options["config"]) - top_service = service.MultiService() + topService = service.MultiService() application = service.Application('cowrie') - top_service.setServiceParent(application) + topService.setServiceParent(application) factory = cowrie.ssh.transport.HoneyPotSSHFactory(cfg) @@ -99,24 +99,23 @@ class CowrieServiceMaker(object): factory.portal.registerChecker( core.checkers.HoneypotNoneChecker()) - - if cfg.has_option('honeypot', 'listen_addr'): - listen_addr = cfg.get('honeypot', 'listen_addr') + if cfg.has_option('honeypot', 'listenAddr'): + listenAddr = cfg.get('honeypot', 'listenAddr') else: - listen_addr = '0.0.0.0' + listenAddr = '0.0.0.0' # Preference: 1, option, 2, config, 3, default of 2222 if options['port'] != 0: - listen_port = int(options["port"]) - elif cfg.has_option('honeypot', 'listen_port'): - listen_port = int(cfg.get('honeypot', 'listen_port')) + listenPort = int(options["port"]) + elif cfg.has_option('honeypot', 'listenPort'): + listenPort = int(cfg.get('honeypot', 'listenPort')) else: - listen_port = 2222 + listenPort = 2222 - for i in listen_addr.split(): - svc = internet.TCPServer(listen_port, factory, interface=i) - # FIXME: Use addService on top_service ? - svc.setServiceParent(top_service) + for i in listenAddr.split(): + svc = internet.TCPServer(listenPort, factory, interface=i) + # FIXME: Use addService on topService ? + svc.setServiceParent(topService) if cfg.has_option('honeypot', 'interact_enabled') and \ cfg.get('honeypot', 'interact_enabled').lower() in \ @@ -125,10 +124,10 @@ class CowrieServiceMaker(object): from cowrie.core import interact svc = internet.TCPServer(iport, interact.makeInteractFactory(factory), interface='127.0.0.1') - # FIXME: Use addService on top_service ? - svc.setServiceParent(top_service) + # FIXME: Use addService on topService ? + svc.setServiceParent(topService) - return top_service + return topService # Now construct an object which *provides* the relevant interfaces # The name of this variable is irrelevant, as long as there is *some*