# Path: lib/settings.py
# def get_top_domains(dbname):


import threading
import lib.utils as utils
import time
import requests
from lib.logger import *
from lib.settings import homenet, lock
                      'pattern: Domain Generation Algorithm (DGA). This is a strong indication ' \
                      'on the presence of active Malware on this device.'
        indicators = '|'.join(homenet.hosts[src].dga_domains)
        reference = 'https://en.wikipedia.org/wiki/Domain_generation_algorithm'
        a = [0, 'dga', self.ctime, self.ctime, 0, 0, 'Malware', src, indicators, 0, description, reference]
        alert_id = utils.add_alert_to_db(a)
        homenet.hosts[src].alerts.append(alert_id)

    def create_spamming_alert(self, src):
        description = 'This host has been detected to be requesting MX records for multiple ' \
                      'different domains in a short period of time. This could indicate that ' \
                      'this device it\'s infected with Malware with spamming capabilities.'
        indicators = '|'.join(homenet.hosts[src].spammed_domains)
        reference = 'https://en.wikipedia.org/wiki/Spamming'
        a = [0, 'spammer', self.ctime, self.ctime, 0, 0, 'Spammer', src, indicators, 0, description, reference]
        alert_id = utils.add_alert_to_db(a)
        homenet.hosts[src].alerts.append(alert_id)


class MinuteAlerts(threading.Thread):
    def __init__(self, threadID):
        threading.Thread.__init__(self)
        self.threadID = threadID
        self.ctime = int(time.time())

    def run(self):

        while 1:
            self.ctime = int(time.time())
            try:

# Path: lib/settings.py
# def get_top_domains(dbname):


# Path: lib/alerts.py
import threading
import lib.utils as utils
import time
import requests
from lib.logger import *
from lib.settings import homenet, lock

                      'pattern: Domain Generation Algorithm (DGA). This is a strong indication ' \
                      'on the presence of active Malware on this device.'
        indicators = '|'.join(homenet.hosts[src].dga_domains)
        reference = 'https://en.wikipedia.org/wiki/Domain_generation_algorithm'
        a = [0, 'dga', self.ctime, self.ctime, 0, 0, 'Malware', src, indicators, 0, description, reference]
        alert_id = utils.add_alert_to_db(a)
        homenet.hosts[src].alerts.append(alert_id)

    def create_spamming_alert(self, src):
        description = 'This host has been detected to be requesting MX records for multiple ' \
                      'different domains in a short period of time. This could indicate that ' \
                      'this device it\'s infected with Malware with spamming capabilities.'
        indicators = '|'.join(homenet.hosts[src].spammed_domains)
        reference = 'https://en.wikipedia.org/wiki/Spamming'
        a = [0, 'spammer', self.ctime, self.ctime, 0, 0, 'Spammer', src, indicators, 0, description, reference]
        alert_id = utils.add_alert_to_db(a)
        homenet.hosts[src].alerts.append(alert_id)


class MinuteAlerts(threading.Thread):
    def __init__(self, threadID):
        threading.Thread.__init__(self)
        self.threadID = threadID
        self.ctime = int(time.time())

    def run(self):

        while 1:
            self.ctime = int(time.time())
            try:

                with lock: