Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, options, filters, push_configs):
self.loop = asyncio.get_event_loop()
max_queues = options.pop("max_size", DEFAULT_MAX_QUEUES)
max_queue_size = options.pop("max_queue_size", DEFAULT_MAX_QUEUE_SIZE)
self.controller = Controller(self.loop, max_queues, max_queue_size)
self.controller.load_configs(filters, push_configs)
options.pop("loop", None) # discard invalid argument
self.manager = Manager(loop=self.loop, **options)
self.manager.log.addHandler(logging.NullHandler())
self.manager.register_event("*", self.handle_events)
self.config = config = dict(
host='127.0.0.1',
port=5038,
http_port='8088',
protocol='http',
debug=True,
)
config.update(bot.config.get('asterisk', {}))
self.log = logging.getLogger('irc3.ast')
self.ilog = logging.getLogger('irc.asterirc')
self.ilog.set_irc_targets(bot, self.config['channel'])
self.log.info('Channel is set to {channel}'.format(**config))
self.rooms = defaultdict(dict)
self.http = None
self.resolver = irc3.utils.maybedotted(self.config['resolver'])
self.manager = Manager(log=logging.getLogger('irc3.ast.manager'),
**config)
self.manager.register_event('Shutdown', self.handle_shutdown)
self.manager.register_event('Meet*', self.handle_meetme)
if config.get('debug'):
self.manager.register_event('*', self.handle_event)
if isinstance(self.resolver, type):
self.resolver = self.resolver(bot)
maxNumTries = int(config['attacker']['maxNumTries'])
maxNumInvitesWithoutAuth = int(config['attacker']['maxNumInvites'])
BLExpireTime = int(config['attacker']['BLExpireTime'])
WLExpireTime = int(config['attacker']['WLExpireTime'])
TLExpireTime = int(config['attacker']['TLExpireTime'])
iptablesChain = config['attacker']['iptablesChain']
else:
maxNumTries = 5
BLExpireTime = 86400
WLExpireTime = 21600
TLExpireTime = 3600
iptablesChain = "INPUT"
# We connect into a Asterisk Manager (Asterisk 11 or newer with Security permissions to read)
manager = Manager(loop=asyncio.get_event_loop(), host=managerHost, port=managerPort, username=managerUser, secret=managerPass)
# Set the logging system to dump everything we do
logging.basicConfig(filename=logFile,level=logging.DEBUG,format='%(asctime)s %(levelname)s: %(message)s')
Log = logging.getLogger()
level = logging.getLevelName(logLevel)
Log.setLevel(level)
logging.debug("Configured Blacklist expire time: "+str(BLExpireTime))
logging.debug("Configured Whitelist expire time: "+str(WLExpireTime))
logging.debug("Configured Templist expire time: "+str(TLExpireTime))
# We set the lists where we storage the addresses.
templist={} # Suspected addresses
whitelist={} # Trusted addresses
blacklist={} # Attackers addresses
invitelist={} # Invite control