def custom(saved=False): """the function returns the custom rules page when the user is logged in""" utils = Webutils() if utils.check_login() is True: payload = utils.get_default_payload("Custom") payload.rules = utils.get_rule_list("custom") payload.custom = utils.get_rule_status("custom") == "custom" payload.saved = saved return render_template('custom.html', vars=payload) return login("", None)
def ports(saved=False): """the function returns the ports page when the user is logged in""" utils = Webutils() if utils.check_login() is True: payload = utils.get_default_payload("Ports") payload.tcp = utils.get_rule_list("tcp") payload.udp = utils.get_rule_list("udp") payload.custom = False if utils.get_rule_status("tcp") == "custom" or utils.get_rule_status( "udp") == "custom": payload.custom = True payload.saved = saved return render_template('ports.html', vars=payload) return login("", None)
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)
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)
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)