Exemple #1
0
def custom_save():
    """the function saves the custom rules into the corresponding rulesfile"""
    utils = Webutils()
    if utils.check_login() is True:
        for key, value in request.form.items():
            key = str(key) + ""  # just for ignoring the warning
            rulelist = value.split("\n")
            utils.save_rule_list("custom", rulelist)
        return custom(True)
    return login("", None)
Exemple #2
0
def blacklist_save():
    """
    the function saves the blacklist rules into the corresponding rulesfile
    """
    utils = Webutils()
    if utils.check_login() is True:
        ipaddress = ""
        rulelist = utils.get_rule_list("blacklist")

        for key, value in request.form.items():
            if key == "ipadr":
                # then a new ip address is blacklisted
                ipaddress = value
                rulelist.append(ipaddress)
                utils.save_rule_list("blacklist", rulelist)
            else:
                # then a old ip address is removed
                ipaddress = key
                rulelist.remove(ipaddress)
                utils.save_rule_list("blacklist", rulelist)
        return blacklist(True)
    return login("", None)
Exemple #3
0
def remove_port(port, ruletype):
    """the function removes a port from the opened port rules file"""
    utils = Webutils()
    rulelist = utils.get_rule_list(ruletype)
    rulelist.remove(port)
    utils.save_rule_list(ruletype, rulelist)
Exemple #4
0
def add_port(port, ruletype):
    """the function adds a port to the opened port rules file"""
    utils = Webutils()
    rulelist = utils.get_rule_list(ruletype)
    rulelist.append(port)
    utils.save_rule_list(ruletype, rulelist)