def cleaner(self): private_nets = [ '0.%', '127.%', '192.168.%', '10.%', '172.16.%', '172.17.%', '172.18.%', '172.19.%', '172.20.%', '172.21.%', '172.22.%', '172.23.%', '172.24.%', '172.25.%', '172.26.%', '172.27.%', '172.28.%', '172.29.%', '172.30.%', '172.31.%' ] logger.info('Dump cleaner run') # history = History.select(History.id).order_by(History.id.desc()).limit(self.cfg.DiffCount()) # Item.delete().where(~(Item.purge << history)).execute() history_clear = History.select(History.id).order_by( History.id.desc()).offset(self.cfg.DiffCount()) item_del = Item.delete().where(Item.purge << history_clear).execute() logger.info('Item deleted: %d', item_del) ip_del = IP.delete().where(IP.purge << history_clear).execute() logger.info('IP deleted: %d', ip_del) domain_del = Domain.delete().where( Domain.purge << history_clear).execute() logger.info('Domain deleted: %d', domain_del) url_del = URL.delete().where(URL.purge << history_clear).execute() logger.info('URL deleted: %d', url_del) history_rm = History.select(History.id).order_by( History.id.desc()).offset(self.cfg.HistoryCount()) hist_del = History.delete().where(History.id << history_rm).execute() logger.info('History deleted: %d', hist_del) for net in private_nets: ip_count = IP.delete().where(IP.ip % net).execute() if ip_count: logger.info('IP error LIKE %s, count %d', net, ip_count)