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


from flask import Flask
from flask import request
from flask import abort
from flask import Response
from lib.logger import *
from lib.settings import homenet, lock, country_stats
import threading
import json
import lib.utils as utils
                return resp
            elif target == 'logs':
                log_count = int(request.json['log_count'])
                data = utils.get_syslogs(log_count)
                resp = Response()
                resp.data = data
                resp.status_code = 200
                resp.mimetype = "application/json"
                return resp
            else:
                abort(400)
        except Exception as e:
            log.debug('FG-WARN: ' + str(e.__doc__) + " - " + str(e))
            resp = Response()
            resp.status_code = 500
            return resp

    @staticmethod
    @app.route('/api/v1.0/falcongate/response/host', methods=['POST'])
    def host_response():
        if not request.json:
            abort(400)

        action = str(request.json['action'])
        target = request.json['target']
        if action == 'blacklist':
            utils.flush_ipset_list('blacklist-user')
            for ip in target:
                with lock:
                    if (len(ip) >= 7) and (ip not in homenet.user_blacklist) and (ip not in homenet.user_whitelist):

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


# Path: api/api.py
from flask import Flask
from flask import request
from flask import abort
from flask import Response
from lib.logger import *
from lib.settings import homenet, lock, country_stats
import threading
import json
import lib.utils as utils

                return resp
            elif target == 'logs':
                log_count = int(request.json['log_count'])
                data = utils.get_syslogs(log_count)
                resp = Response()
                resp.data = data
                resp.status_code = 200
                resp.mimetype = "application/json"
                return resp
            else:
                abort(400)
        except Exception as e:
            log.debug('FG-WARN: ' + str(e.__doc__) + " - " + str(e))
            resp = Response()
            resp.status_code = 500
            return resp

    @staticmethod
    @app.route('/api/v1.0/falcongate/response/host', methods=['POST'])
    def host_response():
        if not request.json:
            abort(400)

        action = str(request.json['action'])
        target = request.json['target']
        if action == 'blacklist':
            utils.flush_ipset_list('blacklist-user')
            for ip in target:
                with lock:
                    if (len(ip) >= 7) and (ip not in homenet.user_blacklist) and (ip not in homenet.user_whitelist):

                        homenet.user_blacklist.append(ip)